背景:內網環境服務器不能直接安裝工具或服務,可以用一臺外網服務器同步阿里云的yum倉庫,作為本地倉庫
搭建本地yum倉庫
編輯yum組態檔,開啟快取使用功能,設定快取路徑
cp /etc/yum.conf /etc/yum.conf.bak
vim /etc/yum.conf
cachedir=/yum/$basearch/$releasever
keepcache=1
安裝創建yum源索引工具
yum -y install createrepo
創建yum源索引,索引路徑即安裝包檔案路徑
createrepo -v /yum
配置nginx,發布yum倉庫
vim /usr/local/nginx/conf/conf.d/yumrepo.conf
server {
listen 8090;
server_name 10.252.90.40;
location / {
root /data/yum/epel/;
autoindex on; ##開 啟 目 錄
index index.html index.htm;
}
}
同步阿里云yum源,每周更新
[root@node40 ~]# crontab -l
0 3 * * 1 /bin/bash /root/yum_repo_update.sh
[root@node40 ~]# cat /root/yum_repo_update.sh
#!/bin/bash
echo 'Updating Aliyum Source'
DATETIME=`date +%Y-%m-%d`
exec > /var/log/aliyumrepo_$DATETIME.log
reposync -np /yum/
if [ $? -eq 0 ];then
createrepo --update /yum/base
createrepo --update /yum/extras
createrepo --update /yum/updates
createrepo --update /yum/epel
echo "SUCESS: $DATETIME aliyum_yum update successful" >>/var/log/aliyumrepo_$DATETIME.log
else
echo "ERROR: $DATETIME aliyum_yum update failed" >> /var/log/aliyumrepo_$DATETIME.log
fi
客戶端配置
編輯yum源地址
[root@node40 ~]# mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/
[root@node40 ~]# vim /etc/yum.repos.d/local.repo
[local]
name=Server
baseurl=http://10.252.90.40:8090/
enable=1
gpgcheck=0
重繪yum快取,使yum源生效
[root@node40 ~]# yum clean all && yum makecache fast
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/534036.html
標籤:Linux
