实验:定时同步数据
准备俩台实验机器,一台作为服务器server,一台作为client
server:192.168.18.126
client:192.168.18.127
如果想把126的数据实时同步到127:
sersync2监控------>126
rsync 服务端 ------>127
在126操作:
把sersync2工具上传到126
插件下载地址:http://download.csdn.net/detail/funk4/8125367
解压,并配置confxml.xml
<sersync>
<localpath watch="/opt/tongbu">
#126机器的同步数据文件夹路径
<remote ip="192.168.18.127" name="tongbu"/>#127机器同步数据文件名
<commonParams params="-artuz"/>
<auth start="true" users="lewis" passwordfile="/etc/rsync.pass"/>
在127操作:
1 install
yum install rsync
2
touch this directory
[root@www rsyncd]# pwd
/etc/rsyncd
[root@www rsyncd]# ls -l
-rw-r--r-- 1 root root 491 07-25 11:08 rsyncd.conf
-rw-r--r-- 1 root root 64 07-25 10:26 rsyncd.motd
-rw------- 1 root root 8 07-25 10:26 rsyncd.secrets
3 vim /etc/rsyncd/rsyncd.conf
uid=root
gid=root
port=873
max connections=0
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=yes
[cache]
path=/cache
list=yes
ignore errors
auth users=lewis#设置虚拟用户
secrets file=/etc/rsyncd/rsyncd.p#虚拟用户密码
read only=no
[root@www rsyncd]# cat rsyncd.motd #欢迎页面
#####################
welcome
#####################
[root@www rsyncd]# cat rsyncd.p
lewis:123
[root@www rsyncd]# chmod 600 rsyncd.p
4 start #启动
[root@www rsyncd]# rsync --daemon --config=/etc/rsyncd/rsyncd.conf
[root@www rsyncd]# lsof -i:873 #检查873端口
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
rsync 8043 root 4u IPv6 22013 TCP *:rsync (LISTEN)
rsync 8043 root 5u IPv4 22014 TCP *:rsync (LISTEN)
在再126操作:
[root@www GNU-Linux-x86]# cat /etc/rsync.pass
123
[root@www GNU-Linux-x86]# chmod 600 /etc/rsync.pass
[root@www www]# ps axu | grep rsync 如果有运行过rsyncd,请删除(中午做了定时同步时,遗留下的进程)
root 8043 0.0 0.0 5252 480 ? Ss 11:08 0:00 rsync --daemon --config=/etc/rsyncd/rsyncd.conf
root 8668 0.0 0.0 5024 696 pts/3 S+ 11:46 0:00 grep rsync
[root@www www]# kill -9 8043
开始测试:
pwd
/opt/rsync/GNU-Linux-x86
./sersync2 -r #第一次执行记得加 -r
###################以下是成功信息提示:
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
use rsync password-file :
user is lewis
passwordfile is /etc/146rsync.pass
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
run the sersync:
watch path is: /opt/tongbu
#####################
现在可以在/opt/tongbu下建立文件,然后去127上查看根目录下的tongbu文件夹下是否有相同数据吧!
准备俩台实验机器,一台作为服务器server,一台作为client
server:192.168.18.126
client:192.168.18.127
如果想把126的数据实时同步到127:
sersync2监控------>126
rsync 服务端 ------>127
在126操作:
把sersync2工具上传到126
插件下载地址:http://download.csdn.net/detail/funk4/8125367
解压,并配置confxml.xml
<sersync>
<localpath watch="/opt/tongbu">
#126机器的同步数据文件夹路径
<remote ip="192.168.18.127" name="tongbu"/>#127机器同步数据文件名
<commonParams params="-artuz"/>
<auth start="true" users="lewis" passwordfile="/etc/rsync.pass"/>
在127操作:
1 install
yum install rsync
2
touch this directory
[root@www rsyncd]# pwd
/etc/rsyncd
[root@www rsyncd]# ls -l
-rw-r--r-- 1 root root 491 07-25 11:08 rsyncd.conf
-rw-r--r-- 1 root root 64 07-25 10:26 rsyncd.motd
-rw------- 1 root root 8 07-25 10:26 rsyncd.secrets
3 vim /etc/rsyncd/rsyncd.conf
uid=root
gid=root
port=873
max connections=0
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=yes
[cache]
path=/cache
list=yes
ignore errors
auth users=lewis#设置虚拟用户
secrets file=/etc/rsyncd/rsyncd.p#虚拟用户密码
read only=no
[root@www rsyncd]# cat rsyncd.motd #欢迎页面
#####################
welcome
#####################
[root@www rsyncd]# cat rsyncd.p
lewis:123
[root@www rsyncd]# chmod 600 rsyncd.p
4 start #启动
[root@www rsyncd]# rsync --daemon --config=/etc/rsyncd/rsyncd.conf
[root@www rsyncd]# lsof -i:873 #检查873端口
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
rsync 8043 root 4u IPv6 22013 TCP *:rsync (LISTEN)
rsync 8043 root 5u IPv4 22014 TCP *:rsync (LISTEN)
在再126操作:
[root@www GNU-Linux-x86]# cat /etc/rsync.pass
123
[root@www GNU-Linux-x86]# chmod 600 /etc/rsync.pass
[root@www www]# ps axu | grep rsync 如果有运行过rsyncd,请删除(中午做了定时同步时,遗留下的进程)
root 8043 0.0 0.0 5252 480 ? Ss 11:08 0:00 rsync --daemon --config=/etc/rsyncd/rsyncd.conf
root 8668 0.0 0.0 5024 696 pts/3 S+ 11:46 0:00 grep rsync
[root@www www]# kill -9 8043
开始测试:
pwd
/opt/rsync/GNU-Linux-x86
./sersync2 -r #第一次执行记得加 -r
###################以下是成功信息提示:
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
use rsync password-file :
user is lewis
passwordfile is /etc/146rsync.pass
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
run the sersync:
watch path is: /opt/tongbu
#####################
现在可以在/opt/tongbu下建立文件,然后去127上查看根目录下的tongbu文件夹下是否有相同数据吧!