注意:环境要求
` 阿里源的centos6和centos7各14G不到,注意磁盘空间`
'环境准备,修改hostname,关闭防火墙,disabled selinux'
[ root@localhost ~]
[ root@yum-server ~]
[ root@yum-server ~]
1、配置服务器端yum
1.1、安装yum源工具
[ root@yum-server ~]
[ root@yum-server ~]
[ root@yum-server ~]
1.2、配置nginx
[ root@yum-server nginx]
[ root@yum-server nginx]
[ root@yum-server nginx]
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;
location / {
}
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
[ root@yum-server nginx]
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[ root@yum-server nginx]
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[ root@yum-server nginx]
HTTP/1.1 200 OK
Server: nginx/1.16.1
Date: Sun, 05 Jul 2020 09:48:05 GMT
Content-Type: text/html
Content-Length: 4833
Last-Modified: Fri, 16 May 2014 15:12:48 GMT
Connection: keep-alive
ETag: "53762af0-12e1"
Accept-Ranges: bytes
1.2.1、配置nginx页面目录
[ root@yum-server nginx]
[ root@yum-server html]
[ root@yum-server html]
/usr/share/nginx/html/CentOS-YUM/
└── Aliyun
├── version_6
│ └── 64bit
└── version_7
└── 64bit
5 directories, 0 files
[root@yum-server html]# cd CentOS-YUM/
[root@yum-server CentOS-YUM]# vim index.html
< p style =" font-weight : bolder; color : green; font-size : 30px; " > ALL of the packages in the below:</ p>
< br/>
< a href = " http://192.168.57.133/CentOS-YUM/Aliyun" > version_6</ a> < br/>
These packagers using for Centos 6< br/>
< a href = " http://192.168.57.133/CentOS-YUM/Aliyun" > version_7</ a> < br/>
These packagers using for Centos 7< br/>
< p style =" font-weight : bolder; color : red; font-size : 18px; " > Please replace the file and fill in the f ollowing content:</ p>
< p style =" font-weight : bolder; color : blue; font-size : 15px; " > Way: /etc/yum.repos.d/CentOS-Base.repo</ p>
1.3、替换yum源文件
[ root@yum-server CentOS-YUM]
[ root@yum-server yum.repos.d]
[ root@yum-server yum.repos.d]
[ root@yum-server yum.repos.d]
reposync -p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_7/64bit/
/usr/bin/sed -i "s/7/6/g" /etc/yum.repos.d/CentOS-Base.repo
reposync -p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_6/64bit/
/usr/bin/sed -i "s/6/7/g" /etc/yum.repos.d/CentOS-Base.repo
[ root@yum-server yum.repos.d]
[ root@yum-server yum.repos.d]
total 8
-rw-r--r-- 1 root root 2523 Jun 16 2018 CentOS-Base.repo
-rwxr-xr-x 1 root root 303 Jul 5 19:02 yum.reposync.sh
[ root@yum-server yum.repos.d]
[ root@yum-server CentOS-YUM]
9.0G Aliyun/version_7/64bit/base/Packages
9.0G Aliyun/version_7/64bit/base
616M Aliyun/version_7/64bit/extras/Packages
616M Aliyun/version_7/64bit/extras
3.6G Aliyun/version_7/64bit/updates/Packages
3.6G Aliyun/version_7/64bit/updates
14G Aliyun/version_7/64bit
14G Aliyun/version_7
9.0G Aliyun/version_6/64bit/base/Packages
9.0G Aliyun/version_6/64bit/base
616M Aliyun/version_6/64bit/extras/Packages
616M Aliyun/version_6/64bit/extras
3.6G Aliyun/version_6/64bit/updates/Packages
3.6G Aliyun/version_6/64bit/updates
14G Aliyun/version_6/64bit
14G Aliyun/version_6
27G Aliyun/
27G total
1.4、建立yum源仓库
'因为建仓最终的目的也是可供client来进行检索的,所以得每个Packages目录都要建成仓库,所以建仓的时候,目录指到最底层的Packages,而-np更新的时候只用指定到64bit的目录就可以了,否则会重复建立base、extras、updates三个目录进行下载
[ root@yum-server ~]
Spawning worker 0 with 10070 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[ root@yum-server ~]
Spawning worker 0 with 397 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[ root@yum-server ~]
Spawning worker 0 with 884 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[ root@yum-server ~]
Spawning worker 0 with 10070 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[ root@yum-server ~]
Spawning worker 0 with 884 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[ root@yum-server ~]
Spawning worker 0 with 397 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete[ root@yum-server ~]
/usr/share/nginx/html/CentOS-YUM/Aliyun/
├── version_6
│ └── 64bit
│ ├── base
│ │ └── Packages
│ │ └── repodata
│ ├── extras
│ │ └── Packages
│ │ └── repodata
│ └── updates
│ └── Packages
│ └── repodata
└── version_7
└── 64bit
├── base
│ └── Packages
│ └── repodata
├── extras
│ └── Packages
│ └── repodata
└── updates
└── Packages
└── repodata
22 directories
'可以写一个更新yum源的脚本,然后写一个计划任务,定期更新yum源(reposync -np 就是更新新的rpm包)
reposync -np /usr/share/nginx/html/CentOS-YUM/Aliyun/version_7/64bit/
echo "centos7 is sync complate"
/usr/bin/sed -i "s/7/6/g" /etc/yum.repos.d/CentOS-Base.repo`
reposync -np /usr/share/nginx/html/CentOS-YUM/Aliyun/version_6/64bit/
echo "centos6 is sync complate"
/usr/bin/sed -i "s/6/7/g" /etc/yum.repos.d/CentOS-Base.repo
2、配置客户端yum
[ root@localhost ~]
[ root@localhost yum.repos.d]
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
back
[ root@localhost yum.repos.d]
[ Aliyun_7_base]
name= source_from_localserver
baseurl= http://192.168.57.133/CentOS-YUM/Aliyun/version_7/64bit/base/Packages
gpgcheck= 0
enable= 1
[ Aliyun_7_extras]
name= source_from_localserver
baseurl= http://192.168.57.133/CentOS-YUM/Aliyun/version_7/64bit/extras/Packages
gpgcheck= 0
enable= 1
[ Aliyun_7_updates]
name= source_from_localserver
baseurl= http://192.168.57.133/CentOS-YUM/Aliyun/version_7/64bit/updates/Packages
gpgcheck= 0
enable= 1
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Package Arch Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Installing:
net-tools x86_64 2.0-0.25.20131004git.el7 Aliyun_7_base 306 k
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
Install 1 Package
Total download size: 306 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
Complete!
安装完成,Repository里面显示,是从Aliyun_7_base内获取的,到此,yum源仓库(阿里源)部署完成