rsync mirror centos centos镜像下载官网
老铁们,大家好,相信还有很多朋友对于rsync mirror centos和centos镜像下载官网的相关问题不太懂,没关系,今天就由我来为大家分享分享rsync mirror centos以及centos镜像下载官网的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!
创建本地CentOS 7镜像和Epel镜像的方法
本文旨在介绍创建本地CentOS 6/CentOS 7镜像的实用技巧。对于拥有众多系统且希望减少带宽消耗、确保软件包安装和网络更新稳定的用户来说,这一方法尤为适用。本文将展示如何使用rsync同步上游镜像,并将同步内容保存在/home/mirrors/路径下,请确保该路径指向一个有足够空间的文件系统,或者安装新的磁盘/分区。
1、同步yum源
使用vim编辑器打开/home/mirrors/centos.sh文件:
vim/home/mirrors/centos.sh
在文件中加入以下基于bash的脚本内容:
运行centos.sh脚本,服务器将自动完成同步。
同样,编辑/home/mirror/epel.sh文件:
vim/home/mirror/epel.sh
在文件中加入以下内容:
运行epel.sh脚本,自动完成同步。
2、建立web服务
同步完成后,可以使用nginx来开始使用这些镜像。
安装nginx:
yum-y install epel-release
yum-y install nginx
修改nginx配置文件:vi/etc/nginx/nginx.conf
修改以下标黄内容:
启动并启用nginx:
systemctl start nginx
systemctl enable nginx
3、客户端配置
配置CentOS Server以使用镜像:
CentOS Base镜像:
cd/etc/yum.repos.d/
mkdir old
mv CentOS* old
使用vim编辑器创建centos_local.repo文件:
vim centos_local.repo
在文件中加入以下内容:
同样,创建epel_local.repo文件,并添加相应内容:
通过更新repo缓存来测试repos是否正常工作:
yum clean all
yum makecache fast
yum-v repolist
4,使用光盘的内容
使用vim编辑器打开cdrom.repo文件:
vim cdrom.repo
大神教你:Lsyncd复制并实时同步到远程服务器
Lsyncd监视本地目录树事件监视器接口(inotify或fsevents)。它聚合并将事件组合在一起几秒钟,然后生成一个(或多个)进程来同步这些更改。默认情况下,由rsync实现同步。因此,Lsyncd是一种轻量级的实时镜像解决方案,相对容易安装,不需要新的文件系统或块设备,也不会妨碍本地文件系统的性能。
Rsync+ssh是一种高级操作配置,它使用ssh来执行文件和目录直接在目标上移动,而不是在线路上重新传输移动目标。细粒度的定制可以通过配置文件实现。自定义动作configs甚至可以从头编写,从shell脚本到Lua语言编写的代码。这种方法简单,强大,灵活的配置可以被解决。
Lsyncd 2.2.2要求在所有源和目标机器上rsync= 3.1。
系统环境:
RenwoleServer:10.28.204.65服务端
RenwoleClient:10.28.204.66客户端
OS:CentOS Linux release 7.4.1708(Core) x64
rsync的安装
请参阅:《CentOS7 Configuring Rsync Server》。
安装扩展依赖包
$ yum install-y gcc gcc-c++ lua lua-devel cmake libxml2 libxml2-devel
源代码编译安装lsyncd
$ wget $ tar xvf release-2.2.2.tar.gz$ cd lsyncd-release-2.2.2$ cmake-DCMAKE_INSTALL_PREFIX=/usr/local/lsyncd$ make amp;amp; make install$ ln-s/usr/local/lsyncd/bin/lsyncd/usr/bin/lsyncd安装过程可能报错:-- Configuring incomplete, errors occurred!
安装lua-devel即可。
设置无密码SSH登录
因为这里使用rsyncssh进行同步,所以还需要配置root账号无密码ssh登录。详细配置请参阅:
《如何在Linux中设置SSH无密码登录》
配置lsyncd
以下是三种常用配置案例
1.远程同步rsyncssh模式配置方案:
$ vim/etc/lsyncd.confsettings{ logfile=/var/log/lsyncd.log,
--日志路径 statusFile=/var/log/lsyncd.status,--状态文件 pidfile=/var/run/lsyncd.pid,
--pid文件路径 statusInterval= 1,
--状态文件写入最短时间 nodaemon= false,
--daemon运行 maxProcesses= 1,
--最大进程 maxDelays= 1,
--最大延迟}sync{ default.rsyncssh,--默认rsync+ssh,rsync版本需要升级3以上版本 source=/apps/www/renwoleblog/,
--源目录 delete= true,
--保持完全同步
host= root@10.28.204.66,
targetdir=/apps/www/renwoleblog/bak/,--目标目录 exclude={
.txt
--需排除的文件},rsync={ binary=/usr/bin/rsync,--需先安装好rsync archive= true,
--归档 compress= false,
--压缩 owner= true,
--属主 perms= true,
--权限 whole_file= false},ssh={ port= 22}}
2.本地目录同步配置方案:
sync{ default.rsync, source=/apps/www/renwoleblog/, target=/apps/www/renwoleblog/bak/,}
3.远程同步rsync-daemon模式配置方案
sync{ default.rsync, source=/apps/www/renwoleblog/, target= renwole@10.28.204.65::renwolecom, delete=true, exclude={.bak*}, delay= 30, init= false, rsync={ binary=/usr/bin/rsync, archive= true, compress= true, verbose= true, perms= true, password_file=/etc/rsync.password, _extra={--bwlimit=200}}}
重点参数说明:
--
#注释符settings#是全局配置sync#定义同步参数rsync#定义同步文件参数ssh
#定义服务器远程端口
lsyncd配置文件允许多个sync互不影响。
说明:如果是一对多,请参阅本地同步,修改目标目录即可。
创建systemctl系统单元文件
为了实现systemctl进行管理,请创建配置文件以及脚本启动文件,命令如下:
$ vim/etc/sysconfig/lsyncd添加如下内容:LSYNCD_OPTIONS=/etc/lsyncd.conf创建启动文件:$ vim/usr/lib/systemd/system/lsyncd.service添加如下内容:[Unit]Description=Live Syncing(Mirror) DaemonAfter=network.target[Service]Type=simpleEnvironmentFile=-/etc/sysconfig/lsyncdExecStart=/usr/local/lsyncd/bin/lsyncd-nodaemon$LSYNCD_OPTIONS[Install]WantedBy=multi-user.target
启动lsyncd并加入开机自启动
$ systemctl start lsyncd$ systemctl enable lsyncd接下来你就可以往源服务器/apps/www/renwoleblog/内上传任意文件,完成后立刻就会同步到客户端 10.28.204.66/apps/www/renwoleblog/bak/目录内,也可以查看服务端的lsyncd日志文件分析是否同步成功。例如:[root@RenwoleServer~]$ cat/var/log/lsyncd.log...Fri Dec 22 01:19:22 2017 Normal: Calling rsync with filter-list of new/modified files/dirs/PCHunter_renwole.com.tar.gz/Fri Dec 22 01:19:24 2017 Normal: Finished(list): 0Fri Dec 22 01:19:32 2017 Normal: Calling rsync with filter-list of new/modified files/dirs/PCHunter_renwole.com.tar.gz/Fri Dec 22 01:19:34 2017 Normal: Finished(list): 0Fri Dec 22 01:19:34 2017 Normal: Calling rsync with filter-list of new/modified files/dirs/PCHunter_renwole.com.tar.gz/Fri Dec 22 01:19:36 2017 Normal: Finished(list): 0
日志内容显示PCHunter_renwole.com.rar文件成功同步。
另外lsyncd是基于inotify+ rsync的开源同步软件,相对于其他同步软件更加安全可靠,占用资源更少,但配置略麻烦。
lsyncd还支持当监控到某个指定事件时就执行什么样的命令,由于是通过时间延迟和累计事件命中次数来触发同步,在设计上要优于inotify,另外他的同步速度完全取决于你的网络质量。