Sersync2安装与部署


实验环境:

      OSRHEL5.6

主机1(client) apache  ip : 192.168.18.254

需要安装软件:sersync2+  rsync(默认已安装)

主机2(server) rsync   ip : 192.168.18.146

需要安装软件:rsync (默认已安装)


一、主机1的操作(1)

apache  192.168.18.254

[root@apache ~]#tar fvxz sersync.tar.gz    #解压缩

GNU-Linux-x86/

GNU-Linux-x86/sersync2

GNU-Linux-x86/confxml.xml

[root@apache~]#cd GNU-Linux-x86/

[root@apacheGNU-Linux-x86]#vim confxml.xml  #修改sersync的配置文件

<sersync>

     <localpath watch="/var/www/html">      #同步本地目录的路径

     <remote ip="192.168.18.146"name="www"/>   #远端服务器的ip和共享目录的名称


<commonParamsparams="-artuz"/>

     <auth start="true" users="lijie"passwordfile="/etc/rsync.pass"/>     #用户名与密码文件存放路径


<failLog path="/tmp/rsync_fail_log"timeToExecute="60"/><!--default every 60mins

execute once-->;


二、主机2的操作

rsync192.168.18.146

[root@rsync ~]#mkdir �Cpv /e       tc/rsyncd    #创建rsync配置文件的目录

[root@rsync ~]#cd /etc/rsyncd

[root@rsync rsyncd]#vim rsyncd.secrets    #添加用户验证信息

lijie:123

[root@rsyncrsyncd]#chmod 600 /etc/rsyncd rsyncd.secrets  #注意此文件的权限必须是600

[root@rsyncrsyncd]#ll /etc/rsyncd rsyncd.secrets

rw------- 1 root root  13 Jul 14 02:20 rsyncd.secrets

[root@rsync rsyncd]#vim/etc/rsyncd/rsyncd.conf  #编辑rsync的主配置文件

uid=root

gid=root

port=873

maxconnections=0   #limit client conection

use chroot = no

log file=/var/log/rsyncd.log

pid file=/var/run/rsyncd.pid

lock file=/var/run/rsyncd.lock


motd file = /etc/rsyncd/rsyncd.motd

read only=no   #关闭只读,因为主机1要向主机2 共享目录中执行写的操作

####limit user conn######

hosts allow=192.168.18.0/255.255.255.0

hosts deny=*

#transfer logging = yes

#log format = %t%a %m %f %b

#syslog facility = local3

#timeout = 300

[www]                                        #共享目录名称

path = /tmp/www                             #共享目录的路径

list = yes

ignore errors

auth users = lijie                              #定义用户

###username!!

secrets file = /etc/rsyncd/rsyncd.secrets  #用户验证机制存放路径

comment = www directory            #描述

read only = no

[root@rsync rsyncd]#mkdir �Cp /tmp/www  #创建共享目录

[root@rsync ~]##rsync --daemon--config=/etc/rsyncd/rsyncd.conf #启动rsyns

146#lsof -i:873    #验证启动结果

COMMAND PID USER   FD   TYPE DEVICE SIZE NODE NAME

rsync  4356 root    4u  IPv6 14561       TCP *:rsync (LISTEN)

rsync  4356 root    5u  IPv4 14562       TCP *:rsync (LISTEN)


三、主机1的操作(2)

apache192.168.18.254

[root@apache~]#vim /etc/rsyns.pass  #编辑密码文件

123

[root@apache ~]#chmod 600 /etc/rsync.pass  #密码文件权限为600


[root@apache ~]#ps axu | grep rsync   #查看本机是否启动rsync进程,有--> kill掉,

root      8043 0.0  0.0   5252  480 ?        Ss   11:08  0:00 rsync --daemon --config=/etc/rsyncd/rsyncd.conf

root     8191  0.6  2.3 82416 24024 pts/7    S+   11:17  0:11 gedit rsync.txt

root     8668  0.0  0.0  5024   696 pts/3    S+  11:46   0:00 grep rsync

[root@apache ~]# kill -9 8043  #kill rsync进程

Test  启动测试

[root@apache~]#cd GNU-Linux-x86/  

[root@apacheGNU-Linux-x86]# ./sersync2 -r    #启动sersync服务

set the systemparam

executeecho50000000 > /proc/sys/fs/inotify/max_user_watches

executeecho327679 > /proc/sys/fs/inotify/max_queued_events

parse the command param

option: -r      rsync all the local files to the remoteservers before the sersync work

daemon thread num: 10

parse xml config file

host ip : localhost     host port: 8008

use rsync password-file :

user is lijie

passwordfile is         /etc/rsync.pass

config xml parse success

please set /etc/rsyncd.conf maxconnections=0 Manually

sersync working thread 12  = 1(primary thread) + 1(fail retry thread) +10(daemon sub threads)

Max threads numbers is: 22 = 12(Thread poolnums) + 10(Sub threads)

please according your cpu use -n param to adjust the cpu rate

------------------------------------------

rsync the directory recursivly to theremote servers once

working please wait...

execute command: cd /var/www/html&& rsync -artuz -R --delete ./ [email protected]::www--password-file=/etc/rsync.pass >/dev/null 2>&1

run the sersync:

watch path is: /var/www/html

此终端已被占用,如果需要进行测试同步结果,就需要另开一个终端,本实验就不在测试啦!


至此, sersyns 已经部署完毕,只要主机 1 /var/www/html 目录中有变化,都会被同步的主机 2 /tmp/www 目录中。


你可能感兴趣的:(rsync,sersync2)