搭建yum源
實現目標
操作系統:CentOS 7
準備兩臺機器server 和 agent,
在server上搭建yum源 ,agent指向server yum源,實現包安裝
在Server搭建yum倉庫
- createrepo:用於創建yum源
- yum-plugin-priorities:用於設置yum源的優先級
- nginx
yum install -y createrepo
yum install -y yum-plugin-priorities
創建倉庫文件夾,將rpm包放到這裏
cd /home
mkdir rpm-repo
cd rpm-repo
createrepo ./
配置nginx,開啓文件可見
訪問地址: http://100.100.100.100
*
*
root: /home/rpm-repo/;
location / {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
如果訪問403,給下權限,訪問如下:
準備數據
rpm包在阿里鏡像拉取 :https://mirrors.aliyun.com/centos/7/isos/x86_64/
- 下載iso包
wget https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1810.iso
- 用7zip解壓
將Packages裏面的內容移到/home/rpm-repo
mv Packages/* /home/rpm-repo
- 生成repo
cd /home/rpm-repo
createrepo ./
在agent創建yum源文件和安裝測試
現將/etc/yum.repos.d/裏面的文件打包備份
創建local.repo
vi /etc/yum.repos.d/local.repo
寫入如下內容到文件
[tools]
name=tools
baseurl=http://100.100.100.100
enabled=1
gpgcheck=0
priority=1
baseurl 對應server 訪問地址
priority 優先級,越小優先級越高
yum安裝測試:
yum clean all
yum makecache
yum install wget
Notes:
倉庫新放入rpm包之後一定要執行createrepo ./
agent端執行 yum clean all 和yum makecache