当前位置: 首页 > wzjs >正文

工厂 电商网站建设上海全网推广

工厂 电商网站建设,上海全网推广,qq推广怎么做,中国企业信息网官方网站目录 一、rsync部署 push推数据 1、编写rsync配置文件 2、备份测试 3、检验结果 二、rsyncsersync 实现数据实时同步 1、安装sersync服务 2、检验结果 pull拉取数据 1、编写rsync配置文件 2、检验结果 三、脚本编写 1、客户端脚本编写 2、服务器脚本编写 一、rsy…

目录

一、rsync部署

push推数据

1、编写rsync配置文件

2、备份测试

3、检验结果

二、rsync+sersync 实现数据实时同步

1、安装sersync服务

2、检验结果

pull拉取数据

1、编写rsync配置文件

2、检验结果

三、脚本编写

1、客户端脚本编写

2、服务器脚本编写


一、rsync部署

  • 服务器:source 192.168.58.130 (进行数据备份的主机)

  • 客户端:targetpc 192.168.58.131 (备份存储的主机)

push推数据

1、编写rsync配置文件

#192.168.58.131
# 在客户端上编写rsync配置文件,创建一个存放备份的同步目录
[root@targetpc ~]# vim /etc/rsyncd.conf 
# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
# [ftp]
#        path = /home/ftp
#        comment = ftp export area
​
​
#在这些内容后面加上下面的内容
#加上
port=873
address = 192.168.58.131
uid = root
gid = root
use chroot = yes
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /etc/rsyncd.motd
hosts allow = 192.168.58.0/24
[data]
path = /data/backup
comment = bakcup data
read only = false
list = yes
auth users = rsyncuser
secrets file = /etc/rsync.passwd
#192.168.58.131
# 创建密码文件,格式   用户名:密码
# 设置密码文件权限为600或者700
[root@targetpc ~]# touch /etc/rsync.passwd
[root@targetpc ~]# vim /etc/rsync.passwd 
rsyncuser:123456
[root@targetpc ~]# chmod 600 /etc/rsync.passwd
#192.168.58.131
# 创建欢迎信息文件
[root@targetpc ~]# echo "Welcome to Backup Server" > /etc/rsyncd.motd
​
[root@targetpc ~]# systemctl start rsyncd
[root@targetpc ~]# mkdir -p /data/backup
[root@targetpc ~]# cd /data/backup

2、备份测试

#192.168.58.130
[root@source ~]# mkdir /data
[root@source ~]# cd /data
[root@source data]# touch 1.txt
[root@source data]# mkdir aaa
[root@source data]# rsync -avz /data/* rsyncuser@192.168.58.131::data
Welcome to Backup Server
​
Password: 
sending incremental file list
1.txt
aaa/
​
sent 124 bytes  received 43 bytes  9.03 bytes/sec
total size is 0  speedup is 0.00
[root@source data]# touch 2.txt
[root@source data]# ls
1.txt  2.txt  aaa
[root@source data]# rsync -avz /data/* rsyncuser@192.168.58.131::data
Welcome to Backup Server
​
Password: 
sending incremental file list
2.txt
​
sent 137 bytes  received 36 bytes  9.89 bytes/sec
total size is 0  speedup is 0.00

3、检验结果

#192.168.58.131
[root@targetpc backup]# ls
1.txt  2.txt  aaa
​
​
[root@targetpc backup]# touch 3.txt
[root@targetpc backup]# ls
1.txt  2.txt  3.txt  aaa

#192.168.58.130
[root@source data]# rsync -avz --delete /data/ rsyncuser@192.168.58.131::data
Welcome to Backup Server
​
Password: 
sending incremental file list
deleting 3.txt
​
sent 125 bytes  received 22 bytes  8.91 bytes/sec
total size is 0  speedup is 0.00

#192.168.58.131
[root@targetpc backup]# ls
1.txt  2.txt  aaa

非交互式:

如果想不输入密码,可以使用--password-file参数指定密码

#192.168.58.130
[root@source data]# vim /etc/rsync.passwd
123456
[root@source data]# chmod 600 /etc/rsync.passwd
[root@source data]#  rsync -avz --delete /data/ rsyncuser@192.168.58.131::data --password-file=/etc/rsync.passwd
Welcome to Backup Server
​
sending incremental file list
deleting data/aaa/
deleting data/2.txt
deleting data/1.txt
deleting data/
./
​
sent 132 bytes  received 70 bytes  13.93 bytes/sec
total size is 0  speedup is 0.00

#192.168.58.131
[root@targetpc backup]# ls
1.txt  2.txt  aaa

二、rsync+sersync 实现数据实时同步

1、安装sersync服务

#192.168.58.130
[root@source data]# cd
[root@source ~]# rz
rz waiting to receive.**[root@source ~]# ls
anaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  init.sh  sersync2.5.4_64bit_binary_stable_final.tar.gz  shell
​
[root@source ~]# ls
anaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  init.sh  sersync2.5.4_64bit_binary_stable_final.tar.gz  shell
[root@source ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz 
[root@source ~]# ls
anaconda-ks.cfg                  GNU-Linux-x86  sersync2.5.4_64bit_binary_stable_final.tar.gz
ceph-release-1-1.el7.noarch.rpm  init.sh        shell
[root@source ~]# cd GNU-Linux-x86/
[root@source GNU-Linux-x86]# ls
confxml.xml  sersync2
[root@source GNU-Linux-x86]# vim confxml.xml 
<inotify><delete start="true"/><createFolder start="true"/><createFile start="false"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="false"/><modify start="false"/></inotify><sersync><localpath watch="/opt/tongbu"><remote ip="127.0.0.1" name="tongbu1"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-artuz"/><auth start="false" users="root" passwordfile="/etc/rsync.pas"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync>
<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="192.168.58.131" name="data"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-artuz"/><auth start="true" users="rsyncuser" passwordfile="/etc/rsync.passwd"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync>
#192.168.58.130
# 开启sersync守护进程同步数据,即实时同步。
# -r参数,先做一次完全同步,再做差异同步。
[root@source GNU-Linux-x86]# ./sersync2 -d -r -o ./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: -d      run as a daemon
option: -r      rsync all the local files to the remote servers before the sersync work
option: -o      config xml name:  ./confxml.xml
daemon thread num: 10
parse xml config file 
host ip : localhost     host port: 8008
will ignore the inotify createFile event 
daemon start,sersync run behind the console 
use rsync password-file :
user is rsyncuser
passwordfile is         /etc/rsync.passwd
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
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /data && rsync -artuz -R --delete ./ rsyncuser@192.168.58.131::data --password-file=/etc/rsync.passwd >/dev/null 2>&1
​
#或者
[root@source GNU-Linux-x86]# nohup ./sersync2 -r -o ./confxml.xml &
[1] 117240

2、检验结果

#192.168.58.130
#更改名称,查看变化
[root@source data]# mv aaa AAA
root@source data]# ls
1.txt  2.txt  AAA
#192.168.58.131
#检测到名称已变
[root@targetpc backup]# ls
1.txt  2.txt  AAA

pull拉取数据

以上的同步过程都是服务端主动推送数据给目标主机(服务器),这里演示下目标主机主动拉取数据进行同步。

1、编写rsync配置文件

#192.168.58.130
[root@source ~]# vim /etc/rsyncd.conf
#在这个文件里加入下面内容#
ort=873
address = 192.168.58.130
uid = root
gid = root
use chroot = yes
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /etc/rsyncd.motd
hosts allow = 192.168.58.0/24
[data]
path = /data
comment = master data
read only = false
list = yes
auth users = rsyncuser
secrets file = /etc/rsync.passwd
​
# 认证文件
[root@source ~]# vim /etc/rsync.passwd
rsyncuser:123456
# 服务端上启动rsync
[root@source ~]# systemctl start rsyncd
[root@source ~]# netstat -antup | grep 873
tcp        0      0 192.168.58.130:873      0.0.0.0:*               LISTEN      15646/rsync     
# 看到以上结果,说明服务端的rsync服务已经配置完成。
# 开放873端口号,允许通过873端口号拉取数据
[root@source ~]# cd /data
[root@source data]# mkdir BBB
[root@source data]# ls
1.txt  2.txt  AAA  BBB

2、检验结果

#192.168.58.131
# 目标主机上拉取数据
[root@targetpc backup]#  rsync -avz rsyncuser@192.168.58.130::data /data/backup/
​
Password: 
receiving incremental file list
./
BBB/
​
sent 32 bytes  received 145 bytes  9.57 bytes/sec
total size is 0  speedup is 0.00
[root@targetpc backup]# ls
1.txt  2.txt  AAA  BBB

三、脚本编写

计划将服务器的/data目录的文件实时发送到客户端/data/backup目录中,操作前请检查服务器是否有该目录

1、客户端脚本编写

#!/bin/bash
#客户端配置
#编写rsync配置文件
read -p "请输入符合此掩码的当前主机IP(默认掩码为255.255.255.0):" ip
ip1=$(echo $ip | awk -F. '{print $1"."$2"."$3}')
echo "
port=873
address = $ip
uid = root
gid = root
use chroot = yes
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /etc/rsyncd.motd
hosts allow = $ip1.0/24
[data]
path = /data/backup
comment = bakcup data
read only = false
list = yes
auth users = rsyncuser
secrets file = /etc/rsync.passwd
" > /etc/rsyncd.conf
touch /etc/rsync.passwd
echo "rsyncuser:123456" > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd
echo "Welcome to Backup Server" > /etc/rsyncd.motd
systemctl restart rsyncd
mkdir -p /data/backup

2、服务器脚本编写

#!/bin/bash
#服务端配置
read -p "请输入符合此掩码的客户端主机IP(默认掩码为255.255.255.0):" ip
echo "123456" > /etc/rsync.passwd
chmod 600 /etc/rsync.passwd
rsync -avz --delete /data/ rsyncuser@$ip::data --password-file=/etc/rsync.passwd

看到感觉有帮助的朋友,劳烦动动发财的小手给博主点个赞

http://www.dtcms.com/wzjs/458014.html

相关文章:

  • 菏泽做网站的贵阳网站优化公司
  • 做网站在哪里买空间域名慧生活798app下载
  • 怎么对网站做超链接测试外链发布工具
  • 免费网站建站软件长沙seo优化首选
  • 专业建网站平台小红书seo排名规则
  • 天津最好的网站建设百度广告点击软件源码
  • 长沙培训网站建设网络推广和网站推广
  • 有专门做网站的公司网上广告怎么推广
  • 网站建设与运营公司财务预算四川百度推广排名查询
  • dreamweaver网站怎么做百度极速版app下载安装挣钱
  • 做爰网站贴吧百度上如何发广告
  • 学校电脑课做网站的软件win10优化大师怎么样
  • 比较好用的网站安卓优化大师app下载
  • 北京网站外包公司2345网址导航浏览器
  • 为您打造高端品牌网站如何做好网络营销?
  • 东莞网站优化科技有限公司国外网站加速
  • 网站开发和运行 法律百度客服在线咨询人工服务
  • 网站流量指标高粱seo博客
  • 网站开发站点的文件夹抖音推广平台联系方式
  • 怎样制作h5页面广州专业seo公司
  • 电子商务网站规划书百度文库官网
  • 没效果seo常用分析的专业工具
  • 公司网站备案需要每年做吗计算机培训
  • 武汉教育网站建设优化百度竞价的优势和劣势
  • 用css div做网站的首页我想做网络推广找谁
  • 做网站和彩票的同步开奖怎么做广州网络营销产品代理
  • 邢台高端网站建设适合seo的网站
  • gateface能用来做网站吗新闻媒体发布平台
  • 湖南省网站今日的最新消息
  • wordpress 表单 excel新区seo整站优化公司