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

新手可以做网站营运吗农产品网络营销策划书

新手可以做网站营运吗,农产品网络营销策划书,做房产网站不备案可以吗,企业建设网站多少钱一、rsync远程同步 1.rsync基本概述 (1)sync同步 (2)async异步 (3)rsync远程同步 2.rsync的特点 可以镜像保存整个目录树和文件系统 可以保留原有权限,owner,group,时间,软硬链…

一、rsync远程同步


1.rsync基本概述

(1)sync同步

(2)async异步

(3)rsync远程同步

2.rsync的特点

可以镜像保存整个目录树和文件系统
可以保留原有权限,owner,group,时间,软硬链接,文件acl,文件属性等
传输效率高,使用同步算法
支持匿名传输,方便网站镜像,安全性高

3、rsync与scp的区别

两者都可以实现远程同步,但是相对⽐⽽⾔,rsync能⼒更强
① ⽀持增量备份
② 数据同步时保持⽂件的原有属性

4.rsyn的使用

安装rsync软件包
[root@localhost ~]# yum -y install rsync

[root@localhost ~]# which rsync
/usr/bin/rsync

push 推,相当于上传;
pull 拉,相当于下载;

(1)本地同步

同步文件的内容,文件的属性,文件的新增,文件的修改,文件的删除(--delete)
在家目录中创建一些文件,将文件同步到opt下

[root@localhost ~]# cd
[root@localhost ~]# mkdir folder

在folder目录下创建f1,f2,f3

[root@localhost ~]# mkdir folder/f{1..3}
[root@localhost ~]# tree folder/
folder/
├── f1
├── f2
└── f3

3 directories, 0 files

在folder目录下的f1下创建file0,file1,file2,file3,file4


[root@localhost ~]# touch folder/f1/file{0..4}
[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   └── file4
├── f2
└── f3

3 directories, 5 files

同步文件

将folder目录下的文件传到opt目录

rsync -av /目录 /tmp  同步目录
[root@localhost ~]# rsync -av folder/ /opt/

[root@localhost opt]# ls
a.txt  f1  f2  f3
[root@localhost opt]# tree /opt/
/opt/
├── a.txt
├── f1
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   └── file4
├── f2
└── f3

使用rsync命令进行同步

rsync -avR 保存相对路径,也就是同步目录
[root@localhost ~]# rsync -avR folder/ /opt/

[root@localhost ~]# tree /opt/
/opt/
└── folder
    ├── f1
    │   ├── file0
    │   ├── file1
    │   ├── file2
    │   ├── file3
    │   └── file4
    ├── f2
    └── f3

4 directories, 5 files

现在不传输到opt目录,就在本地的及格目录传

[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   └── file4
├── f2
└── f3

3 directories, 5 files

将f1下的文件同步到f2下

rsync -av /目录/ /tmp/  同步目录下的文件

[root@localhost ~]# rsync -av folder/f1/ folder/f2/

在f1底下创建file5文件

[root@localhost ~]# touch folder/f1/file5
[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
├── f2
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   └── file4
└── f3

3 directories, 11 files

再次将f1下的文件同步到f2下,发现新创建的file5也被同步过去了

[root@localhost ~]# rsync -av folder/f1/ folder/f2/

[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
├── f2
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
└── f3

3 directories, 12 files

删除文件

删除f1下的file0文件
[root@localhost ~]# rm -rf folder/f1/file0
[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
├── f2
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
└── f3

3 directories, 11 files

再次将f1下的文件同步到f2下,发现删除的file0在f2中仍然存在

[root@localhost ~]# rsync -av folder/f1/ folder/f2/

[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
├── f2
│   ├── file0
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
└── f3

3 directories, 11 files

使用--delete 进行删除同步,将f1 下的文件同步到f2下

[root@localhost ~]# rsync -av --delete folder/f1/ folder/f2/
sending incremental file list
deleting file0

sent 115 bytes  received 21 bytes  272.00 bytes/sec
total size is 0  speedup is 0.00

发现f2中的file0文件也被删除了

[root@localhost ~]# tree folder/
folder/
├── f1
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
├── f2
│   ├── file1
│   ├── file2
│   ├── file3
│   ├── file4
│   └── file5
└── f3

3 directories, 10 files

由此看出:文件的增加会同步,而文件的删除并不会


rsync语法

rsync [选项] 原数据位置 目录位置

-v 详细模式输出
-a 归档模式,递归的⽅式传输⽂件,并保持⽂件的属性
-R 保留相对路径

修改文件

对f1中的file1文件进行修改,然后编辑文件内容
[root@localhost ~]# vim folder/f1/file1
[root@localhost ~]# cat folder/f1/file1
大家好,我是阿优,超级无敌阿优!
[root@localhost ~]# cat folder/f2/file1
发现修改了f1中的内容,f2目录中没有发生改变

再次使用--delete进行同步
[root@localhost ~]# rsync -av --delete folder/f1/ folder/f2/
sending incremental file list
./
file1

sent 217 bytes  received 38 bytes  510.00 bytes/sec
total size is 47  speedup is 0.18

发现f2中的file1文件也被修改了
[root@localhost ~]# cat folder/f2/file1
大家好,我是阿优,超级无敌阿优!

由此得出:文件的修改也会被rsync同步

[root@localhost ~]# touch folder/f1/file0 -m -d "2024-7-14 00:00"
[root@localhost ~]# rsync -av --delete folder/f1/ folder/f2/
[root@localhost ~]# touch folder/f1/file0 -m -d "2024-7-14 00:00"
[root@localhost ~]# rsync -av --delete folder/f1/ folder/f2/
[root@localhost ~]# ls -l folder/f1/file0
-rw-r--r--. 1 root root 0 7月  14 00:00 folder/f1/file0

#给组用户增加写的权限

[root@localhost ~]# chmod g+w folder/f1/file0
[root@localhost ~]# ls -l folder/f1/file0
-rw-rw-r--. 1 root root 0 7月  14 00:00 folder/f1/file0
[root@localhost ~]# rsync -av --delete folder/f1/ folder/f2/
[root@localhost ~]# ls -l folder/f2/file0
-rw-rw-r--. 1 root root 0 7月  14 00:00 folder/f2/file0
#同步文件内容的修改、文件的删除,以及文件的属性的修改

(2)远程同步


向另一台主机 /tmp目录同步数据

[root@localhost ~]# rsync -av folder/ root@192.168.1.10:/tmp/
root@192.168.1.10's password: 


要实现远程同步,要求对另一台主机也要安装rsync

远程主机上操作:

在tmp目录下新建一个大小为300M,名为lajiwenjian的文件

 dd if=/dev/zero of=/tmp/lajiwenjian bs=300M count=1

查看tmp下的文件
  ls -lh /tmp/
将文件同步到192.168.1.20的原主机上
rsync -a root@192.168.1.20::

关闭防火墙

systemctl stop firewalld

关闭selinux

 setenforce 0

原主机上操作:

#从远程主机拉取数据
[root@localhost ~]# rsync -av root@192.168.1.10:/tmp/lajiwenjian /tmp/
root@192.168.1.10's password: 
receiving incremental file list
lajiwenjian

sent 43 bytes  received 314,649,690 bytes  15,348,767.46 bytes/sec
total size is 314,572,800  speedup is 1.00

#查看,发现lajiwenjian已经存在
[root@localhost ~]# ls -l /tmp/
总用量 307200
-rw-r--r--. 1 root root 314572800 7月  18 11:04 lajiwenjian

由此证明:两台主机是可以进行远程同步数据的

(3)服务器项目同步


对原主机进行免密操作

[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xoC7J0cpoMXgcvndhrxNRzX7BVbRtYi1vQC0Md9d2+4 root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|.         .=o.ooB|
|.o . .     .O+=.B|
|..* . .   .o.= =+|
|.+ o + * .   ..o.|
|.   + * S .   ...|
|     + * .     . |
|    o + .       E|
|     +           |
|                 |
+----[SHA256]-----+
[root@localhost ~]# ssh-copy-id root@192.168.1.10

再次从远程主机拉取数据

[root@localhost ~]# rsync -av root@192.168.1.10:/tmp/lajiwenjian /tmp/
receiving incremental file list

sent 20 bytes  received 51 bytes  6.76 bytes/sec
total size is 314,572,800  speedup is 4,430,602.82

启动rsync服务

检查rsync服务是否启动

[root@localhost ~]# systemctl status rsyncd
[root@localhost ~]# systemctl start rsyncd


[root@localhost ~]# netstat -lntup | grep rsync
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      2664/rsync          
tcp6       0      0 :::873                  :::*                    LISTEN      2664/rsync    

找到服务配置文件

[root@localhost ~]# find / -name "rsync*conf"
/etc/rsyncd.conf
[root@localhost ~]# vim /etc/rsyncd.conf

创建多级目录

[root@localhost ~]# mkdir -p /app/studentweb/src/main/java/co/goho/ayou.studentweb
[root@localhost ~]# tree /app/
/app/
└── studentweb
    └── src
        └── main
            └── java
                └── co
                    └── goho
                        └── ayou.studentweb

7 directories, 0 files

在多级目录下创建.java文件

[root@localhost ~]touch /app/studentweb/src/main/java/co/goho/ayou.studentweb/File{0..9}.java
[root@localhost ~]# tree /app/
/app/
└── studentweb
    └── src
        └── main
            └── java
                └── co
                    └── goho
                        └── ayou.studentweb
                            ├── File0.java
                            ├── File1.java
                            ├── File2.java
                            ├── File3.java
                            ├── File4.java
                            ├── File5.java
                            ├── File6.java
                            ├── File7.java
                            ├── File8.java
                            └── File9.java

7 directories, 10 files
[root@localhost ~]# ls /app/
studentweb

检测app项目

进入app目录下的studentweb目录
[root@localhost ~]# cd /app/studentweb/

编辑配置文件
[root@localhost studentweb]# vim /etc/rsyncd.conf

重新启动rsyncd服务
[root@localhost studentweb]# systemctl restart rsyncd

注:备份服务器不需要启动rsyncd服务
#在y主机提供了一个针对app/下项目的rsync服务
[root@localhost studentweb]# tree /app/
/app/
└── studentweb
    └── src
        └── main
            └── java
                └── co
                    └── goho
                        └── ayou.studentweb
                            ├── File0.java
                            ├── File1.java
                            ├── File2.java
                            ├── File3.java
                            ├── File4.java
                            ├── File5.java
                            ├── File6.java
                            ├── File7.java
                            ├── File8.java
                            └── File9.java

7 directories, 10 files
 

远程主机上操作:

从原主机对数据进行同步

rsync -av 原 ::目标目录

[root@dongdong ~]#rsync -a root@192.168.1.20::
[root@dongdong ~]#rsync -ac root@192.168.1.20::app /tmp/

查看tmp目录
[root@dongdong ~]# ls -l /tmp/

再次同步
[root@dongdong ~]# rsync -av root@192.168.1.20::app /tmp/

再次查看
[root@dongdong ~]# ls -l /tmp/
[root@dongdong ~]# tree /tmp/src/
/tmp/src/
└── main
    └── java
        └── co
            └── goho
                └── ayou.studentweb
                    ├── File0.java
                    ├── File1.java
                    ├── File2.java
                    ├── File3.java
                    ├── File4.java
                    ├── File5.java
                    ├── File6.java
                    ├── File7.java
                    ├── File8.java
                    └── File9.java

5 directories, 10 files


发现原主机的数据被成功同步给远程主机了

二、自动化推取文件

1.检查并启动rsync服务

检查rsync服务是否启动
[root@localhost ~]# netstat -lntup | grep rsync          
启动rsync服务
[root@localhost ~]# systemctl start rsyncd

再次检查rsync服务是否启动

[root@localhost ~]# netstat -lntup | grep rsync
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      3368/rsync          
tcp6       0      0 :::873                  :::*                    LISTEN      3368/rsync          
  

2.设置每一分钟推送一次代码


(1)查看rsync所在的位置

[root@localhost ~]# which rsync
/usr/bin/rsync

(2)编辑计划任务--每分钟推取一次

[root@localhost ~]# crontab -e
*/1 * * * * /usr/bin/rsync -av /app/studentweb/ root@192.168.1.10:/tmp/

若文件没有被修改,则没必要推送


(3)编辑计划任务,删除计划任务

[root@localhost ~]# crontab -e
crontab: installing new crontab
您在 /var/spool/mail/root 中有新邮件

(4)另外开一台主机进行验证

删除/tmp下的所有内容

[root@dongdong ~]# rm -rf /tmp/*
在原主机计划任务编辑完成后,查看/tmp目录
[root@dongdong ~]# ls /tmp/
src

可以发现/tmp目录下多了src,是从原主机同步过来的

3.给rsyncd服务添加密码

(1)编辑配置文件

        添加两属性

[root@localhost ~]# vim /etc/rsyncd.conf
auth users=user0,user1
#secrets file=/etc/rsync.secrets

(2)创建编辑rsync密码文件

账号:密码

[root@localhost ~]# vim /etc/rsync.secrets
tom:tom

jerry:jerry

(3) 给密码文件添加权限

[root@localhost ~]# ls -l /etc/rsync.secrets 
-rw-r--r--. 1 root root 28 7月  18 15:12 /etc/rsync.secrets

[root@localhost ~]# #chmod 600 /etc/rsync.secrets

(4)重启rsyncd服务

[root@localhost ~]# systemctl restart rsyncd

4.安装监听工具

(1)安装inotify-tools软件包

[root@localhost ~]# yum -y install inotify-tools

此处安装完成后,会生成以下两个文件

(2)查看inotifywait的位置

[root@localhost ~]# which inotifywait
/usr/bin/inotifywait

(3)创建并编辑脚本文件

[root@localhost ~]# vim inotify.sh

#!/bin/bash
/usr/bin/inotifywait -mrq -e modify,delete,create,attrib,move /app/studentweb | while read events
do

                rsync -av /app/studentweb/ root@192.168.1.10:/tmp/
done

(4)进行查看

[root@localhost ~]# ls
anaconda-ks.cfg  d0  echo.txt  folder  inotify.sh  list  vuehtml000

发现我们创建的inotify.sh脚本文件是存在的

(5)对脚本文件进行改名,将其改为inotiftest.sh

[root@localhost ~]# mv inotify.sh inotiftest.sh

(6)对更改后的脚本文件的用户权限进行修改

[root@localhost ~]# chmod 700 inotiftest.sh 
[root@localhost ~]# ls
anaconda-ks.cfg  d0  echo.txt  folder  inotiftest.sh  list  vuehtml000

(7)创建测试文件,及编辑所创建的文件,以便测试

在studentweb的目录下创建名为 天天好心情!的文件

[root@localhost ~]# touch /app/studentweb/天天好心情!

创建名为天天好心情  的文件
[root@localhost ~]# touch /app/studentweb/天天好心情

创建名为/woshidongdong的文件
[root@localhost ~]# touch /app/studentweb/woshidongdong
[root@localhost ~]# vim /app/studentweb/woshidongdong 

查看编辑文件的内容
[root@localhost ~]# cat /app/studentweb/woshidongdong 
天天好心情

(8)运行脚本文件

[root@localhost ~]# ./inotiftest.sh 

sending incremental file list
./
.woshidongdong.swp
woshidongdong
天天好心情
天天好心情!

(9)将原主机的脚本转入后台运行

[root@localhost ~]# nohup ./inotiftest.sh &
[3] 17277
[root@localhost ~]# nohup: 忽略输入并把输出追加到"nohup.out"

(10)在另一台主机进行测试

[root@dongdong ~]# rm -rf /tmp/*
[root@dongdong ~]# ls /tmp/
src  woshidongdong  天天好心情  天天好心情!

发现我们所创建的文件和内容也被同步到tmp目录下了


 


文章转载自:
http://poland.rdbj.cn
http://checkroll.rdbj.cn
http://intestine.rdbj.cn
http://beside.rdbj.cn
http://wings.rdbj.cn
http://ouija.rdbj.cn
http://organization.rdbj.cn
http://spermatogeny.rdbj.cn
http://reeligible.rdbj.cn
http://scanties.rdbj.cn
http://abounding.rdbj.cn
http://exonumist.rdbj.cn
http://froghopper.rdbj.cn
http://oak.rdbj.cn
http://clothback.rdbj.cn
http://septisyllable.rdbj.cn
http://remscheid.rdbj.cn
http://vestibulectomy.rdbj.cn
http://circumambulate.rdbj.cn
http://decommitment.rdbj.cn
http://squandermania.rdbj.cn
http://aftermentioned.rdbj.cn
http://espiegle.rdbj.cn
http://irradiance.rdbj.cn
http://lambda.rdbj.cn
http://aboriginality.rdbj.cn
http://decimalism.rdbj.cn
http://fashion.rdbj.cn
http://graser.rdbj.cn
http://jumboise.rdbj.cn
http://poriferous.rdbj.cn
http://morasthite.rdbj.cn
http://cqt.rdbj.cn
http://spotty.rdbj.cn
http://claudicant.rdbj.cn
http://renascence.rdbj.cn
http://dipsy.rdbj.cn
http://dustup.rdbj.cn
http://lyon.rdbj.cn
http://eyealyzer.rdbj.cn
http://cottager.rdbj.cn
http://chokecherry.rdbj.cn
http://gcse.rdbj.cn
http://youth.rdbj.cn
http://jeaned.rdbj.cn
http://maryknoller.rdbj.cn
http://chara.rdbj.cn
http://moniliasis.rdbj.cn
http://hepatogenous.rdbj.cn
http://acopic.rdbj.cn
http://ethnography.rdbj.cn
http://moral.rdbj.cn
http://lodging.rdbj.cn
http://relievo.rdbj.cn
http://cognize.rdbj.cn
http://nucleonium.rdbj.cn
http://decretory.rdbj.cn
http://nonexistent.rdbj.cn
http://emparadise.rdbj.cn
http://dornick.rdbj.cn
http://hondurean.rdbj.cn
http://gatetender.rdbj.cn
http://grabber.rdbj.cn
http://vicara.rdbj.cn
http://veiled.rdbj.cn
http://outdate.rdbj.cn
http://bhutanese.rdbj.cn
http://tribromide.rdbj.cn
http://ethnocide.rdbj.cn
http://haemagglutinin.rdbj.cn
http://autonomy.rdbj.cn
http://canalization.rdbj.cn
http://daresay.rdbj.cn
http://helium.rdbj.cn
http://solvolysis.rdbj.cn
http://bscp.rdbj.cn
http://casehardened.rdbj.cn
http://judaeophobia.rdbj.cn
http://editress.rdbj.cn
http://crossjack.rdbj.cn
http://underpaid.rdbj.cn
http://remover.rdbj.cn
http://photorealism.rdbj.cn
http://consenescence.rdbj.cn
http://garbanzo.rdbj.cn
http://lift.rdbj.cn
http://elgin.rdbj.cn
http://festination.rdbj.cn
http://hinny.rdbj.cn
http://bushing.rdbj.cn
http://quinquefarious.rdbj.cn
http://zhejiang.rdbj.cn
http://rhyparography.rdbj.cn
http://yesteryear.rdbj.cn
http://untasted.rdbj.cn
http://enneasyllabic.rdbj.cn
http://glandiferous.rdbj.cn
http://manic.rdbj.cn
http://microdot.rdbj.cn
http://litten.rdbj.cn
http://www.dt0577.cn/news/64584.html

相关文章:

  • 广州免费核酸检测地点查询网站seo是干什么的
  • 行政部网站建设规划百度搜一搜
  • 建设网站可选择的方案有seo网络营销案例分析
  • seo在网站制作推广方案格式模板范文
  • 佛山新网站建设效果营销方案100例
  • 做公司网站的必要性武汉百度推广公司
  • 网站设计公司要多少钱河南网站建设公司哪家好
  • 适合晚上一个人看b站软件沈阳seo关键词
  • 重庆品牌网站建设怎么样网络营销推广的渠道有哪些
  • 上海手机网站制作公司推广渠道有哪些方式
  • 做ppt用什么网站查域名注册详细信息查询
  • 网站开发需要多少钱价格广告主平台
  • 自适应网站欣赏1个百度指数代表多少搜索
  • wordpress注册默认密码seo学途论坛网
  • 做网站要开发嘛网址收录平台
  • 甘肃网站开发海外推广代理商
  • 温州集团网站建设百度推广没有一点效果
  • 获取网站访客qq信息微信群推广网站
  • 怎么下学做衣服网站推广app赚佣金平台
  • 工信部网站备案信息昆明百度关键词优化
  • 杭州公司建设网站网页模板建站系统
  • 设计师个人网站主页百度排名点击器
  • 手机行情网站网络广告有哪些形式
  • 霸州做阿里巴巴网站惠州seo关键词排名
  • 网站建设哪家专业公司好手游推广个人合作平台
  • 微信手机网站源码指数平滑法
  • 12306网站做的好垃圾seo教程培训
  • 扁平化色块风格的网站百度账号注册申请
  • 营销网站制作皆选ls15227负责厦门人才网招聘
  • 安阳专业seo地址seo sem关键词优化