linux搭建http源yum仓库【服务端和客户端详细说明】、linux搭建多个http源的yum仓库、centos8或belinux8搭建http源yum仓库方法、建立索引报错处理 |
您所在的位置:网站首页 › 粤语说早点睡觉 › linux搭建http源yum仓库【服务端和客户端详细说明】、linux搭建多个http源的yum仓库、centos8或belinux8搭建http源yum仓库方法、建立索引报错处理 |
文章目录
说明服务端关闭防火墙和selinux配置http服务rpm安装包准备建立索引权限配置测试
多服务端源搭建客户端yum文件配置清除缓存并验证完整流程
centos8或belinux8搭建http源yum仓库方法服务端搭建服务端配置方法建立索引报错Old repodata doesn't exists: Cannot rename packages86_Base/repodata/ -> packages86_Base/repodata.old.10456.20230713103559.636274: No such file or directory
总结
说明
搭建的HTTP源本质上和使用镜像搭建的本地源是一样的,我们平常搭建的http源的包一般也是用镜像里面的包,比如某台服务器升级ssh失败了,又没有搭建本地源,没有任何共享服务的包,那么这时候在另外一台服务器上搭建一个http源,在故障服务器上配置http源即可。 我下面的HTTP配置使用的包就是iso镜像里面的包【同理,我们只要会这种方式以后,使用什么包都一样,可以自己在网上下载自己需要的包和依赖,然后通过这种方式配置成http源,然后就可以直接使用yum安装了,这样的好处是解决软件在安装的时候会有许多依赖包这个繁琐的过程,他将我们管理的软件包规整到一起,解决了安装时候各个软件的依赖问题。 我这使用的是centos7.6的系统和centos7.6镜像中的包【我下面的搭建环境是没有外网的,所以无需担心没有外网弄不了】 【使用啥系统和镜像无所谓,配置方式都一样】 [root@master ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@master ~]# [root@master ~]# ls | grep *iso CentOS-7.6-x86_64-DVD-1810.iso [root@master ~]# 服务端我服务端的ip为:192.168.59.142 [root@master ~]# ip a | grep 192 inet 192.168.59.142/24 brd 192.168.59.255 scope global noprefixroute ens33 inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 [root@master ~]# 关闭防火墙和selinux firewall的话,直接systemctl stop firewalld即可 如果使用的是iptables,则吧firewalld替换成iptables [root@master ~]# systemctl is-active firewalld active [root@master ~]# [root@master ~]# systemctl stop firewalld [root@master ~]# [root@master ~]# systemctl is-active firewalld inactive [root@master ~]# selinux关闭:setenforce 0 使用getenforce 查看结果为Disabled才行。 [root@master ~]# [root@master ~]# getenforce Disabled [root@master ~]# [root@master ~]# #setenforce 0 [root@master ~]# 配置http服务 我们需要安装http服务,所以我们需要先搭建一个本地源 下面我简单说下过程【照着我的做就行】,如果有不能理解的,去我博客中翻翻yum源的搭建,学习一下 #先创建一个文件用来挂载镜像 [root@master ~]# #mkdir /root/centos7.6 # 挂载镜像到刚才创建的那个文件 [root@master ~]# #mount CentOS-7.6-x86_64-DVD-1810.iso /root/centos7.6/ # 配置文件如下 [root@master ~]# cat /etc/yum.repos.d/centos.repo [cenot-7.6] name=cenots7.6 baseurl=file:///root/centos7.6 gpgcheck=0 enable=1 [root@master ~]# # 正常情况直接执行这个命令就可以看到镜像数量了,如果为0,则执行一下:yum clean all [root@master ~]# yum repolist Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Determining fastest mirrors repo id repo name status !cenot-7.6 cenots7.6 4,021 repolist: 4,021 [root@master ~]# 安装httpd服务 yum install -y httpd [root@master ~]# yum install -y httpd Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Loading mirror speeds from cached hostfile cenot-7.6 | 3.6 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed --> Processing Dependency: httpd-tools = 2.4.6-88.el7.centos for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-88.el7.centos will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.6-88.el7.centos cenot-7.6 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 cenot-7.6 103 k apr-util x86_64 1.5.2-6.el7 cenot-7.6 92 k httpd-tools x86_64 2.4.6-88.el7.centos cenot-7.6 90 k mailcap noarch 2.1.41-2.el7 cenot-7.6 31 k Transaction Summary ================================================================================ Install 1 Package (+4 Dependent packages) Total download size: 3.0 M Installed size: 10 M Downloading packages: -------------------------------------------------------------------------------- Total 33 MB/s | 3.0 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-3.el7_4.1.x86_64 1/5 Installing : apr-util-1.5.2-6.el7.x86_64 2/5 Installing : httpd-tools-2.4.6-88.el7.centos.x86_64 3/5 Installing : mailcap-2.1.41-2.el7.noarch 4/5 Installing : httpd-2.4.6-88.el7.centos.x86_64 5/5 Verifying : httpd-tools-2.4.6-88.el7.centos.x86_64 1/5 Verifying : apr-1.4.8-3.el7_4.1.x86_64 2/5 Verifying : mailcap-2.1.41-2.el7.noarch 3/5 Verifying : httpd-2.4.6-88.el7.centos.x86_64 4/5 Verifying : apr-util-1.5.2-6.el7.x86_64 5/5 Installed: httpd.x86_64 0:2.4.6-88.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-88.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete! [root@master ~]# 修改配置文件:/etc/httpd/conf/httpd.conf 我们httpd 中默认提供web 界面的位置是我们/var/www/html 目录,如果我们yum 源想指定目录,就需要修改2处内容 [root@master ~]# vim /etc/httpd/conf/httpd.conf # 下面是修改后的内容及行号 119 DocumentRoot "/usr/local" 131注:有2个directory,修改下面哪个 给/usr/local/yumrepo 配置权限,因为我们的httpd 的服务使用的是apache用户,该目录需要有普通用户的执行权限 [root@master yumrepo]# chmod -R 755 /usr/local/yumrepo/ [root@master yumrepo]# 测试正常情况,我们在本地浏览器上输入ip/yumrepo即可看到全部包的内容。 上面服务端中,从rpm安装包准备开始,新建不同目录【上面是mkdir /usr/local/yumrepo,那么继续创建如mkdir /usr/local/yumrepo2这样】 然后重复后面操作即可,在客户端中配置的话,也仅需要改变ip后面的路径就可以了~~~~~ 适用于: 1、我上面是centos7.6的镜像嘛,那么可以继续搭建centos7.9的包,因为rpm包能向下兼容,不能向上【至于一开始为什么不弄7.9,因为那时候池里镜像最高就是7.6,没换的主要原因,不确定7.9的rpm包,其他系统能不能兼容】2、下载网络源的rpm包,比如ceph的所有rpm包,放到这里做一个仓库源。 客户端任意能和服务端通信的主机均可配置,包括服务端自己也是可以配置该http源的。 yum文件配置如果是默认的yum源且没有外网可用,则进入到/etc/yum.repos.d/ 目录下创建一个备份的目录,将我们/etc/yum.repos.d/ 下的yum 源 mv移动到我们的新建的备份目录下 [root@master yum.repos.d]# pwd /etc/yum.repos.d [root@master yum.repos.d]# mkdir bak_docker [root@master yum.repos.d]# mv CentOS-* bak_docker/ [root@master yum.repos.d]# ls bak_docker因为这台是我的服务端,这个自带一个本地源文件的,然后我又新建了一个http源:http.repo [root@master yum.repos.d]# ls bak_docker centos.repo http.repo [root@master yum.repos.d]# # 这是本地源代码 [root@master yum.repos.d]# cat centos.repo [cenot-7.6] name=cenots7.6 baseurl=file:///root/centos7.6 gpgcheck=0 enable=1 [root@master yum.repos.d]# # 这就是http源,照着做就行,就修改ip即可,其他不要变 [root@master yum.repos.d]# cat http.repo [http] name=http enabled=1 gpgcheck=0 baseurl=http://192.168.59.142/yumrepo/ [root@master yum.repos.d]# 代码解释: name=http #我们yum 源命名enabled=1 #启用yum源,0为不启用,1为启用gkgcheck=0 #检查GPG-KEY,0为不检查,1为检查baseurl=http://192.168.59.142/yumrepo #是服务器设置中最重要的部分,只有设置正确,才能从上面获取软件 清除缓存并验证下面3个代码按顺序执行一遍 yum clean all #清除yum缓存yum makecache #缓存本地yum源中的软件包信息yum repolist #查看源软件包正常情况呢,就是执行yum repolist以后有我们定义的http源名称,且有相应的数量,如果数量为0,则哪个步骤出问题了,如下,我有本地源和http源,所以总共是8000多个。 [root@master yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Cleaning repos: cenot-7.6 http Cleaning up list of fastest mirrors Other repos take up 383 M of disk space (use --verbose for details) [root@master yum.repos.d]# yum makecache Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Determining fastest mirrors cenot-7.6 | 3.6 kB 00:00 http | 2.9 kB 00:00 (1/7): cenot-7.6/group_gz | 166 kB 00:00 (2/7): cenot-7.6/filelists_db | 3.2 MB 00:00 (3/7): cenot-7.6/other_db | 1.3 MB 00:00 (4/7): cenot-7.6/primary_db | 3.1 MB 00:00 (5/7): http/filelists_db | 3.2 MB 00:00 (6/7): http/primary_db | 3.1 MB 00:00 (7/7): http/other_db | 1.3 MB 00:00 Metadata Cache Created [root@master yum.repos.d]# [root@master yum.repos.d]# yum repolist Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, : subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Loading mirror speeds from cached hostfile repo id repo name status cenot-7.6 cenots7.6 4,021 http http 4,021 repolist: 8,042 [root@master yum.repos.d]# 完整流程上面呢我是在服务端本身上配置的一个http,不具有客观表现,所以,我下面在另外一台主机上配置http源 [root@etcd2 ~]# ping -c 2 192.168.59.142 PING 192.168.59.142 (192.168.59.142) 56(84) bytes of data. 64 bytes from 192.168.59.142: icmp_seq=1 ttl=64 time=1.46 ms 64 bytes from 192.168.59.142: icmp_seq=2 ttl=64 time=0.409 ms --- 192.168.59.142 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.409/0.938/1.467/0.529 ms [root@etcd2 ~]# [root@etcd2 ~]# cd /etc/yum.repos.d/ [root@etcd2 yum.repos.d]# ls CentOS-Base.repo docker-ce.repo epel.repo k8s.repo [root@etcd2 yum.repos.d]# mkdir bak_docker [root@etcd2 yum.repos.d]# mv * bak_docker/ mv: 无法将目录"bak_docker" 移动至自身的子目录"bak_docker/bak_docker" 下 [root@etcd2 yum.repos.d]# ls bak_docker [root@etcd2 yum.repos.d]# vim http.repo [root@etcd2 yum.repos.d]# cat http.repo [http] name=http enabled=1 gpgcheck=0 baseurl=http://192.168.59.142/yumrepo/ [root@etcd2 yum.repos.d]# [root@etcd2 yum.repos.d]# yum clean all 已加载插件:fastestmirror 正在清理软件源: http Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos [root@etcd2 yum.repos.d]# yum repolist 已加载插件:fastestmirror http | 2.9 kB 00:00 http/primary_db | 3.1 MB 00:00 Determining fastest mirrors 源标识 源名称 状态 http http 4,021 repolist: 4,021 [root@etcd2 yum.repos.d]# centos8或belinux8搭建http源yum仓库方法 上面的内容都是centos7的a !!!! 服务端搭建 注:我在http的目录下创建了一个目录packages8.2,然后在这个路径下又分别创建了2个目录,分别存放2个路径的包,我下面这样做,应该看得懂了吧? [root@yum-centos-oa packages8.2]# pwd /usr/local/packages8.2 [root@yum-centos-oa packages8.2]# ls packages82_App packages82_Base [root@yum-centos-oa packages8.2]# [root@yum-centos-oa packages8.2]# ls packages82_App/| wc -l 4848 [root@yum-centos-oa packages8.2]# [root@yum-centos-oa packages8.2]# ls packages82_Base/| wc -l 1442 [root@yum-centos-oa packages8.2]# [root@yum-centos-oa packages8.2]# ls /root/yum/AppStream/Packages/ | wc -l 4847 [root@yum-centos-oa packages8.2]# [root@yum-centos-oa packages8.2]# ls /root/yum/BaseOS/Packages/ | wc -l 1441 [root@yum-centos-oa packages8.2]# 搭建都一样,照着上面的做![]() ![]() ![]() |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |