公司有需要做线上设备的主备数据实时同步,其中有些注意事项,详细信息如下:
http://qiuyt.blog.51cto.com/1229789/1742977
1,Rsync:873
2,注意需要关闭iptables
3,实时查看sersync进程及rsync进程 是否正常运行
4,使用Sersync自动同步之前 使用rsync手动同步测试
5,rsync version 3.0.6 system:Centos 2.6.32-279.el6.x86_64
6,Master:192.168.1.202 ,Slave:192.168.1.206
1,检测系统环境是否支持
[root@Nagios inotify-tools-3.14]# uname -m x86_64 [root@Nagios inotify-tools-3.14]# uname -r 2.6.32-279.el6.x86_64
一、RSYNC Client Configuration
2,创建rsyncd.conf 配置文件,如果存在需要CP进行备份。
sync server #created by qyt 20160218 #rsyncd.conf start# uid = root gid = root user chroot = no max connections = 2000 timeout = 600 pod file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 192.168.1.202/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password ############################################### [cfgs] comment = www by qyt 20160218 path = /usr/local/nagios/etc/cfgs #################################################3 [objects] comment = bbs by qyt 20160218 path = /usr/local/nagios/etc/objects #################################################3 EOF
3,创建相关待同步目录
mkdir -p /data0/www/bbs/ /data0/www/www/ /data0/www/blog/
(同时创建多个目录,也就是需要同步的目录,如果目录存在请忽略)
推送用户要有对被同步目录的写入更新的权限
3,认证
配置Password ,自行定义,[[ 但需要与/etc/rsyncd.conf 配置文件中secrets= * 定义内容相同 ]]
echo "rsync_backup:123" > /etc/rsync.password chmod 600 /etc/rsync.password #for check cat /etc/rsync.password ll /etc/rsync.password
4,配置好后,使用如下命令,开启rsync守护进程
rsync --daemon ps -ef|grep rsync netstat -lnt|grep 873 lsof -i :873
[root@Nagios /etc]$ps -ef|grep rsync root 2048 1 0 17:52 ? 00:00:00 /usr/bin/rsync --daemon root 3544 2237 0 19:24 pts/0 00:00:00 grep rsync [root@Nagios /etc]$netstat -lnt|grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN tcp 0 0 :::873 :::*
5,设置开机自启动
echo "##rsync service daemon by qyt 20160218" >>/etc/rc.local echo "/usr/local/bin/rsync--daemon" >>/etc/rc.local grep daemon /etc/rc.local
6,重启服务
pkill rsync rsync --daemon ps -ef|grep rsync
二、Rsync Master Configuration
1,手动测试同步rsync(测试之前停掉防火墙 否则会引起失败)
2,在Master上配置rsync权限,只需要配置密码就OK了。
echo "123" > /etc/rsync.password chmod 600 /etc/rsync.password #for check cat /etc/rsync.password ll /etc/rsync.password
3,创建测试文件
touch /usr/local/nagios/etc/cfgs/cfgs.log /usr/local/nagios/etc/objects/objects.log
tree /usr/local/nagios/etc/ ├── cfgs │ ├── cfgs.log ├── objects │ ├── objects.log
3,执行同步,手动执行
rsync -avzP /usr/local/nagios/etc/cfgs/ rsync_backup@192.168.1.206::cfgs/ --password-file=/etc/rsync.password
rsync -avzP /usr/local/nagios/etc/objects/ rsync_backup@192.168.1.206::objects/ --password-file=/etc/rsync.password
[root@Nagios etc]# rsync -avzP /usr/local/nagios/etc/cfgs/ rsync_backup@192.168.1.206::cfgs/ --password-file=/etc/rsync.password sending incremental file list ./ cfgs.log 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=4/11) sent 312 bytes received 30 bytes 684.00 bytes/sec total size is 87568 speedup is 256.05
4,然后去backup server(nagios02)上去验证,是否有同步过去的文件
[root@Nagios02 /usr/local/nagios/etc]$tree ├── cfgs │ ├── cfgs.log ├── objects │ ├── objects.log 成功
三、Sersync Configuration
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。