• 1.YUM源服务器部署信息表;

  • 2.YUM源服务部署架构图;

  • 3.部署过程详细;

    • 3.1 获取远程基础yum源仓库

    • 3.2. 安装 createrepo 管理工具

    • 3.3 创建目录

    • 3.4. 安装 nginx

    • 3.5. 配置仓库路径

    • 3.6. 启动 nginx

    • 3.7. 配置 repo

    • 3.8. 同步源

    • 3.9. 创建 repo 库

    • 3.10. 下载 rpm 包及依赖到 packages

    • 3.11 客户端使用;


1.YUM源服务器部署信息表;

环境类型 服务名称 IP地址信息 部署路径 访问域名 备注


PROD

NGINX


172.21.1.1


/etc/nginx/conf.d/


ops-yum.com

yum访问入口代理
YUM服务 /chj/data/YUM yum软件仓库存储位置


2.YUM源服务部署架构图;



3.部署过程详细;


3.1 获取远程基础yum源仓库


1
2
3
4
5
6
7
8
9
10
mkdir  /etc/yum .repos.d /bak/
mv  /etc/yum .repos.d/*   /etc/yum .repos.d /bak/
curl -o  /etc/yum .repos.d /CentOS-Base .repo http: //mirrors .aliyun.com /repo/Centos-7 .repo
curl -o  /etc/yum .repos.d /epel-7 .repo http: //mirrors .aliyun.com /repo/epel-7 .repo
 
curl -o  /etc/yum .repos.d /jenkins .repo http: //pkg .jenkins-ci.org /redhat-stable/jenkins .repo
rpm -- import  http: //pkg .jenkins-ci.org /redhat-stable/jenkins-ci .org.key
rpm -Uvh https: //mirror .webtatic.com /yum/el7/epel-release .rpm
rpm -Uvh https: //mirror .webtatic.com /yum/el7/webtatic-release .rpm
yum  install  -y epel-release


3.2. 安装 createrepo 管理工具


1
2
yum -y install createrepo
yum -y install yum-utils



3.3 创建目录


1
mkdir  /data/YUM


3.4. 安装 nginx


1
2
3
4
5
6
7
8
9
10
11
12
13
14
yum -y  install  nginx
/etc/nginx/conf .d
cat  yum.conf
server {
       listen 80;
       server_name  ops-yum.com;
       access_log   /var/log/yum .log;
       location / {
              root  /chj/data/ ;
              autoindex on;              #开启索引功能
              autoindex_exact_size off;  # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
              autoindex_localtime on;  
       }
}


3.5. 配置仓库路径


1
2
cd  /data/
ln -s /data/YUM/   /data/Centos


3.6. 启动 nginx


1
2
systemctl start nginx
systemctl  enable  nginx



3.7. 配置 repo


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(
cat  <
[base]
name=Local YUM base
baseurl=http: //ops-yum.com /Centos/base
gpgcheck=0
enabled=1
 
[epel]
name=Local YUM epel
baseurl=http: //ops-yum.com /Centos/epel
gpgcheck=0
enabled=1
 
[extras]
name=Local YUM extras
baseurl=http: //ops-yum.com /Centos/extras
gpgcheck=0
enabled=1
 
[updates]
name=Local YUM updates
baseurl=http: //ops-yum.com /Centos/updates
gpgcheck=0
enabled=1
 
[jenkins]
name=Local YUM jenkins
baseurl=http: //ops-yum.com /Centos/jenkins
gpgcheck=0
enabled=1
 
[webtatic]
name=Local YUM webtatic
baseurl=http: //ops-yum.com /Centos/webtatic
gpgcheck=0
enabled=1
EOF
) > / data/YUM/CentOS7 .repo


3.8. 同步源


1
2
3
4
5
6
7
cd  /YUM
reposync -n -d -r extras
reposync -n -d -r updates
reposync -n -d -r base
reposync -n -d -r epel
reposync -n -d -r jenkins
reposync -n -d -r webtatic


3.9. 创建 repo 库


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
rm  -rf ` find  /data/YUM/  -name repodata`
createrepo - v  /data/YUM/base
createrepo - v  /data/YUM/epel
createrepo - v  /data/YUM/extras
createrepo - v  /data/YUM/updates
createrepo - v  /data/YUM/jenkins
createrepo - v  /data/YUM/webtatic
 
curl -o  /data/YUM/base/repodata/comps .xml.gz https: //mirrors .aliyun.com /centos/7/os/x86_64/repodata/29b154c359eaf12b9e35d0d5c649ebd62ce43333f39f02f33ed7b08c3b927e20-c7-x86_64-comps .xml.gz
gzip  -d  /data/YUM/base/repodata/comps .xml.gz
createrepo -vg  /YUM/base/repodata/comps .xml  /data/YUM/base
 
curl -o  /data/YUM/epel/repodata/comps .xml.gz http: //mirrors .aliyun.com /epel/7/x86_64/repodata/c05b9b116fbeb56969f8572766a459cf23c8887335f16611b097073726a45f77-comps-Everything .x86_64.xml.gz
gzip  -d  /data/YUM/epel/repodata/comps .xml.gz
curl -o  /data/YUM/epel/repodata/epel-comps .xml http: //mirrors .aliyun.com /epel/7/x86_64/repodata/5307666922f0cd10058b04791f3f596cfcaab48df6fdd6cf847f349bd455e0bd-comps-Everything .x86_64.xml
createrepo -vg / data/YUM/epel/repodata/comps .xml  /data/YUM/epel
createrepo -vg  /data/YUM/epel/repodata/epel-comps .xml  /data/YUM/epel



3.10. 下载 rpm 包及依赖到 packages


1
2
3
4
5
6
7
8
9
10
yumdownloader -y --resolve --destdir=/chj/data/YUM/packages
nginx mariadb-server mariadb php56w php56w-mysql php56w-gd 
php56w-imap php56w-ldap php56w-odbc php56w-pear
php56w-xml php56w-xmlrpc php56w-mbstring php56w-mcrypt
php56w-bcmath php56w-mhash php56w-fpm php56w-opcache
jenkins zlib zlib-devel libffi-devel openssl-devel glibc make
binutils gcc libaio bc flex bash-completion httpd subversion
mod_dav_svn java autoconf automake curl gcc git libmnl-devel
libuuid-devel lm_sensors make MySQL-python nc
pkgconfig python python-psycopg2 PyYAML zlib-devel  '@Development Tools'



3.11. 创建 repo


1
createrepo - v  /data/YUM/packages



3.11 客户端使用;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
mkdir /etc/yum.repos.d/bak
cd /etc/yum.repos.d
mv *.repo bak
  
cat CHJ_CentOS7.repo
[base]
name=Local YUM base
baseurl=http: //ops-yum.com/Centos/base
gpgcheck= 0
enabled= 1
 
[epel]
name=Local YUM epel
baseurl=http: //ops-yum.com/Centos/epel
gpgcheck= 0
enabled= 1
 
[extras]
name=Local YUM extras
baseurl=http: //ops-yum.com/Centos/extras
gpgcheck= 0
enabled= 1
 
[updates]
name=Local YUM updates
baseurl=http: //ops-yum.com/Centos/updates
gpgcheck= 0
enabled= 1