自制yum倉(cāng)庫(kù)
[TOC]
yum倉(cāng)庫(kù)配置文件
# 倉(cāng)庫(kù)名
[base]
# 倉(cāng)庫(kù)描述
name=CentOS-$releasever - Base - mirrors.aliyun.com
# 倉(cāng)庫(kù)地址
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
# 檢測(cè)簽名機(jī)制(1:開啟檢測(cè) 0:關(guān)閉檢測(cè))
gpgcheck=1
# 簽名機(jī)制秘鑰地址
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
yum倉(cāng)庫(kù)類型
# 1.遠(yuǎn)程倉(cāng)庫(kù)
http:// ? 端口:80
https:// ? 端口:443
ftp:// ? ? 端口:21
# 2.本地倉(cāng)庫(kù)
file:// ? 沒有端口(本地協(xié)議)
# 協(xié)議:http:// https:// ftp:// file://
http:// ? 端口:80
https:// ? 端口:443
ftp:// ? ? 端口:21
file:// ? 沒有端口(本地協(xié)議)
本地yum倉(cāng)庫(kù)(file://)
# 先決條件
1)創(chuàng)建倉(cāng)庫(kù)的命令
- createrepo
2)還要有rpm包
- 網(wǎng)站獲取
- 鏡像獲取
- yum源獲取
3)yum源的配置文件
# 1.安裝創(chuàng)建倉(cāng)庫(kù)的命令
[root@localhost <sub>]# yum install -y createrepo
# 2.通過(guò)鏡像,獲取rpm包
# 1)掛載鏡像
[root@localhost </sub>]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
# 2)創(chuàng)建一個(gè)倉(cāng)庫(kù)目錄
[root@localhost <sub>]# mkdir /local_yum_repo
# 3)拷貝rpm包到倉(cāng)庫(kù)目錄中
[root@localhost </sub>]# cp /mnt/Packages/*.rpm /local_yum_repo/
# 4)先把倉(cāng)庫(kù)變成目錄
[root@localhost <sub>]# createrepo /local_yum_repo/
Spawning worker 0 with 4070 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
# 5)檢查是否把目錄變成了倉(cāng)庫(kù)
[root@localhost </sub>]# ll -d /local_yum_repo/
drwxr-xr-x. 3 root root 225280 Apr 25 17:28 /local_yum_repo/
# 6)壓縮其他yum源
[root@localhost <sub>]# gzip -r /etc/yum.repos.d/
# 7)手寫yum源配置文件(必須以repo結(jié)尾)
# 倉(cāng)庫(kù)名
[zxw_local]
# 倉(cāng)庫(kù)描述
name=Local Pepository By zxw
# 倉(cāng)庫(kù)地址
baseurl=file:///local_yum_repo
#關(guān)閉簽名檢測(cè)機(jī)制
gpgcheck=0
#開啟倉(cāng)庫(kù)
enabled=1
# 8)使用yum源
[root@localhost </sub>]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
zxw_local Local Pepository By zxw enabled: 4,070
repolist: 4,070
遠(yuǎn)程yum倉(cāng)庫(kù)
# 1.先決條件
1)創(chuàng)建倉(cāng)庫(kù)的命令
- createrepo
2)還要有rpm包
- 網(wǎng)站獲取
- 鏡像獲取
- yum源獲取
3)yum源的配置文件
# 1.安裝創(chuàng)建倉(cāng)庫(kù)的命令
[root@localhost <sub>]# yum install -y createrepo
# 2.通過(guò)鏡像,獲取rpm包
## 1)掛載鏡像
[root@localhost </sub>]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
## 2)安裝安裝vsftpd服務(wù)
[root@localhost <sub>]# yum install -y vsftpd
## 3)啟動(dòng)服務(wù)
[root@localhost </sub>]# systemctl start vsftpd
## 4)檢查端口
如果沒有命令net-tools就安裝一個(gè)
[root@localhost <sub>]# yum install -y net-tools
[root@localhost </sub>]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 941/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1107/master
tcp6 0 0 :::21 :::* LISTEN 11416/vsftpd
tcp6 0 0 :::22 :::* LISTEN 941/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1107/master
[root@localhost <sub>]# netstat -lntup|grep vsftpd
tcp6 0 0 :::21 :::* LISTEN 11416/vsftpd
## 5)打開瀏覽器訪問:ftp://10.0.0.105
ftp://ID
## 6)關(guān)閉防火墻
[root@localhost </sub>]# systemctl stop firewalld
[root@localhost <sub>]# setenforce 0
## 7)創(chuàng)建倉(cāng)庫(kù)目錄
[root@localhost </sub>]# mkdir /var/ftp/pub/{base,epel}
[root@localhost <sub>]# ll /var/ftp/pub/
total 0
drwxr-xr-x. 2 root root 6 Apr 25 18:27 base
drwxr-xr-x. 2 root root 6 Apr 25 18:27 epel
## 8)拷貝rpm包到base目錄下(我就隨便弄了倆,這里只是示范)
[root@localhost pub]# cp /mnt/Packages/zip-3.0-11.el7.x86_64.rpm ./base/
[root@localhost pub]# cp /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm ./base/
[root@localhost pub]# ll base/
total 308
-rw-r--r--. 1 root root 47508 Apr 25 18:42 tree-1.6.0-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 266160 Apr 25 18:38 zip-3.0-11.el7.x86_64.rpm
## 9)下載rpm包到epel源
[root@localhost pub]# cd epel/
[root@localhost epel]# wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/h/hdf5-1.8.12-13.el7.x86_64.rpm
[root@localhost epel]# ll
total 1644
-rw-r--r--. 1 root root 1682124 Sep 16 2021 hdf5-1.8.12-13.el7.x86_64.rpm
## 10)分別把這兩個(gè)目錄做成倉(cāng)庫(kù)
[root@localhost </sub>]# createrepo /var/ftp/pub/base/
Spawning worker 0 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost <sub>]# createrepo /var/ftp/pub/epel/
Spawning worker 0 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost </sub>]# ll /var/ftp/pub/base/
total 312
drwxr-xr-x. 2 root root 4096 Apr 25 19:16 repodata
-rw-r--r--. 1 root root 47508 Apr 25 18:42 tree-1.6.0-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 266160 Apr 25 18:38 zip-3.0-11.el7.x86_64.rpm
[root@localhost <sub>]# ll /var/ftp/pub/epel/
total 1648
-rw-r--r--. 1 root root 1682124 Sep 16 2021 hdf5-1.8.12-13.el7.x86_64.rpm
drwxr-xr-x. 2 root root 4096 Apr 25 19:17 repodata
## 11)在其他機(jī)器上手寫repo配置文件
[root@zxw </sub>]# vim /etc/yum.repos.d/base_epel.repo
[zxw_base]
name=wode base cangku
baseurl=ftp://10.0.0.105/pub/base/
gpgcheck=0
enabled=1
[zxw_epel]
name=wode epel cangku
baseurl=ftp://10.0.0.105/pub/epel
gpgcheck=0
enabled=1
# 12)檢查yum倉(cāng)庫(kù)
[root@zxw <sub>]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
zxw_base wode base cangku 2
zxw_epel wode epel cangku 1
repolist: 3
# 13)使用yum安裝
[root@zxw </sub>]# yum install -y tree
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
tree x86_64 1.6.0-10.el7 zxw_base 46 k
Transaction Summary
========================================================================================
Install 1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tree-1.6.0-10.el7.x86_64 1/1
Verifying : tree-1.6.0-10.el7.x86_64 1/1
Installed:
tree.x86_64 0:1.6.0-10.el7
Complete!
[root@zxw ~]# tree
.
├── 1.TXT
└── 2.TXT
0 directories, 2 files
本文摘自 :https://blog.51cto.com/u