两台安装yum -y install rsync 测试备份/var/lib/kubelet目录(此方法为两目录一定时间同步,建议使用脚本定期复制到nfs,可参考之前文章 k8s的备份与还原里面的手动备份。)
a 1 cat /etc/rsyncd.conf
pid file=/var/run/rsyncd.pid
port=873
address=10.194.28.104
uid=root
gid=root
read only=yes
hosts allow=10.194.28.110
hosts deny=*
max connections = 5
motd file = /etc/rsyncd.motd
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[kubelet] #此处注意使用的名称
path = /var/lib/kubelet
list=no
ignore errors
auth users = root
secrets file = /etc/rsyncd.secrets
comment = This is kubelet
a 2 #cat /etc/rsyncd.secrets
root:password #备份的密码(不必与本机root相同)
#chmod 600 /etc/rsyncd.secrets #權限必須為600
#cat /etc/rsyncd.motd
test-test #内容随意写
# /usr/bin/rsync --daemon /etc/rsyncd.conf 启动
#iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT #开通防火墙或者关闭
b 1 目标服务器
#cat /etc/rsyncd.secrets
password #与设置的备份密码一致
#chmod 600 /etc/rsyncd.secrets #修改600
b 2测试
rsync -azvP --delete --password-file=/etc/rsyncd.secrets root@10.194.28.104::kubelet /test/kubelet
设置 crontab -e 定时每天0点同步
0 0 * * * rsync -azvP --delete --password-file=/etc/rsyncd.secrets root@10.194.28.104::kubelet /test/kubelet