sersync同步

本文介绍了如何搭建可道云网盘,并通过sersync实现与NFS和Rsync服务器的同步。详细步骤包括web服务器环境配置、NFS环境搭建和Rsync环境搭建。在NFS服务器故障时,可通过切换到Rsync的数据节点确保服务连续性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

搭建可道云网盘并同步
  1. web服务器搭建环境(IP:172.16.1.7)
#搭建rsync环境
yun install rsync -y	#安装rsync
mkdir /data
groupadd -g666 www
useradd -u666 -g666 wwww
chown www.www /data 

#搭建可道云环境
yum install httpd php -y #安装HTTP和PHP
sed -i '/^User/c User www' /etc/httpd/conf/httpd.conf	#修改HTTP的用户为www
sed -i '/^Group/c Group www' /etc/httpd/conf/httpd.conf	#修改HTTP的组为www
cd /var/www/html/
chown -R www.www /var/www/html
wget http://static.kodcloud.com/update/download/kodexplorer4.40.zip	#下载可道云
unzip kodexplorer4.40.zip
systemctl start httpd
systemctl enable httpd
yum install php-mbstring php-gd -y	#多数会报错,缺少这两个库文件

#将可道云的本地文件推到NFS服务器
cd /var/www/html/data/User/admin/home/
scp -rp * root@172.16.1.31:/data

#将可道云的存储节点挂载为NFS的节点
mount -t nfs 172.16.1.31:/data /var/www/html/data/User/admin/home/
  1. NFS环境搭建(IP:172.16.1.31)
#搭建rsync环境
yum install rsync -y	#安装rsync
groupadd -g666 www
useradd -u666 -g666 www
mkdir /backup /data
vim /etc/rsyncd.conf
------------------/etc/rsyncd.conf------------------------
uid = www                        # 运行进程的用户
gid = www                      # 运行进程的用户组
port = 873                       # 监听端口
fake super = yes                 # 不需要rsync已root身份运行,就可以存储文件的完整属性
use chroot = no                  # 禁锢推送的数据至某个目录, 不允许跳出该目录
max connections = 200            # 最大连接数
timeout = 600                    # 超时时间
ignore errors                    # 忽略错误信息
read only = false                # 对备份数据可读写
list = false                     # 不允许查看模块信息
auth users = rsync_backup        # 定义虚拟用户,作为连接认证用户
secrets file = /etc/rsync.passwd # 定义rsync服务用户连接认证密码文件路径

[backup]                # 定义模块信息
comment = commit        # 模块注释信息
path = /backup          # 定义接收备份数据目录

[data]
path = /data
------------------/etc/rsyncd.conf结束---------------------
vim /etc/rsync.passwd
-------------------/etc/rsync.passwd-----------------------------
rsync_backup:123456
------------------/etc/rsync.passwd结束---------------------------
chmod 600 /etc/rsync.passwd
chown -R www.www /backup
chown -R www.www /data
systemctl start rsyncd
systemctl enable rsyncd

# NFS环境搭建
yum install nfs-utils -y	#安装NFS
vim /etc/exports
--------------------------/etc/exports----------------------------------
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
--------------------------/etc/exports结束-------------------------------
systemctl srat nfs
systemctl enable nfs

#搭建sersync同步到Rsync的/data
wget https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz
tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86/ /usr/local/serync
vim /usr/local/serync/confsml.xml
---------------------/usr/local/serync/confsml.xml------------------------
<host hostip="localhost" port="8008"></host>
    <debug start="false"/>
    <fileSystem xfs="false"/>
    <filter start="false">
	<exclude expression="(.*)\.svn"></exclude>
	<exclude expression="(.*)\.gz"></exclude>
	<exclude expression="^info/*"></exclude>
	<exclude expression="^static/*"></exclude>
    </filter>
    <inotify>
	<delete start="true"/>
	<createFolder start="true"/>
	<createFile start="true"/>
	<closeWrite start="true"/>
	<moveFrom start="true"/>
	<moveTo start="true"/>
	<attrib start="true"/>
	<modify start="true"/>
    </inotify>
    <sersync>
	<localpath watch="/data">
	    <remote ip="172.16.1.41" name="data"/>
	    <!--<remote ip="192.168.8.39" name="tongbu"/>-->
	    <!--<remote ip="192.168.8.40" name="tongbu"/>-->
	</localpath>
	<rsync>
	    <commonParams params="-avz"/>
	    <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.pass"/>
	    <userDefinedPort start="false" port="874"/><!-- port=874 -->
	    <timeout start="false" time="100"/><!-- timeout=100 -->
	    <ssh start="false"/>
	</rsync>
	<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
	<crontab start="false" schedule="600"><!--600mins-->
	    <crontabfilter start="false">
		<exclude expression="*.php"></exclude>
		<exclude expression="info/*"></exclude>
	    </crontabfilter>
	</crontab>
	<plugin start="false" name="command"/>
    </sersync>

<plugin name="command">
	<param prefix="/bin/sh" suffix="" ignoreError="true"/>	<!--prefix /opt/tongbu/mmm.sh suffix-->
	<filter start="false">
	    <include expression="(.*)\.php"/>
	    <include expression="(.*)\.sh"/>
	</filter>
    </plugin>

    <plugin name="socket">
	<localpath watch="/opt/tongbu">
	    <deshost ip="192.168.138.20" port="8009"/>
	</localpath>
    </plugin>
    <plugin name="refreshCDN">
	<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
	    <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
	    <sendurl base="http://pic.xoyo.com/cms"/>
	    <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
	</localpath>
    </plugin>
</head>
---------------------/usr/local/serync/confsml.xml结束---------------------
/usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml	#开始同步
  1. Rsync环境搭建(IP:172.16.1.41)
#搭建Rsync环境
yum install rsync -y	#安装rsync
groupadd -g666 www
useradd -u666 -g 666 www
mkdir /data /backup
chown -R www.www /data
chown -R www.www /backup
vim /etc/rsyncd.conf
---------------------------/etc/rsyncd.conf--------------------------------
uid = www                        # 运行进程的用户
gid = www                      # 运行进程的用户组
port = 873                       # 监听端口
fake super = yes                 # 不需要rsync已root身份运行,就可以存储文件的完整属性
use chroot = no                  # 禁锢推送的数据至某个目录, 不允许跳出该目录
max connections = 200            # 最大连接数
timeout = 600                    # 超时时间
ignore errors                    # 忽略错误信息
read only = false                # 对备份数据可读写
list = false                     # 不允许查看模块信息
auth users = rsync_backup        # 定义虚拟用户,作为连接认证用户
secrets file = /etc/rsync.passwd # 定义rsync服务用户连接认证密码文件路径

[backup]                # 定义模块信息
comment = commit        # 模块注释信息
path = /backup          # 定义接收备份数据目录

[data]
path = /data
---------------------------/etc/rsyncd.conf结束-----------------------------
vim /etc/rsync.passwd
---------------------------/etc/rsync.passwd-------------------------------
rsync_backup:123456
---------------------------/etc/rsync.passwd结束----------------------------
chmod 600 /etc/rsync.passwd	#改变密码文件的权限
systemctl start rsyncd
systemctl enable rsyncd

#搭建NFS环境
yum install nfs-utils -y
vim /etc/exports
---------------------------/etc/exports----------------------------------
/data 172.16.1.0/24(rw,all_squash,anonuid=666,anongid=666)
---------------------------/etc/exports结束-------------------------------
systemctl start nfs
systemctl enable nfs
  1. 当NFS服务器出现问题时,可以将web的可道云节点改为Rsync的/data节点
umount /var/www/html/data/User/admin/home/	#取消挂载
mount -t nfs 172.16.1.41:/data /var/www/html/data/User/admin/home/
#当有时卸载成功,但挂载不成功时
mount	#查看当前挂载文件(最后可以找到我们挂载的目录)
umount -lf /var/www/html/data/User/admin/home	#强制卸载
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值