网站分为几种,网络 网站,百度的广告策略,柳城网站制作准备工作检查selinux 防火墙
#关闭 selinux
sed -i s/^SELINUX.*/SELINUXdisabled/ /etc/selinux/config
#关闭防火墙
systemctl stop firewalld;systemctl disable firewalld1.安装nfs相关包
# 所有节点安装nfs相关包
yum install nfs-utils -y
systemctl enable nfs-utils …准备工作检查selinux 防火墙
#关闭 selinux
sed -i s/^SELINUX.*/SELINUXdisabled/ /etc/selinux/config
#关闭防火墙
systemctl stop firewalld;systemctl disable firewalld1.安装nfs相关包
# 所有节点安装nfs相关包
yum install nfs-utils -y
systemctl enable nfs-utils --now2.主节点启动nfs服务
systemctl enable nfs-server.service --now3.主节点创建目录并共享
# 创建nfs共享目录
mkdir /data
echo /data *(rw,sync,insecure,no_subtree_check,no_root_squash) /etc/exports# 重启nfs服务
systemctl restart nfs-server.service# 在其他节点showmount测试
showmount -e 172.25.47.18
Export list for xxx.xxx.xxx.xxx:
/data *#其他节点测试挂载
mkdir /haha
mount -t nfs 主节点IP地址:/data /haha
umount /haha4.从节点创建目录
mkdir /data5.配置 rsync
此文档使用以下IP和目录举例使用时请根据实际情况进行更换
主节点172.16.164.14
从节点172.16.164.15
同步目录 /datayum install rsync -yvi /etc/rsyncd.conf从节点执行
uid root
gid root
use chroot yes
max connections 200
log file/var/log/rsyncd.log
pid file /var/run/rsyncd.pid
lock file/var/run/rsyncd.lock
exclude lostfound/
transfer logging yes
timeout 600
ignore nonreadable yes
dont compress *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2[data]
path /data
auth users rsync
secrets file /etc/rsync_salve.pass
hosts allow 172.16.164.14
read only no6.配置认证文件
从节点执行
格式为用户:用户密码
echo rsync:password /etc/rsync_salve.pass
chmod 600 /etc/rsync_salve.pass主节点执行
这里写入从节点配置的密码
echo password /etc/rsync.pass
chmod 600 /etc/rsync.pass7.目录授权
主节点和从节点执行
chown -R root:root /data8.启动服务
从节点执行
systemctl enable rsyncd.service
systemctl start rsyncd.service9.同步测试
主节点执行
rsync -arv /data/ rsync172.16.164.15::data --password-file/etc/rsync.pass#如果想在目标目录中删除那些在源目录中不存在的文件可使用
#rsync -avz --progress --delete /data/ rsync172.16.164.15::data --password-file/etc/rsync.pass10.使用 sersync2 配置自动同步(主节点执行)
10.1 安装 sersync2
#下载
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
#解压
tar -zxvf sersync*_64bit_binary_stable_final.tar.gz mv GNU-Linux-x86/ /usr/local/sersync cd /usr/local/sersync10.2 修改配置文件
注意更换下面的IP地址哦(改为从节点的)
sed -ri 24s#localpath watch/opt/tongbu#localpath watch/data#g confxml.xmlsed -ri 25s#remote ip127.0.0.1 nametongbu1/#remote ip172.16.164.15 namedata/#g confxml.xmlsed -ri 31s#auth startfalse usersroot passwordfile/etc/rsync.pas/#auth starttrue usersrsync passwordfile/etc/rsync.pass/#g confxml.xmlsed -ri 33s#timeout startfalse time100/!-- timeout100 --#timeout starttrue time100/!-- timeout100 --#g confxml.xml10.3 启动
将 sersync2 纳入 system管理
cat /etc/systemd/system/sersync2.service EOF
[Unit]
DescriptionSersync2 Service
Afternetwork.target[Service]
RemainAfterExityes
ExecStart/usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
ExecStop/usr/bin/pkill sersync2
ExecReload/usr/bin/pkill sersync2 /usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
Restarton-abnormal[Install]
WantedBymulti-user.target
EOF启动 sersync2
systemctl daemon-reload
systemctl enable sersync2
systemctl start sersync211.测试主从是否同步
#主节点执行
echo 123 /data/test.tt#从节点执行
cat /data/test.txt
#如果看到结果是123即表示成功搭建了NFS主从