首页 / CENTOS / 制作CentOS7yum源
制作CentOS7yum源
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了制作CentOS7yum源,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4991字,纯文字阅读大概需要8分钟。
内容图文
![制作CentOS7yum源](/upload/InfoBanner/zyjiaocheng/943/39034700b4bf4152aa3f3866432141d9.jpg)
制作CentOS7.7 内网yum源
如果CentOS服务器处在内网环境中时,如果缺少依赖手动安装那么会非常麻烦,要花费很多时间来寻找rpm包,现在如果搭建本地的yum源,就非常方便了,如果搭建http的,那么局域网内其他服务器就都可以使用了,使用yum源首先需要一个CentOS安装镜像
IP | 主机名 | 用途 |
---|---|---|
192.168.200.27 | yum | 内网yum源服务器 |
192.168.200.29 | web | web服务器 |
1. 安装http服务
[root@yum ~]# yum -y install httpd
[root@yum ~]# systemctl start httpd
[root@yum ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
2. 挂在本地源
[root@yum ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@yum ~]# df -h | tail -1
/dev/sr0 4.2G 4.2G 0 100% /mnt
[root@yum ~]# ll /mnt/
总用量 678
-rw-rw-r-- 1 root root 14 5月 2 2018 CentOS_BuildTag
drwxr-xr-x 3 root root 2048 5月 4 2018 EFI
-rw-rw-r-- 1 root root 227 8月 30 2017 EULA
-rw-rw-r-- 1 root root 18009 12月 10 2015 GPL
drwxr-xr-x 3 root root 2048 5月 4 2018 images
drwxr-xr-x 2 root root 2048 5月 4 2018 isolinux
drwxr-xr-x 2 root root 2048 5月 4 2018 LiveOS
drwxrwxr-x 2 root root 655360 5月 4 2018 Packages
drwxrwxr-x 2 root root 4096 5月 4 2018 repodata
-rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root 2883 5月 4 2018 TRANS.TBL
3. 把本地源拷贝到httpd的静态资源路径下
[root@yum ~]# cd /var/www/html/
[root@yum html]# cp -a /mnt ./centos
[root@yum html]# ll -d centos
drwxr-xr-x 8 root root 254 5月 4 2018 centos
[root@yum html]# ll centos/
总用量 320
-rw-rw-r-- 1 root root 14 5月 2 2018 CentOS_BuildTag
drwxr-xr-x 3 root root 35 5月 4 2018 EFI
-rw-rw-r-- 1 root root 227 8月 30 2017 EULA
-rw-rw-r-- 1 root root 18009 12月 10 2015 GPL
drwxr-xr-x 3 root root 57 5月 4 2018 images
drwxr-xr-x 2 root root 198 5月 4 2018 isolinux
drwxr-xr-x 2 root root 43 5月 4 2018 LiveOS
drwxrwxr-x 2 root root 221184 5月 4 2018 Packages
drwxrwxr-x 2 root root 4096 5月 4 2018 repodata
-rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 root root 2883 5月 4 2018 TRANS.TBL
4. 网页访问测试
5. 修改yum源的配置
[root@yum html]# cd /etc/yum.repos.d/
[root@yum yum.repos.d]# mkdir bak
[root@yum yum.repos.d]# mv CentOS-* bak/
[root@yum yum.repos.d]# vim Centos.repo
[root@yum yum.repos.d]# cat Centos.repo
[base]
name=CentOS7.7-base
baseurl=file:///var/www/html/centos/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
6. 卸载本地镜像进行本地测试
[root@yum yum.repos.d]# umount /dev/sr0
[root@yum yum.repos.d]# yum -y clean all
[root@yum yum.repos.d]# yum makecache
[root@yum yum.repos.d]# rpm -qa|grep lsof
[root@yum yum.repos.d]# yum -y install lsof
[root@yum yum.repos.d]# rpm -qa|grep lsof
lsof-4.87-5.el7.x86_64
7.远程进行网络测试
[root@web ~]# cd /etc/yum.repos.d/
[root@web yum.repos.d]# mkdir bak
[root@web yum.repos.d]# mv CentOS-* bak/
[root@web yum.repos.d]# vim Centos.repo
[root@web yum.repos.d]# cat Centos.repo
[base]
name=CentOS7.7-base
baseurl=http://192.168.200.27/centos/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@web yum.repos.d]# yum -y clean all
[root@web yum.repos.d]# yum makecache
[root@web yum.repos.d]# rpm -qa|grep lsof
[root@web yum.repos.d]# yum -y install lsof
[root@web yum.repos.d]# rpm -qa|grep lsof
lsof-4.87-5.el7.x86_64
8. 下载7.7.1908增量的repo数据
[root@yum yum.repos.d]# mkdir -p /var/www/html/updates/repodata
[root@yum yum.repos.d]# cd /var/www/html/updates/repodata
[root@yum repodata]# wget http://mirrors.163.com/centos/7.7.1908/updates/x86_64/repodata/
[root@yum repodata]# wget -nc -B http://mirrors.163.com/centos/7.7.1908/updates/x86_64/repodata/ -F -nH --cut-dirs=3 -i index.html
9. 下载7.7.1908增量的更新软件集
[root@yum repodata]# mkdir -p /var/www/html/updates/Packages
[root@yum repodata]# cd /var/www/html/updates/Packages
[root@yum Packages]# wget http://mirrors.163.com/centos/7.7.1908/updates/x86_64/Packages/
[root@yum Packages]# wget -nc -B http://mirrors.163.com/centos/7.7.1908/updates/x86_64/Packages/ -F -nH --cut-dirs=3 -i index.html
10.远程进行网络升级测试
[root@web yum.repos.d]# vim Centos.repo
[root@web yum.repos.d]# cat Centos.repo
[base]
name=CentOS7.7-base
baseurl=http://192.168.200.27/centos/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7.7-Updates
baseurl=http://192.168.200.27/updates/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@web yum.repos.d]# yum -y clean all
[root@web yum.repos.d]# yum makecache
[root@web yum.repos.d]# rpm -qa|grep sudo
sudo-1.8.23-3.el7.x86_64
[root@web yum.repos.d]# yum update sudo
[root@web yum.repos.d]# rpm -qa|grep sudo
sudo-1.8.23-4.el7_7.1.x86_64
如果包源更新失败,请参考 http://www.path8.net/tn/archives/6098
内容总结
以上是互联网集市为您收集整理的制作CentOS7yum源全部内容,希望文章能够帮你解决制作CentOS7yum源所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。