温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

本地服务器搭建yum源 镜像163yum源

发布时间:2020-06-13 15:30:19 来源:网络 阅读:310 作者:tomshen 栏目:系统运维

关闭防火墙,关闭SElinux

本地服务器搭建yum源 镜像163yum源
该实验仅实现在本地服务商搭建yum源,可以使其他服务器作为客户端可以通过yum命令安装程序包,但无法安装包组
各位大神如有可实现搭建本地yum源并且,能实现包组功能的资料,欢迎指正,本人QQ:×××

实验环境:
一台HP DL380 G7 服务器,300G硬盘,RHEL7.0 64位操作系统 IP地址:10.49.128.96
需要提前安装的程序包:
yum-utils (包含reposync命令)
createrepo 编辑yum库工具
nginx 或httpd

删除/etc/yum.repos.d/下的原有.repo文件
touch rhel-debuginfo.repo
编辑rhel-debuginfo.repo 输入以下内容:

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/7/extras//$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/7/centosplus//$basearch/
gpgcheck=1
enabled=0

刷新缓存:
yum clean all
yum makecache

yum install epel-release -y
yum install yum-utils createrepo -y
yum install nginx -y 或者yum install httpd -y

yum repolist

建立rpm库存放目录:
mkdir -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
开始同步下载rpm包:
reposync --repoid=base -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=extras -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=updates -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=epel -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/

( 使用--repoid 选项会镜像相应程序包,并创建与--repoid=xx 指定值 同名的文件夹)

创建索引:( createrepo -po 源目录 索引元数据的输出位置目录)
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/base/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/extras/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/updates/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/epel/Packages

设置http服务的根目录:

方案一:使用nginx提供http服务;

server {
listen 80;
server_name localhost;
root /home/benddijingxiangyuan;
#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
}

方案二:使用httpd(apache)提供http服务:

注释/etc/httpd/conf/httpd.conf文件中的 DocumentRoot "/var/www/html" 这行

创建目录/var/log/httpd/bengdiyumyuam/
在/var/log/httpd/bengdiyumyuam/中创建文件,yum_access_log和yum_error_log

在/etc/httpd/conf.d中创建文件Bendiyumyuan.conf,内容如下:

<VirtualHost 10.49.128.96:80>
ServerName localhost
DocumentRoot "/home/benddijingxiangyuan/wangyi163/CentOS/7/64bit"
CustomLog /var/log/httpd/bengdiyumyuam/yum_access_log combined
ErrorLog /var/log/httpd/bengdiyumyuam/yum_error_log
LogLevel warn

<Directory "/home/benddijingxiangyuan/wangyi163/CentOS/7/64bit">
Options Indexes
AllowOverride None
Require all granted
</Directory>

</VirtualHost>

在客户端服务器/etc/yum.repos.d/下创建local.repo文件,内容如下:

[base]
name=local-Base(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/base/Packages
enabled=1
gpgcheck=0

[updates]
name=local-Updates(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/updates/Packages
enabled=1
gpgcheck=0

[extras]
name=local-Extras(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/extras/Packages
enabled=1
gpgcheck=0

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI