加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux开启 Sersync 守护进程进行数据同步

发布时间:2020-12-13 23:29:59 所属栏目:Linux 来源:网络整理
导读:a 、配置 Sersync 环境变量 ? [[email?protected] sersync]# echo ‘export PATH=$PATH:/usr/local/sersync/bin‘/etc/profile ? [[email?protected] sersync]# tail -1 /etc/profile export PATH=$PATH:/usr/local/sersync/bin [[email?protected] sersync]

a、配置 Sersync 环境变量

?

[[email?protected] sersync]# echo ‘export PATH=$PATH:/usr/local/sersync/bin‘>>/etc/profile

?

[[email?protected] sersync]# tail -1 /etc/profile export PATH=$PATH:/usr/local/sersync/bin [[email?protected] sersync]# . /etc/profile [[email?protected] sersync]# which sersync

?

?

启动的过程及结果:

?

注意:我们这里要启动的是多实例,即 confxml.xml 和 download_confxml.xml

?

[[email?protected] ~]# ls /usr/local/sersync/conf/*

?

/usr/local/sersync/conf/confxml.xml

?

/usr/local/sersync/conf/confxml.xml.bak.2014-06-04

?

/usr/local/sersync/conf/download_confxml.xml

?

?

[[email?protected] ~]# sersync -r -d -o /usr/local/sersync/conf/confxml.xml

?

?

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

?

?

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

?

?

option: -d run as a daemon

?

?

option: -o config xml name: /usr/local/sersync/conf/confxml.xml

?

?

daemon thread num: 10

?

?

parse xml config file

?

?

host ip : localhosthost port: 8008

?

?

daemon start,sersync run behind the? console

?

?

use rsync password-file :

?

?

user isrsync_bak

?

passwordfile is /etc/rsync.password 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 thr eads)

Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)

?

?

chmod: cannot access `/usr/local/logs/rsync_fail_log.sh‘: No such file or directory

?

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

?

rsync the directory recursivly to the remote servers once working please wait...

execute command: cd /data/web && rsync -aruz -R --delete ./ --timeout=100 rsync_bak

?

@172.16.100.1::web --password-file=/etc/rsync.password >/dev/null 2>&1

?

?

run the sersync:

?

?

watch path is: /data/web

?

?

[[email?protected] ~]# sersync -r -d -o /usr/local/sersync/conf/download_confxml.xml

?

?

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

?

?

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

?

?

option: -d run as a daemon

?

?

option: -o config xml name: /usr/local/sersync/conf/download_confxml.xml

?

?

daemon thread num: 10

?

?

parse xml config file

?

?

host ip : localhosthost port: 8008

?

?

daemon start,sersync run behind the console

?

use rsync password-file :

?

user isrsync_bak

?

passwordfile is /etc/rsync.password config xml parse success

please set /etc/rsyncd.conf max connections=0 Manually

?

?

eads)

?

Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)

?

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

?

chmod: cannot access `/usr/local/logs/rsync_fail_log.sh‘: No such file or directory

?

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

?

rsync the directory recursivly to the remote servers once

?

?

working please wait...

?

?

execute command: cd /data/download && rsync -aruz -R --delete ./ --timeout=100 rsync

?

?

[email?protected]::download --password-file=/etc/rsync.password >/dev/null 2>&1

?

?

run the sersync:

?

?

watch path is: /data/download

?

b、开启后查看进程

?

?

[[email?protected] ~]# ps -ef |grep sersync

?

?

root????? 2114???? 1 0 01:56 ???????? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/confxml.

?

?

xml

?

?

root????? 2223???? 1 0 02:03 ???????? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/downloa

?

?

d_confxml.xml

?

?

root????? 2295 2244 0 02:08 pts/2??? 00:00:00 grep sersync

?

?

C、配置开机自启动

?

?

[[email?protected] ~]# cp /etc/rc.local /etc/rc.local.bak._$(date +%F)

?

[[email?protected] ~]# cat >>/etc/rc.local<< ‘EOF‘

?

> # sync data to 172.16.100.1,172.16.100.2

?

> sersync -d -o /usr/local/sersync/conf/confxml.xml

?

> sersync -d -o /usr/local/sersync/conf/download_confxml.xml

?

> EOF

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读