yum源服务端配置工作
一、安装必要的软件
yum install -y wget make cmake gcc gcc-c++ &&\\yum install -y pcre-devel lib zlib-devel \\openssl openssl-devel createrepo yum-util
安装nginx ,一会需要对外提供http服务。
yum -y install nginx
二、创建索引
下一步将nginx的根目录配置为索引根目录/opt/yum/centos/7/os/。
mkdir /opt/yum/centos/7/os/x86_64/createrepo /opt/yum/centos/7/os/x86_64/
三、 nginx配置如下:
cat /etc/nginx/conf.d/yum.confserver {listen 9000 default_server;server_name _;root /opt/yum/centos/7/os/; ##这里# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {##这里autoindex on;autoindex_exact_size off;autoindex_localtime on;index index.html;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}
四、设置阿里云镜像为本地yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#yum repolist查看yum仓库标识
五、同步base源到自建的yum仓库地址
reposync -r base -p /opt/yum/centos/7/os/
同理,可以同步epel源到自建仓库目录
reposync -r epel -p /opt/yum/centos/7/os/
六、上述同步完成以后,更新仓库索引
createrepo --update /opt/yum/centos/7/os/base/createrepo --update /opt/yum/centos/7/os/epel/
此时yum源仓库配置完成。
客户端机器测试自建yum源
1.客户端服务器配置/etc/yum.repos.d目录的repo仓库
cp -rp /etc/yum.repos.d /etc/yum.repos.d.bakrm -rf /etc/yum.repos.d/*#新建编辑base和epel的仓库文件#cat smcaiot-base.repo[smcaiot-base]name=centos-basebaseurl=http://192.168.101.21:9000/base/enabled=1gpgcheck=0#cat smcaiot-epel.repo[smcaiot-epel]name=smcaiot-epelbaseurl=http://192.168.101.21:9000/epel/enabled=1gpgcheck=0
2.清理缓存
yum clean all && yum makecache
3.测试yum安装,比如 yum -y install htop 发现安装速度还是比较快的。