说明:
操作系统:CentOS 6.x
主机名:yum.base.com
IP 地址:192.168.27.233(生产区服务器)
实现目的:由于生产区服务器无法上外网,为了方便生产区安装软件,同步 yum 镜像站点的内容到此服务器,向生产区提供 yum服务。
RSYNC 代理上网:
[root@yum ~]# vim /etc/profile
export RSYNC_PROXY="repo.base.com:3128"
[root@yum ~]# source /etc/profile
准备篇:
一、安装 HTTP 服务
这里使用 NGINX 提供 HTTP 服务。
NGINX 的安装
[root@yum ~]# cd /opt/nginx-1.12.1
[root@yum nginx-1.12.1]# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
[root@yum nginx-1.12.1]# make
[root@yum nginx-1.12.1]# make install
二、系统约定
NGINX 系统根目录:/opt/yum_data/
三、开启 NGINX 目录浏览功能
[root@yum conf]# vim nginx.conf
user root;
server {
listen 80;
server_name yum.base.bjebc.com;
#charset koi8-r;
#access_log logs/host.access.log main;
root /opt/yum_data;
location / {
autoindex on; #<--开启nginx目录浏览功能
autoindex_exact_size off; #<--文件大小从KB开始显示
autoindex_localtime on; #<--显示文件修改时间为服务器本地时间
}
}
[root@yum ~]# cd /usr/local/nginx/sbin/
[root@yum sbin]# nginx
安装篇:
一、创建镜像文件存放目录
[root@yum ~]# mkdir /opt/yum_data/centos/6/{extras,os,updates}/x86_64 -p
[root@yum ~]# mkdir /opt/yum_data/centos/7/{extras,os,updates}/x86_64 -p
[root@yum ~]# mkdir /opt/yum_data/epel/{6,7}/x86_64/ -p
[root@yum ~]# mkdir /opt/yum_data/repoforge/rhel/el{6,7}/en/x86_64/{extras,rpmforge}/RPMS/ -p
[root@yum ~]# mkdir /opt/yum_data/remi/6/remi/x86_64/ -p
[root@yum ~]# mkdir /opt/yum_data/elasticstack/elastic-{5.x,6.x}/ -p
[root@yum ~]# mkdir /opt/yum_data/foreman/{plugins,releases}/1.12/el6/x86_64/ -p
[root@yum ~]# mkdir /opt/yum_data/nginx/{6,7}/x86_64/RPMS/ -p
[root@yum ~]# mkdir /opt/yum_data/zabbix/ -p
[root@yum ~]# mkdir /opt/yum_data/puppet/el/{6,7}/{dependencies,devel,products}/{i386,x86_64} -p
[root@yum ~]# mkdir /opt/yum_data/puppet/puppet/el/{6,7}/x86_64 -p
[root@yum ~]# mkdir /opt/yum_data/puppet/puppet/el/6/i386 -p
[root@yum opt]# tree -L 3 yum_data/centos/
yum_data/centos/
├── 6
│ ├── extras
│ │ └── x86_64
│ ├── os
│ │ └── x86_64
│ └── updates
│ └── x86_64
└── 7
├── extras
│ └── x86_64
├── os
│ └── x86_64
└── updates
└── x86_64
[root@yum opt]# tree -L 3 yum_data/epel/
yum_data/epel/
├── 6
│ └── x86_64
│ ├── drpms
│ ├── epel-release-6-8.noarch.rpm
│ ├── Packages
│ └── repodata
└── 7
└── x86_64
├── drpms
├── Packages
└── repodata
10 directories, 1 file
[root@yum opt]# tree -L 3 yum_data/remi/
yum_data/remi/
└── 6
├── foo
├── php54
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── php55
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── php56
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── php70
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── php71
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── php72
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── remi
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
├── safe
│ ├── httpsmirror
│ ├── mirror
│ └── x86_64
└── x86_64
├── foo
├── php54
├── php55
├── php56
├── php70
├── php71
├── php72
├── remi
└── safe
26 directories, 18 files
[root@yum opt]# tree -L 4 yum_data/repoforge/
yum_data/repoforge/
└── rhel
├── el6
│ └── en
│ └── x86_64
└── el7
└── en
└── x86_64
7 directories, 0 files
[root@yum opt]# tree -L 3 yum_data/nginx/
yum_data/nginx/
├── 6
│ └── x86_64
│ ├── repodata
│ └── RPMS
└── 7
└── x86_64
├── repodata
└── RPMS
[root@yum opt]# tree -L 4 yum_data/foreman/
yum_data/foreman/
├── plugins
│ └── 1.12
│ └── el6
│ └── x86_64
└── releases
└── 1.12
└── el6
└── x86_64
8 directories, 0 files
[root@yum opt]# tree -L 2 yum_data/zabbix/
yum_data/zabbix/
├── non-supported
│ └── rhel
├── RPM-GPG-KEY-ZABBIX -> RPM-GPG-KEY-ZABBIX-79EA5ED4
├── RPM-GPG-KEY-ZABBIX-79EA5ED4
├── RPM-GPG-KEY-ZABBIX-A14FE591
├── RPM-GPG-KEY-ZABBIX-A14FE591-EL5
├── zabbix
│ ├── 1.8
│ ├── 2.0
│ ├── 2.2
│ ├── 2.4
│ ├── 2.5
│ ├── 3.0
│ ├── 3.1
│ ├── 3.2
│ ├── 3.4
│ └── 3.5
└── zabbix-official-repo.key
13 directories, 5 files
[root@yum opt]# tree -L 2 yum_data/elasticstack/
yum_data/elasticstack/
├── elastic-5.x
│ ├── 5.0.0
│ ├── 5.0.1
│ ├── 5.0.2
│ ├── 5.1.1
│ ├── 5.1.2
│ ├── 5.2.0
│ ├── 5.2.1
│ ├── 5.2.2
│ ├── 5.3.0
│ ├── 5.3.1
│ ├── 5.3.2
│ ├── 5.3.3
│ ├── 5.4.0
│ ├── 5.4.1
│ ├── 5.4.2
│ ├── 5.4.3
│ ├── 5.5.0
│ ├── 5.5.1
│ ├── 5.5.2
│ ├── 5.5.3
│ ├── 5.6.0
│ ├── 5.6.1
│ ├── 5.6.2
│ ├── 5.6.3
│ ├── 5.6.4
│ ├── 5.6.5
│ └── repodata
└── elastic-6.x
├── 6.0.0
├── 6.0.1
├── 6.1.0
├── 6.1.1
└── repodata
34 directories, 0 files
[root@yum opt]# tree -L 4 yum_data/puppet/
yum_data/puppet/
└── el
├── 6
│ ├── dependencies
│ │ ├── i386
│ │ └── x86_64
│ ├── devel
│ │ ├── i386
│ │ └── x86_64
│ └── products
│ ├── i386
│ └── x86_64
└── 7
├── dependencies
│ └── x86_64
├── devel
│ ├── i386
│ └── x86_64
└── products
├── i386
└── x86_64
20 directories, 0 files
二、确定 yum 同步镜像地址
CentOS6源:
rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/
rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64/
rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/
EPEL6/7源:
rsync://mirrors.ustc.edu.cn/epel/6/x86_64/
rsync://mirrors.ustc.edu.cn/epel/7/x86_64/
Zabbix源:
rsync://mirror.tuna.tsinghua.edu.cn/zabbix/
Nginx源:
rsync://mirrors.ustc.edu.cn/repo/nginx/centos/6/x86_64/
rsync://mirrors.ustc.edu.cn/repo/nginx/centos/7/x86_64/
Foreman源:
rsync://rsync.theforeman.org/yum/releases/1.12/el6/x86_64/
rsync://rsync.theforeman.org/yum/plugins/1.12/el6/x86_64/
Remi源:
rsync://mirror.tuna.tsinghua.edu.cn/remi/enterprise/6/remi/x86_64/
Repoforge源:
rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/x86_64/rpmforge/
rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/x86_64/rpmforge/
rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/x86_64/extras/
rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/x86_64/extras/
Elasticstack源:
rsync://mirror.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-5.x/
rsync://mirror.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-6.x/
Puppet源:
rsync://rsync.puppet.com/packages/yum/el/6/dependencies/x86_64/
rsync://rsync.puppet.com/packages/yum/el/7/dependencies/x86_64/
rsync://rsync.puppet.com/packages/yum/el/6/dependencies/i386/
rsync://rsync.puppet.com/packages/yum/el/6/devel/x86_64/
rsync://rsync.puppet.com/packages/yum/el/7/devel/x86_64/
rsync://rsync.puppet.com/packages/yum/el/6/devel/i386/
rsync://rsync.puppet.com/packages/yum/el/7/devel/i386/
rsync://rsync.puppet.com/packages/yum/el/6/products/x86_64/
rsync://rsync.puppet.com/packages/yum/el/7/products/x86_64/
rsync://rsync.puppet.com/packages/yum/el/6/products/i386/
rsync://rsync.puppet.com/packages/yum/el/7/products/i386/
三、同步 yum 源:
Centos6源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/ /opt/yum_data/centos/6/os/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /opt/yum_data/centos/6/extras/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /opt/yum_data/centos/6/updates/x86_64/
Centos7源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/ /opt/yum_data/centos/7/os/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /opt/yum_data/centos/7/extras/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /opt/yum_data/centos/7/updates/x86_64/
EPEL6/7源:
[root@yum ~]# /usr/bin/rsync -avz --progress --exclude=debug --no-motd rsync://mirrors.ustc.edu.cn/epel/6/x86_64/ /opt/yum_data/epel/6/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --exclude=debug --no-motd rsync://mirrors.ustc.edu.cn/epel/7/x86_64/ /opt/yum_data/epel/7/x86_64/
Zabbix源:
[root@yum ~]# /usr/bin/rsync -avz --progress --exclude=debian --exclude=ubuntu --exclude=rhel/5 --exclude=rhel/6/i386 --exclude=rhel/6/SRPMS --exclude=rhel/7/SRPMS --no-motd rsync://mirror.tuna.tsinghua.edu.cn/zabbix/ /opt/yum_data/zabbix/
NGINX源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/repo/nginx/centos/6/x86_64/ /opt/yum_data/nginx/6/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirrors.ustc.edu.cn/repo/nginx/centos/7/x86_64/ /opt/yum_data/nginx/6/x86_64/
Foreman源:
[root@yum ~]# rsync --list-only rsync://rsync.theforeman.org/yum/releases/1.12/
[root@yum ~]# rsync --list-only rsync://rsync.theforeman.org/yum/plugins/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.theforeman.org/yum/releases/1.12/el6/x86_64/ /opt/yum_data/foreman/releases/1.12/el6/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.theforeman.org/yum/plugins/1.12/el6/x86_64/ /opt/yum_data/foreman/plugins/1.12/el6/x86_64/
Remi源:
[root@yum ~]# rsync --list-only rsync://mirror.tuna.tsinghua.edu.cn/remi/enterprise/6/
[root@yum ~]# /usr/bin/rsync -avz --progress --exclude=debug-* --exclude=test* --exclude=php*/i386/ --exclude=remi/i386/ --exclude=safe/i386/ --exclude=index.html --no-motd rsync://mirror.tuna.tsinghua.edu.cn/remi/enterprise/6/remi/x86_64/ /opt/yum_data/remi/6/x86_64/remi/x86_64/
Repoforge源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/x86_64/rpmforge/ /opt/yum_data/repoforge/rhel/el6/en/x86_64/rpmforge/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/x86_64/rpmforge/ /opt/yum_data/repoforge/rhel/el7/en/x86_64/rpmforge/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/x86_64/extras/ /opt/yum_data/repoforge/rhel/el6/en/x86_64/extras/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/x86_64/extras/ /opt/yum_data/repoforge/rhel/el7/en/x86_64/extras/
Elasticstack源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-5.x/ /opt/yum_data/elasticstack/elastic-5.x/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://mirror.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-6.x/ /opt/yum_data/elasticstack/elastic-6.x/
Puppet源:
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/dependencies/x86_64/ /opt/yum_data/puppet/el/6/dependencies/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/7/dependencies/x86_64/ /opt/yum_data/puppet/el/7/dependencies/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/dependencies/i386/ /opt/yum_data/puppet/el/6/dependencies/i386/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/devel/x86_64/ /opt/yum_data/puppet/el/6/devel/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/7/devel/x86_64/ /opt/yum_data/puppet/el/7/devel/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/devel/i386/ /opt/yum_data/puppet/el/6/devel/i386/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/7/devel/i386/ /opt/yum_data/puppet/el/7/devel/i386/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/products/x86_64/ /opt/yum_data/puppet/el/6/products/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motdrsync://rsync.puppet.com/packages/yum/el/7/products/x86_64/ /opt/yum_data/puppet/el/7/products/x86_64/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motd rsync://rsync.puppet.com/packages/yum/el/6/products/i386/ /opt/yum_data/puppet/el/6/products/i386/
[root@yum ~]# /usr/bin/rsync -avz --progress --no-motdrsync://rsync.puppet.com/packages/yum/el/7/products/i386/ /opt/yum_data/puppet/el/7/products/i386/
测试篇:
一、创建 yum 源的 repo 文件
[root@yum ~]# cd /etc/yum.repos.d/
[root@yum yum.repos.d]# more base.repo
[base]
enabled=1
baseurl=http://yum.base.com/centos/$releasever/os/$basearch/
path=/
gpgcheck=1
name=CentOS-$releasever - Base - yum.base.com
gpgkey=http://yum.base.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6
二、测试 yum 源是否正确
[root@yum ~]# yum clean all #<--清除缓存中的RPM包和头文件
Loaded plugins: fastestmirror, security
Cleaning repos: base elastic-5.x elastic-6.x epel extras foreman foreman-plugins nginx remi rpmforge rpmforge-extras updates
: zabbix-client
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@yum yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, security
Determining fastest mirrors
base | 3.7 kB 00:00
base/group_gz | 226 kB 00:00
base/filelists_db | 6.4 MB 00:00
base/primary_db | 4.7 MB 00:00
base/other_db | 2.8 MB 00:00
elastic-5.x | 2.9 kB 00:00
elastic-5.x/filelists_db | 7.5 MB 00:00
elastic-5.x/primary_db | 261 kB 00:00
elastic-5.x/other_db | 18 kB 00:00
elastic-6.x | 2.9 kB 00:00
elastic-6.x/filelists_db | 1.0 MB 00:00
elastic-6.x/primary_db | 47 kB 00:00
elastic-6.x/other_db | 4.2 kB 00:00
epel | 4.7 kB 00:00
epel/group_gz | 255 kB 00:00
epel/filelists_db | 7.8 MB 00:00
epel/prestodelta | 321 B 00:00
epel/primary_db | 6.0 MB 00:00
epel/other_db | 3.0 MB 00:00
extras | 3.4 kB 00:00
extras/filelists_db | 26 kB 00:00
extras/prestodelta | 1.3 kB 00:00
extras/primary_db | 29 kB 00:00
extras/other_db | 30 kB 00:00
foreman | 2.9 kB 00:00
foreman/filelists_db | 759 kB 00:00
foreman/primary_db | 148 kB 00:00
foreman/other_db | 84 kB 00:00
foreman-plugins | 2.9 kB 00:00
foreman-plugins/filelists_db | 289 kB 00:00
foreman-plugins/primary_db | 68 kB 00:00
foreman-plugins/other_db | 43 kB 00:00
nginx | 2.9 kB 00:00
nginx/filelists_db | 36 kB 00:00
nginx/primary_db | 32 kB 00:00
nginx/other_db | 16 kB 00:00
puppetlabs-deps | 2.5 kB 00:00
puppetlabs-deps/filelists_db | 198 kB 00:00
puppetlabs-deps/primary_db | 27 kB 00:00
puppetlabs-deps/other_db | 21 kB 00:00
puppetlabs-products | 2.5 kB 00:00
puppetlabs-products/filelists_db | 1.0 MB 00:00
puppetlabs-products/primary_db | 170 kB 00:00
puppetlabs-products/other_db | 194 kB 00:00
remi | 2.9 kB 00:00
remi/filelists_db | 2.4 MB 00:00
remi/primary_db | 2.0 MB 00:00
remi/other_db | 976 kB 00:00
rpmforge | 1.9 kB 00:00
rpmforge/filelists_db | 2.3 MB 00:00
rpmforge/primary_db | 2.7 MB 00:00
rpmforge/other_db | 575 kB 00:00
rpmforge-extras | 1.9 kB 00:00
rpmforge-extras/filelists_db | 335 kB 00:00
rpmforge-extras/primary_db | 472 kB 00:00
rpmforge-extras/other_db | 92 kB 00:00
updates | 3.4 kB 00:00
updates/filelists_db | 3.5 MB 00:00
updates/prestodelta | 171 kB 00:00
updates/primary_db | 5.8 MB 00:00
updates/other_db | 83 MB 00:01
zabbix-client | 2.9 kB 00:00
zabbix-client/filelists_db | 64 kB 00:00
zabbix-client/primary_db | 86 kB 00:00
zabbix-client/other_db | 60 kB 00:00
Metadata Cache Created
[root@yum ~]# yum repolist #<--列出yum源中可用的软件包
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
repo id repo name status
base CentOS-6 - Base - yum.base.com 6,706
elastic-5.x Elastic repository for 5.x packages 302
elastic-6.x Elastic repository for 6.x packages 60
epel Extra Packages for Enterprise Linux 6 - x86_64 12,448
extras CentOS-6 - Extras - yum.base.com 47
foreman Foreman 1.12 460
foreman-plugins Foreman 1.12 240
nginx nginx-6 - yum.base.com 90
puppetlabs-deps Puppet Labs Dependencies El 6 - x86_64 77
puppetlabs-products Puppet Labs Products El 6 - x86_64 564
remi Les RPM de remi pour Enterprise Linux 6 - x86_64 4,890
rpmforge RHEL 6 - yum.base/rpmforge - dag 4,718
rpmforge-extras RHEL 6 - yum.base/extras - dag 711
updates CentOS-6 - Updates - yum.base.com 858
zabbix-client zabbix client repo for yum.base.com 170
repolist: 32,341
[root@yum ~]# yum install htop #<--测试rpmforge源
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
elastic-5.x | 2.9 kB 00:00
elastic-6.x | 2.9 kB 00:00
epel | 4.7 kB 00:00
extras | 3.4 kB 00:00
foreman | 2.9 kB 00:00
foreman-plugins | 2.9 kB 00:00
nginx | 2.9 kB 00:00
remi | 2.9 kB 00:00
rpmforge | 1.9 kB 00:00
rpmforge-extras | 1.9 kB 00:00
updates | 3.4 kB 00:00
zabbix-client | 2.9 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:1.0.3-1.el6.rf will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
htop x86_64 1.0.3-1.el6.rf rpmforge 87 k
Transaction Summary
=====================================================================================================================================
Install 1 Package(s)
Total download size: 87 k
Installed size: 209 k
[root@yum ~]# yum install php
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.4.45-13.el6.remi will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.45-13.el6.remi for package: php-5.4.45-13.el6.remi.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.4.45-13.el6.remi for package: php-5.4.45-13.el6.remi.x86_64
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.4.45-13.el6.remi.x86_64
--> Processing Dependency: httpd for package: php-5.4.45-13.el6.remi.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-60.el6.centos.6 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-60.el6.centos.6 for package: httpd-2.2.15-60.el6.centos.6.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-60.el6.centos.6.x86_64
---> Package php-cli.x86_64 0:5.4.45-13.el6.remi will be installed
---> Package php-common.x86_64 0:5.4.45-13.el6.remi will be installed
--> Running transaction check
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-60.el6.centos.6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
php x86_64 5.4.45-13.el6.remi remi 2.8 M
Installing for dependencies:
apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
httpd x86_64 2.2.15-60.el6.centos.6 updates 836 k
httpd-tools x86_64 2.2.15-60.el6.centos.6 updates 80 k
php-cli x86_64 5.4.45-13.el6.remi remi 4.1 M
php-common x86_64 5.4.45-13.el6.remi remi 968 k
Transaction Summary
=====================================================================================================================================
Install 6 Package(s)
Total download size: 8.8 M
Installed size: 32 M
参数篇:
--progress:可以显示同步的进度,包括文件传输完成进度、传输速率信息
--no-motd:此选项会影响客户端在守护程序传输开始时输出的信息。它会禁止 motd 信息,但是也会影响 daemon 对 "rsync host::" 请求显示模块列表的回应信息,因此如果想要请求 daemon 的模块列表,应该忽略该选项。
--list-only:该选项强制 rsync 仅列出源路径的文件列表而不是进行文件传输。如果 rsync 命令行中只给出了一个地址,将隐含该选项。注意通配符会被 shell 解析并扩展为 rsync 的参数。
-z:传输前进行压缩
-a:归档模式,表示以递归方式传输文件,并保持所有文件属性,等于 -rlptgoD
-v:显示命令执行详细信息
计划任务脚本:
#!/bin/bash
#同步本地YUM源
#YUM存储路径
Data=/opt/yum_data
#YUM源rsync地址
Ustc=mirrors.ustc.edu.cn/centos
Epel=mirrors.ustc.edu.cn/epel
Repo=mirrors.ustc.edu.cn/repo
Tsinghua=mirror.tuna.tsinghua.edu.cn
Forman=rsync.theforeman.org
Puppet=rsync.puppet.com/packages/yum
source /etc/profile
datetime=`date +"%Y-%m-%d"`
exec > /var/log/synchronous.log
#同步Centos 6/7 的OS、Extras、Updates
for i in {1..3}
do
for version in 6 7
do
/usr/bin/rsync -az --no-motd rsync://$Ustc/$version/os/x86_64/ $Data/centos/$version/os/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version os update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version os update failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Ustc/$version/extras/x86_64/ $Data/centos/$version/extras/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version extras successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version extras failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Ustc/$version/updates/x86_64/ $Data/centos/$version/updates/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version update failed \033[0m"
fi
done
sleep 10
done
#同步EPEL 6/7
for i in {1..3}
do
for version in 6 7
do
/usr/bin/rsync -az --exclude=debug --no-motd rsync://$Epel/$version/x86_64/ $Data/epel/$version/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m EPEL $version update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m EPEL $version update failed \033[0m"
fi
done
sleep 10
done
#同步ZABBIX
/usr/bin/rsync -az --exclude=debian --exclude=ubuntu --exclude=rhel/5 --exclude=rhel/6/i386 --exclude=rhel/6/SRPMS --exclude=rhel/7/SRPMS --no-motd rsync://$Tsinghua/zabbix/ $Data/zabbix/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m ZABBIX update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m ZABBIX update failed \033[0m"
fi
#同步Nginx
for i in {1..3}
do
for version in 6 7
do
/usr/bin/rsync -az --no-motd rsync://$Repo/nginx/centos/$version/x86_64/ $Data/nginx/$version/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version Nginx update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version Nginx update failed \033[0m"
fi
done
sleep 10
done
#同步Foreman
/usr/bin/rsync -az --no-motd rsync://$Forman/yum/releases/1.12/el6/x86_64/ $Data/foreman/releases/1.12/el6/x86_64/ > /dev/null
/usr/bin/rsync -az --no-motd rsync://$Forman/yum/releases/1.17/el7/x86_64/ $Data/foreman/releases/1.17/el7/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Foreman update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Foreman update failed \033[0m"
fi
#同步Foreman-plugins
/usr/bin/rsync -az --no-motd rsync://$Forman/yum/plugins/1.12/el6/x86_64/ $Data/foreman/plugins/1.12/el6/x86_64/ > /dev/null
/usr/bin/rsync -az --no-motd rsync://$Forman/yum/plugins/1.17/el7/x86_64/ $Data/foreman/plugins/1.17/el7/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Foreman-plugins update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Foreman-plugins update failed \033[0m"
fi
#同步Remi
/usr/bin/rsync -az --exclude=debug-* --exclude=test* --exclude=php*/i386/ --exclude=remi/i386/ --exclude=safe/i386/ --no-motd rsync://$Tsinghua/remi/enterprise/6/remi/x86_64/ $Data/remi/6/x86_64/remi/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Remi update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Remi update failed \033[0m"
fi
#同步Repoforge-rpmforge
for version in 6 7
do
/usr/bin/rsync -az --no-motd rsync://$Tsinghua/repoforge/redhat/el$version/en/x86_64/rpmforge/ $Data/repoforge/rhel/el$version/en/x86_64/rpmforge/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version Repoforge-rpmforge update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version Repoforge-rpmforge update failed"
fi
done
#同步Repoforge-extras
for version in 6 7
do
/usr/bin/rsync -az --no-motd rsync://$Tsinghua/repoforge/redhat/el$version/en/x86_64/extras/ $Data/repoforge/rhel/el$version/en/x86_64/extras/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m Centos $version Repoforge-extras update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m Centos $version Repoforge-extras update failed \033[0m"
fi
done
#同步Elasticstack
for version in elastic-5.x elastic-6.x
do
/usr/bin/rsync -az --no-motd rsync://$Tsinghua/elasticstack/yum/$version/ $Data/elasticstack/$version/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m $version update successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m $version update failed \033[0m"
fi
done
#同步Puppet
for version in 6 7
do
for architecture in x86_64 i386
do
/usr/bin/rsync -az --no-motd rsync://$Puppet/el/$version/dependencies/$architecture/ $Data/puppet/el/$version/dependencies/$architecture/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m puppet $version dependencies($architecture) successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m puppet $version dependencies($architecture) failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Puppet/el/$version/devel/$architecture/ $Data/puppet/el/$version/devel/$architecture/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m puppet devel($architecture) successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m puppet devel($architecture) failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Puppet/el/$version/products/$architecture/ $Data/puppet/el/$version/products/$architecture/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m puppet products($architecture) successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m puppet products($architecture) failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Puppet/puppet/el/$version/x86_64/ $Data/puppet/puppet/el/$version/x86_64/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m puppet $version x86_64 successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m puppet $version x86_64 failed \033[0m"
fi
/usr/bin/rsync -az --no-motd rsync://$Puppet/puppet/el/6/i386/ $Data/puppet/puppet/el/6/i386/ > /dev/null
if [ $? -eq 0 ];then
echo -e "SUCESS: $datetime \033[32m puppet 6 i386 successful \033[0m"
else
echo -e "ERROR: $datetime \033[31m puppet 6 i386 failed \033[0m"
fi
done
done
chown -R root.root $Data/
yum clean all
yum makecache
mail -s "yum-update" -a /var/log/synchronous.log [email protected]
转载至http://blog.51cto.com/stuart/2061869