渭南商铺网站建设社区电商app定制开发多少钱

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

渭南商铺网站建设,社区电商app定制开发多少钱,什么是软文写作,做类似淘宝的网站开发需要什么rsync ( Remote sync#xff0c;远程同步) 是一个开源的快速备份工具#xff0c;可以在不同主机之间镜像同步整个目录树#xff0c;支持增量备份#xff0c;并保持链接和权限#xff0c;且采用优化的同步算法#xff0c;传输前执行压缩#xff0c;因此非常适用于异地备…rsync ( Remote sync远程同步) 是一个开源的快速备份工具可以在不同主机之间镜像同步整个目录树支持增量备份并保持链接和权限且采用优化的同步算法传输前执行压缩因此非常适用于异地备份、镜像服务器等应用。 在远程同步任务中负责发起rsync同步操作的客户机称为发起端而负责响应来自客户机的rsync同步操作的服务器称为同步源。在同步过程中同步源负责提供文件的原始位置发起端应对该位置具有读取权限。 Rsync是Linux系统下的数据镜像备份工具使用快速增量备份工具Remote sync 可以远程同步可以在不同主机之间进行同步可实现全量备份与增量备份保持链接和权限且采用优化的同步算法传输前执行压缩因此非常适合用于架构集中式备份或异地备份等应用。同时Rsync支持本地复制或者与其他SSH、 rsync主机同步。 Rsync官方网站https://rsync.samba.org/ 同步方式 (1完整备份:每次备份都是从备份源将所有的文件或目录备份到目的地。 (2差量备份:备份上次完全备份以后有变化的数据他针对的上次的完全备份他备份过程中不清除存档属性。 (3增量备份:备份上次备份以后有变化的数据他才不管是那种类型的备份有变化的数据就备份他会清除存档属性) 同步过程 选项 含义 -r 递归模式包含目录及子目录中的所有文件 -l 对于符号链接文件仍然复制为符号链接文件 -v 显示同步过程的详细(verbose信息 -z 在传输文件时进行压缩( compress ) -a 归档模式保留文件的权限、属性等信息等同于组合选项-r lptgoD -p 保留文件的权限标记 -t 保留文件的时间标记 -g 保留文件的属组标记(仅超级用户使用 -o 保留文件的属主标记(仅超级用户使用) -H 保留硬连接文件 -A 保留ACL属性信息 -D 保留设备文件及其他特殊文件 -delete 删除目标位置有而原始位置没有的文件 -checksum 根据校验和而不是文件天小、修改时间来决定是否跳过文件 实验操作 主机 备注 192.168.32.129 客户端发起端 192.168.32.130 服务端同步源 客户端192.168.32.129[rootlocalhost ~]# systemctl stop firewalld.service setenforce 0 [rootlocalhost ~]# cd /opt/ [rootlocalhost opt]# ls [rootlocalhost opt]# rpm -q rsync 若没有rsync则yum安装 [rootlocalhost opt]# yum install -y rsync [rootlocalhost opt]# rpm -q rsync rsync-3.1.2-12.el7_9.x86_64 [rootlocalhost opt]# cd /home/ [rootlocalhost home]# ls [rootlocalhost home]# mkdir -p /home/student echo this is school /home/student/1.txt [rootlocalhost home]# ls /home/student/1.txt /home/student/1.txt [rootlocalhost home]# cat /home/student/1.txt this is school 同步/home/student/下的文件到/opt/ [rootlocalhost home]# rsync -avz /home/student/ /opt/ sending incremental file list ./ 1.txtsent 121 bytes received 38 bytes 318.00 bytes/sec total size is 15 speedup is 0.09 [rootlocalhost home]# cd /opt/ [rootlocalhost opt]# ls

  1. txt [rootlocalhost opt]# mkdir student [rootlocalhost opt]# ls

  2. txt student服务端192.168.32.130 [rootlocalhost ~]# systemctl stop firewalld.service setenforce 0 [rootlocalhost opt]# yum install -y rsync [rootlocalhost opt]# rpm -q rsync rsync-3.1.2-12.el7_9.x86_64[rootlocalhost opt]# rpm -qc rsync /etc/rsyncd.conf /etc/sysconfig/rsyncd### 备份好方便回滚 [rootlocalhost ~]# cp /etc/rsyncd.conf /etc/rsyncd.conf_bak

    配置

    [rootlocalhost ~]# vim /etc/rsyncd.conf [rootlocalhost ~]# mkdir -p /var/www/html [rootlocalhost ~]# ls -ld /var/www/html drwxr-xr-x. 2 root root 6 12月 11 10:54 /var/www/html [rootlocalhost ~]# chmod r /var/www/html/ [rootlocalhost ~]# vim /etc/rsyncd_users.db##给个权限只有自己的用户访问别的用户访问不了 [rootlocalhost ~]# cat /etc/rsyncd_users.db zhangsan:123456## 重新加载rsync [rootlocalhost ~]# rsync –daemon [rootlocalhost ~]# netstat -antp|grep rsync tcp 0 0 192.168.32.130:873 0.0.0.0:* LISTEN 59812/rsync [rootlocalhost ~]# cd /var/www/html [rootlocalhost html]# cp /etc/passwd /etc/shadow ./## 拷贝文件到当前的目录中 [rootlocalhost html]# ls passwd shadow [rootlocalhost html]### myhtml是/etc/rsyncd.conf 配置文件下指定的参数目录 下载服务端备份源中的数据使用配置源的第二种方式进行备份 rsync -avz zhangsan192.168.32.130::myhtml /opt/ 客户端192.168.32.129 [rootlocalhost opt]# rsync -avz zhangsan192.168.32.130::myhtml /opt/ Password: receiving incremental file list shadowsent 46 bytes received 374 bytes 120.00 bytes/sec total size is 1,361 speedup is 3.24## 拷贝文件到当前的目录中 [rootlocalhost opt]# ls 1.txt passwd shadow student 增量数据备份 服务端192.168.32.130## 修改192.168.32.130配置文件下的password ,新增一行表示增量数据 [rootlocalhost html]# vim /var/www/html/passwd 客户端192.168.32.129

    此时服务端的数据已经变动了更新了里面修改过后的文件密码为123456上面服务端中的创建的密码[rootlocalhost ~]# rsync -avz zhangsan192.168.32.130::myhtml /opt/student/

    Password: receiving incremental file list ./ passwd shadowsent 65 bytes received 768 bytes 238.00 bytes/sec total size is 1,395 speedup is 1.67[rootlocalhost opt]# vim /opt/student/passwd

    可以看到文件已经和服务端修改过的一样的了 配置免交互密码

    客户端192.168.32.129 [rootlocalhost opt]# echo 123456 /etc/server.pass [rootlocalhost opt]# chmod 600 /etc/server.pass服务端192.168.32.130

    由于本地没有此文件需要先自行创建一个文件数据里面的数据可以随便输入

    [rootlocalhost html]# vim /etc/yum.repos.d/local.repo## 把创建好的数据拷贝进html目录中 [rootlocalhost html]# cp /etc/yum.repos.d/local.repo /var/www/html/

    备份源中已有新增的数据 客户端192.168.32.129

    [rootlocalhost opt]# rsync -avz –password-file/etc/server.pass zhangsan192.168.32.130::myhtml /opt/student/

    此时免交互密码设置成功可直接下载文件 可以看到客户端已经有同步新增数据文件了

    使用inotify工具进行实时同步(上传数据) 发起端客户端配置rsyncinotify 使用inotify通知接口可以用来监控文什系统的各种变化情况如文件存取、删除、移动、修改等。利用这一机制可以非常方便地实现文件异动告警、增量备份并针对目录或文件的变化及时作出响应。 将inotify机制与rsync工具相结合可以实现触发式备份实时同步)即只要原始位置的文档发生变化则立即启动增量备份操作;否则处于静默等待状态。这样就避免了按固定周期备份时存在的延迟性、周期过密等问题。 因为 inotify 通知机制出 Linux 内核提供因此主要做木机监控在触发式备份中应用时更适合上行同步。
    服务端192.168.32.130 [rootlocalhost html]# vim /etc/rsyncd.conf [rootlocalhost html]# cat /var/run/rsyncd.pid 59812

    杀掉进程

    [rootlocalhost html]# kill $(cat /var/run/rsyncd.pid) [rootlocalhost html]# netstat -antp|grep rsync [rootlocalhost html]# rsync –daemon [rootlocalhost html]# netstat -antp|grep rsync tcp 0 0 192.168.32.130:873 0.0.0.0:* LISTEN 77936/rsync
    [rootlocalhost html]# chmod 777 /var/www/html/ [rootlocalhost html]# ls /var/www/html/ local.repo passwd shadow客户端192.168.32.129## inotify 的默认内核参数 [rootlocalhost opt]# cat /proc/sys/fs/inotify/max_queued_events 16384## 每个用户所能创建的Inotify实例的上限 [rootlocalhost opt]# cat /proc/sys/fs/inotify/max_user_instances 128## 每个inotify实例相关联的watches的上限即每个inotify实例可监控的最大目录、文件数量 [rootlocalhost opt]# cat /proc/sys/fs/inotify/max_user_watches 8192 [rootlocalhost opt]# vim /etc/sysctl.conf [rootlocalhost opt]# sysctl -p fs.inotify.max_queued_events 16384 fs.inotify.max_user_instances 1024 fs.inotify.max_user_watches 1048576把 inotify-tools-3.14.tar.gz 放入进 opt 目录中下载地址https://sourceforge.net/projects/inotify-tools/files/inotify-tools-3.14.tar.gz/download ## 安装依赖包 [rootlocalhost opt]# yum install -y gcc gcc-c make [rootlocalhost opt]# tar -zxvf inotify-tools-3.13.tar.gz [rootlocalhost opt]# cd inotify-tools-3.13 [rootlocalhost inotify-tools-3.13]# ./configure make make install使用命令进行监控inotifywait -mrq -e modify,create,move,delete
    选项 含义 -e 用来指定要监控哪些事件 -m 表示持续监控 -r 表示递归整个目录 -q 简化输出信息 客户端192.168.32.129

    表示持续监控/opt/student/目录下的事件

    [rootlocalhost opt]# inotifywait -mrq -e modify,create,move,delete /opt/student/## 另开一个客户端192.168.32.129窗口模拟删除操作 [rootlocalhost ~]# cd /opt/student/ [rootlocalhost student]# ls local.repo passwd shadow [rootlocalhost student]# rm -rf passwd

    查看实时监控窗口时间输出

    日志实时记录打印删除事件 使用Shell脚本进行实时监控

    监控端在什么地方脚本也要放在相同地方[rootlocalhost opt]# vim inotify.sh

    –password-file/etc/server.pass 指定密码文件

    zhangsan192.168.32.130 指定用户在/etc/rsyncd.conf配置文件

    /opt/student/ 客户端要同步给远程服务端的目录

    myhtml 远程服务端要同步的目录[rootlocalhost opt]# cat inotify.sh

    #!/bin/bash INOTIFY_CMDinotifywait -mrq -e modify,create,move,delete /opt/student/ RSYNC_CMDsudo rsync -arvH –delete –password-file/etc/server.pass /opt/student/ zhangsan192.168.32.130::myhtml

    使用while、read持续获取监控结果根据结果可以作进一步判断是否读取到输出的监控记录

    $INOTIFY_CMD | while read DIRECTORY EVENT FILE

    while判断是否接收到监控记录

    doif [ \((pgrep rsync | wc -l) -le 0 ] ; then#如果rsync未在执行则立即启动 sudo \)RSYNC_CMDfi done[rootlocalhost opt]# chmod x /opt/inotify.sh [rootlocalhost opt]# chmod 777 /opt/student/ [rootlocalhost opt]# chmod x /etc/rc.d/rc.local [rootlocalhost opt]# echo /opt/inotify.sh /etc/rc.d/rc.local [rootlocalhost opt]# cat /etc/rc.d/rc.local #!/bin/bash

    THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

    #

    It is highly advisable to create own systemd services or udev rules

    to run scripts during boot instead of using this file.

    #

    In contrast to previous versions due to parallel execution during boot

    this script will NOT be run after all other services.

    #

    Please note that you must run chmod x /etc/rc.d/rc.local to ensure

    that this script will be executed during boot.touch /var/lock/subsys/local

    /opt/inotify.sh## 启动脚本 [rootlocalhost opt]# sh /opt/inotify.sh ## 测试

    复制文件到监控/opt/student/目录下

    [rootlocalhost student]# cp /etc/yum.repos.d/* /opt/student/

    可以看到脚本实时记录输出日志## 查看客户端192.168.32.129/opt/student/ ## 查看监控脚本inotify.sh输出日志## 查看远程同步目录服务端192.168.32.130备份同步目录是否自动同步## 可以看到已经触发inotify.sh脚本自动同步了生产环境同步实验fastdfs

    环境 客户端172.16.153.201数据源目录 服务端172.16.153.202远程同步目录 客户端172.16.153.201数据源目录 [root201-app storage]# systemctl stop firewalld.service setenforce 0 [root201-app storage]# rpm -q rsync rsync-3.0.9-18.el7.x86_64 若没有rsync则yum安装 [rootlocalhost opt]# yum install -y rsync [root201-app storage]# rpm -q rsync rsync-3.0.9-18.el7.x86_64

    以上都有则正常

    服务端172.16.153.202远程同步目录 [root202-app data]# systemctl stop firewalld.service setenforce 0 [root202-app data]# rpm -q rsync rsync-3.0.9-18.el7.x86_64 若没有rsync则yum安装 [rootlocalhost opt]# yum install -y rsync [root202-app data]# rpm -q rsync rsync-3.0.9-18.el7.x86_64

    以上都有则正常[root202-app data]# rpm -qc rsync

    /etc/rsyncd.conf /etc/sysconfig/rsyncd### 备份好方便回滚 [root202-app data]# cp /etc/rsyncd.conf /etc/rsyncd.conf_bak

    配置

    [root202-app data]# vim /etc/rsyncd.conf [root202-app data]# mkdir -p /var/www/html [root202-app data]# ls -ld /var/www/html drwxr-xr-x. 2 root root 6 12月 12 11:00 /var/www/html [root202-app data]# chmod r /var/www/html/ [root202-app data]# vim /etc/rsyncd_users.db ##给个权限只有自己的用户访问别的用户访问不了 [rootlocalhost ~]# cat /etc/rsyncd_users.db zhangsan:123456

    给/etc/rsyncd_users.db 密码配置文件授权

    [root202-app html]# chmod 600 /etc/rsyncd_users.db [root202-app data]# kill $(cat /var/run/rsyncd.pid) [root202-app data]# rsync –daemon [root202-app data]# netstat -antp|grep rsync tcp 0 0 172.16.153.202:873 0.0.0.0:* LISTEN 9566/rsync## 服务端rsync服务正常启动完成 客户端配置免交互密码172.16.153.201 [root201-app storage]# echo 123456 /etc/server.pass [root201-app storage]# chmod 600 /etc/server.pass

    客户端先测试下免密同步是否成功 ## 客户端172.16.153.201

    启动客户端rsync 服务

    [root201-app data]# rsync –daemon [root201-app data]# netstat -antp|grep rsync tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 17240/rsync
    tcp6 0 0 :::873 :::* LISTEN 17240/rsync ## 测试 [root201-app data]# rsync -avz –password-file/etc/server.pass zhangsan172.16.153.202::myhtml /data/ 使用inotify工具进行实时同步(上传数据) 发起端客户端配置rsyncinotify 使用inotify通知接口可以用来监控文什系统的各种变化情况如文件存取、删除、移动、修改等。利用这一机制可以非常方便地实现文件异动告警、增量备份并针对目录或文件的变化及时作出响应。 将inotify机制与rsync工具相结合可以实现触发式备份实时同步)即只要原始位置的文档发生变化则立即启动增量备份操作;否则处于静默等待状态。这样就避免了按固定周期备份时存在的延迟性、周期过密等问题。 因为 inotify 通知机制出 Linux 内核提供因此主要做木机监控在触发式备份中应用时更适合上行同步。
    服务端172.16.153.202 [root202-app html]# vim /etc/rsyncd.conf

    修改此处为no [root202-app html]# kill $(cat /var/run/rsyncd.pid)

    [root202-app html]# netstat -antp|grep rsync [root202-app html]# rsync –daemon [root202-app html]# netstat -antp|grep rsync tcp 0 0 172.16.153.202:873 0.0.0.0:* LISTEN 22135/rsync
    [root202-app html]# chmod 777 /var/www/html/ [root202-app html]# ls /var/www/html/ 111 a.txt test 客户端172.16.153.201## inotify 的默认内核参数 [root201-app data]# cat /proc/sys/fs/inotify/max_queued_events 16384## 每个用户所能创建的Inotify实例的上限 [root201-app data]# cat /proc/sys/fs/inotify/max_user_instances 1024## 每个inotify实例相关联的watches的上限即每个inotify实例可监控的最大目录、文件数量 [root201-app data]# cat /proc/sys/fs/inotify/max_user_watches 1048576[root201-app data]# vim /etc/sysctl.conf fs.inotify.max_queued_events 16384 fs.inotify.max_user_instances 1024 fs.inotify.max_user_watches 1048576 [root201-app data]# sysctl -p客户端安装inotify-tools-3.14.tar.gz [root201-app data]# yum install -y gcc gcc-c make [root201-app data]# tar -zxvf inotify-tools-3.13.tar.gz [root201-app data]# cd inotify-tools-3.13 [root201-app inotify-tools-3.13]# ./configure make make install 使用命令进行监控inotifywait -mrq -e modify,create,move,delete 选项 含义 -e 用来指定要监控哪些事件 -m 表示持续监控 -r 表示递归整个目录 -q 简化输出信息 客户端172.16.153.201

    表示持续监控/data/目录下的事件

    [root201-app inotify-tools-3.13]# inotifywait -mrq -e modify,create,move,delete /data/

    有日志输出就可以了 客户端使用Shell脚本进行实时监控

    客户端172.16.153.201

    监控端在什么地方脚本也要放在相同地方

    [root201-app data]# vim inotify.sh #!/bin/bash INOTIFY_CMDinotifywait -mrq -e modify,create,move,delete /data/ RSYNC_CMDsudo rsync -arvH –password-file/etc/server.pass /data/ zhangsan172.16.153.202::myhtml

    使用while、read持续获取监控结果根据结果可以作进一步判断是否读取到输出的监控记录

    $INOTIFY_CMD | while read DIRECTORY EVENT FILE

    while判断是否接收到监控记录

    dosudo $RSYNC_CMD done[root201-app data]# chmod x /data/inotify.sh [root201-app data]# chmod -R 777 /data/ [root201-app data]# chmod x /etc/rc.d/rc.local [root201-app data]# echo /data/inotify.sh /etc/rc.d/rc.local 客户端:172.16.153.201服务端172.16.153.202 实验成功## 附件同步脚本#!/bin/bash INOTIFY_CMDinotifywait -mrq -e modify,create,move,delete /home/fastdfs/storage/ RSYNC_CMDsudo rsync -arvH –delete –password-file/etc/server.pass /home/fastdfs/storage/ zhangsan172.16.153.202::myhtml

    使用while、read持续获取监控结果根据结果可以作进一步判断是否读取到输出的监控记录

    $INOTIFY_CMD | while read DIRECTORY EVENT FILE

    while判断是否接收到监控记录

    dosudo $RSYNC_CMD done