通過 rsync 搭建 CentOS 本地 yum 源伺服器
阿新 • • 發佈:2018-12-20
說明:
作業系統:CentOS 6.x
主機名:yum.base.com
IP 地址:192.168.27.233(生產區伺服器)
實現目的:由於生產區伺服器無法上外網,為了方便生產區安裝軟體,同步 yum 映象站點的內容到此伺服器,向生產區提供 yum服務。
RSYNC 代理上網:
[[email protected] ~]# vim /etc/profile
export RSYNC_PROXY="repo.base.com:3128"
[[email protected] ~]# source /etc/profile
準備篇:
一、安裝 HTTP 服務
這裡使用 NGINX 提供 HTTP 服務。
NGINX 的安裝
[[email protected] ~]# cd /opt/nginx-1.12.1
[[email protected] 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
[ [email protected] nginx-1.12.1]# make
[[email protected] nginx-1.12.1]# make install
二、系統約定
NGINX 系統根目錄:/opt/yum_data/
三、開啟 NGINX 目錄瀏覽功能
[[email protected] 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; #<--顯示檔案修改時間為伺服器本地時間
}
}
[ [email protected] ~]# cd /usr/local/nginx/sbin/
[[email protected] sbin]# nginx
安裝篇:
一、建立映象檔案存放目錄
[[email protected] ~]# mkdir /opt/yum_data/centos/6/{extras,os,updates}/x86_64 -p
[[email protected] ~]# mkdir /opt/yum_data/centos/7/{extras,os,updates}/x86_64 -p
[[email protected] ~]# mkdir /opt/yum_data/epel/{6,7}/x86_64/ -p
[[email protected] ~]# mkdir /opt/yum_data/repoforge/rhel/el{6,7}/en/x86_64/{extras,rpmforge}/RPMS/ -p
[[email protected] ~]# mkdir /opt/yum_data/remi/6/remi/x86_64/ -p
[[email protected] ~]# mkdir /opt/yum_data/elasticstack/elastic-{5.x,6.x}/ -p
[[email protected] ~]# mkdir /opt/yum_data/foreman/{plugins,releases}/1.12/el6/x86_64/ -p
[[email protected] ~]# mkdir /opt/yum_data/nginx/{6,7}/x86_64/RPMS/ -p
[[email protected] ~]# mkdir /opt/yum_data/zabbix/ -p
[[email protected] ~]# mkdir /opt/yum_data/puppet/el/{6,7}/{dependencies,devel,products}/{i386,x86_64} -p
[[email protected] ~]# mkdir /opt/yum_data/puppet/puppet/el/{6,7}/x86_64 -p
[[email protected] ~]# mkdir /opt/yum_data/puppet/puppet/el/6/i386 -p
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] opt]# tree -L 4 yum_data/repoforge/
yum_data/repoforge/
└── rhel
├── el6
│ └── en
│ └── x86_64
└── el7
└── en
└── x86_64
7 directories, 0 files
[[email protected] opt]# tree -L 3 yum_data/nginx/
yum_data/nginx/
├── 6
│ └── x86_64
│ ├── repodata
│ └── RPMS
└── 7
└── x86_64
├── repodata
└── RPMS
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# rsync --list-only rsync://rsync.theforeman.org/yum/releases/1.12/
[[email protected] ~]# rsync --list-only rsync://rsync.theforeman.org/yum/plugins/
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# rsync --list-only rsync://mirror.tuna.tsinghua.edu.cn/remi/enterprise/6/
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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源:
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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/
[[email protected] ~]# /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 檔案
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] 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 源是否正確
[[email protected] ~]# 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
[[email protected] 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
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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