码迷,mamicode.com
首页 > 其他好文 > 详细

Centos 7建立本地内网源

时间:2021-04-27 14:52:02      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:epel源配置   core   list   epel   rgb   redhat   com   权限   ast   

原文地址:

https://blog.csdn.net/oToyix/article/details/106170701

 

repo的路径不要放到root下,放到/usr/share/nginx/下,要不没权限

 

Centos 7建立本地内网源
一、环境
二、先配置163base源及阿里epel源
三、建立本地仓库localbase、localepel
四、通过nginx将发布源站
五、客户端使用192.168.1.111的base及epel源

建立一台YUM源服务器,同步163base源及阿里epel源,通过nginx发布出去,为企业PC提供yum服务。
一、环境
服务端:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# ifconfig|grep inet
inet 192.168.1.111 netmask 255.255.255.0 broadcast 192.168.1.255

1
2
3
4
5
客户端PC:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# ifconfig|grep inet
inet 192.168.1.107 netmask 255.255.255.0 broadcast 192.168.1.255

1
2
3
4
5
二、先配置163base源及阿里epel源
安装yum支持环境

[root@localhost ~]# yum install createrepo yum-utils –y
1
备份base源文件

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo{,.bakup}
1
下载reop文件

163base源
[root@localhost ~]# wget -P /etc/yum.repos.d/ http://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里epel源
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

1
2
3
4
5
清缓存

[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache

1
2
3
查看源列表

[root@localhost ~]# yum repolist
1


三、建立本地仓库localbase、localepel
新建仓库目录localbase、localepel

[root@localhost ~]# mkdir -p /data/localrepo/localbase
[root@localhost ~]# mkdir -p /data/localrepo/localepel

1
2
3
同步base源

[root@localhost ~]# reposync -r base -p /data/localrepo/localbase
1
同步epel源

[root@localhost ~]# reposync -r epel -p /data/localrepo/localepel
1
创建仓库repodata目录,每次有新包都得运行此命令加载一次

base
[root@localhost ~]# createrepo /data/localrepo/localbase
Spawning worker 0 with 5035 pkgs
Spawning worker 1 with 5035 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

epel
[root@localhost ~]# createrepo /data/localrepo/localepel/
Spawning worker 0 with 6635 pkgs
Spawning worker 1 with 6634 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
下载base源gpgkey文件(epel gpgkey文件不用下载)

保存至/data/localrepo/localbase/
[root@localhost~]#wget -P /data/localrepo/localbase/ http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
1
2
备份base与epel源配置文件

[root@localhost ~]# mv /etc/yum.repos.d/CentOS7-Base-163.repo{,.bakup}
[root@localhost ~]# mv /etc/yum.repos.d/epel.repo{,.bakup}

1
2
3
新建base与epel本地源配置文件

[root@localhost ~]# vim /etc/yum.repos.d/localbase.repo
[base]
name=centos7 local base_163
baseurl=file:///data/localrepo/localbase/
gpgcheck=1
gpgkey=file:///data/localrepo/localbase/RPM-GPG-KEY-CentOS-7

1
2
3
4
5
6
7
[root@localhost ~]# vim /etc/yum.repos.d/localepel.repo
[epel]
name=centos7 local epel
baseurl=file:///data/localrepo/localepel/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

1
2
3
4
5
6
7
清缓存

[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache

1
2
3
查看仓库列表yum repolist


四、通过nginx将发布源站
安装nginx

[root@localhost ~]# yum install nginx -y
1
编译nginx配置文件

[root@localhost ~]# vim /etc/nginx/nginx.conf
42 autoindex on; #开启目录访问功能
43 root /data/localrepo; #路径
1
2
3
[root@localhost ~]# systemctl restart nginx 启动nginx
[root@localhost ~]# systemctl stop firewalld 临时关闭防火墙,也可以开启端口,这里就不说明了
[root@localhost ~]# setenforce 0 关闭selinux
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled

1
2
3
4
5
6
打开浏览器输入IP即可

可以看到base与epel源,点击进入,里面也有文件,与163官网类似


五、客户端使用192.168.1.111的base及epel源
[root@localhost ~]# vim /etc/yum.repos.d/localbase.repo
[base]
name=centos7 local base_163
baseurl=http://192.168.1.111/localbase/
gpgcheck=1
gpgkey=http://192.168.1.111/localbase/RPM-GPG-KEY-CentOS-7

1
2
3
4
5
6
7
[root@localhost ~]# vim /etc/yum.repos.d/localepel.repo
[epel]
name=centos7 local repo
baseurl=http://192.168.1.111/localepel/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

1
2
3
4
5
6
7
#也可以使用yum-config-manager来添加

[root@localhost ~]# yum-config-manager --add-repo=http://192.168.1.111/localbase/
1
将旧的base改名备份

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo{,.bakup}
1
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
base centos7 local base_163 10,070
epel centos7 local repo 13,269
repolist: 23,339

1
2
3
4
5
6
7
8
9
10

 


------------------end
————————————————
版权声明:本文为CSDN博主「归$兮」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/oToyix/article/details/106170701

Centos 7建立本地内网源

标签:epel源配置   core   list   epel   rgb   redhat   com   权限   ast   

原文地址:https://www.cnblogs.com/wangmo/p/14705732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!