rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Chongqing /etc/localtime
date
Thu Jan 6 17:46:43 CST 2011
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Chongqing /etc/localtime
date
Thu Jan 6 17:46:43 CST 2011
为了安全,数据每天备份是非常有必要的,之前cron一直跑的很顺利,最近发现每天ftp上的备份数据都不完整,找来找去没找到原因,直接跑备份脚本又完全没问题
具体现象:备份脚本第一行执行不完整,而后面的会被继续,ftp上就会有个不完整的备份文件
断断续续Google了一两周,没结果,最后问朋友,也没搞定,不过有句话到时启发我了,问我的脚本需不需要输出,我想想不需要,就把脚本输出写到/dev/null了,今早起来看ftp,嘿~就对了
不知道是不是cron能接受的脚本输出有限,超过就撑爆然后打断。
最近闲着无聊,看了下/var/log/secure,那简直壮观的没的话说,每天都能好几百次穷举暴力攻击,不过估计都是在猜测一些比较简单的密码,每ip也就拿么几十次尝试
所以,是时候稍微动动手了 vi /etc/ssh/sshd_config
LoginGraceTime 5
Port 21212
ListenAddress 0.0.0.0:21212
IgnoreUserKnownHosts yes
然后重启sshd,现在绝大多数盲扫已经与你无关了,现在先别急着断开,还有很重要的事情
为了更加安全,现在可以禁用root远程登陆,当然,很多时候连上去都是为了做些配置修改的,因此,直接禁用root然后用su就显得有些多此一举了,所以需要让root用户只能用公钥私钥验证登陆就比较方便了
PermitRootLogin without-password
添上这一段后,把生成好的root公钥丢上去,然后就完事了
生成ssh用密钥对:ssh-keygen -t dsa -b 1024 -f /user/keys,密码留空,然后cp /user/keys.pub /user/.ssh/authorized_keys,把keys拉回本地然后删除
拿下来的keys已经可以在基于openssh的客户端上用了,如果要给putty用,还需要用putty自带的工具转一下格式
最近又被垃圾服务商折腾了,ftp备份居然不完整,最后决定用rsync做backup,避免一切意外情况- –
呃。。其实有点标题党,不过确实只有3大步骤- –
1.在需要备份的服务器上生成ssh用密钥对:ssh-keygen -t dsa -b 1024 -f /user/keys,密码留空,然后cp /user/keys.pub /user/.ssh/authorized_keys,如果已经有密钥对了跳过此步
2.把上面生成的私钥keys丢到备份服务器上,然后尝试首次同步,为了加速同步,可以先把所有文件搬到备份机,然后增量就很快了:
rsync -avz -e “ssh -i /user/keys” root@remote_server_ip:/remote_path /local_path
3.写入crontab实现自动备份
crontab -e,把这一段丢进去:@daily rsync -avz -e “ssh -i /user/keys” root@remote_server_ip:/remote_path /local_path
如此高压之下,nginx依旧表示蛋定,不得不服气- –
有空了研究下详细的参数,继续优化
测试环境:两个相距5跳的vps,ping下来1.2ms
被测试vps:512M内存,1024M的burst,openvz,跑完3000个测试load接近2
网页是博客首页,已经用w3 total cache静态化
[root@vps ~]#ab -c 100 -n 3000 http://johnliu.info/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking johnliu.info (be patient)
Completed 300 requests
Completed 600 requests
Completed 900 requests
Completed 1200 requests
Completed 1500 requests
Completed 1800 requests
Completed 2100 requests
Completed 2400 requests
Completed 2700 requests
Finished 3000 requests
Server Software: nginx/0.8.53
Server Hostname: johnliu.info
Server Port: 80
Document Path: /
Document Length: 32170 bytes
Concurrency Level: 100
Time taken for tests: 10.576416 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 97896000 bytes
HTML transferred: 96510000 bytes
Requests per second: 283.65 [#/sec] (mean)
Time per request: 352.547 [ms] (mean)
Time per request: 3.525 [ms] (mean, across all concurrent requests)
Transfer rate: 9039.07 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 60 395.1 7 3012
Processing: 49 268 85.3 268 2438
Waiting: 21 228 75.8 225 2415
Total: 51 328 404.6 275 3981
Percentage of the requests served within a certain time (ms)
50% 275
66% 293
75% 302
80% 308
90% 334
95% 362
98% 783
99% 3273
100% 3981 (longest request)