Linux 部署 YUM 仓库
程序员文章站
2022-05-03 13:22:02
本篇主要写了怎么搭建自定义的 YUM 源,在一个拥有大量本地网络的主机环境中,可以减少对外网的依赖。 ......
本篇主要写了怎么搭建自定义的yum
源,在一个拥有大量本地网络的主机环境中,可以减少对外网的依赖。
server
安装 vsftp 包
[root@server ~]# yum install vsftpd -y
添加相关资源包
- 创建需要存放的目录
[root@server ~]# mkdir /var/ftp/centos7 /var/ftp/others [root@server ~]# ls /var/ftp/ centos7 others pub
- 拷贝镜像文件内容至相关目录
[root@server ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@server ~]# cp -r /mnt/* /var/ftp/centos7/
- 给
others
目录创建repodata
[root@server ~]# createrepo -g /var/ftp/centos7/repodata/repomd.xml /var/ftp/others/ saving primary metadata saving file lists metadata saving other metadata generating sqlite dbs sqlite dbs complete
- 检查文件是否齐全
[root@server ~]# ls /var/ftp/centos7/ centos_buildtag efi eula gpl images isolinux liveos packages repodata rpm-gpg-key-centos-7 rpm-gpg-key-centos-testing-7 trans.tbl
[root@server ~]# ls /var/ftp/others/ repodata
开启服务
[root@server ~]# systemctl enable vsftpd created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service. [root@server ~]# systemctl start vsftpd [root@server ~]# netstat -ntuap | grep vsftpd tcp6 0 0 :::21 :::* listen 35971/vsftpd
关闭防火墙
[root@server ~]# systemctl stop firewalld [root@server ~]# setenforce 0
client
安装 ftp 包
[root@client ~]# yum install ftp -y
匿名登录查看
[root@client ~]# ftp 192.168.28.128 connected to 192.168.28.128 (192.168.28.128). 220 (vsftpd 3.0.2) name (192.168.28.128:root): ftp 331 please specify the password. password: 230 login successful. remote system type is unix. using binary mode to transfer files. ftp> ls 227 entering passive mode (192,168,28,128,255,56). 150 here comes the directory listing. drwxr-xr-x 8 0 0 2048 sep 05 2017 centos7 drwxr-xr-x 3 0 0 22 sep 16 19:42 others drwxr-xr-x 2 0 0 6 oct 30 2018 pub 226 directory send ok. ftp> bye 221 goodbye.
编辑 yum 源配置文件
- 备份已有
yum
源
[root@client ~]# cd /etc/yum.repos.d/ [root@client yum.repos.d]# mkdir bak [root@client yum.repos.d]# mv *.repo bak/
- 编辑自定义
yum
源
[root@client yum.repos.d]# vim ftp.repo [base] name=centos7.packages baseurl=ftp://192.168.28.128/centos7/ enabled=1 gpgcheck=1 gpgkey=ftp://192.168.28.128/centos7/rpm-gpg-key-centos-7 [others] name=others.packages baseurl=ftp://192.168.28.128/others/ enabled=1 gpgcheck=0
查看结果
[root@client ~]# yum clean all loaded plugins: fastestmirror cleaning repos: base others cleaning up everything maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos cleaning up list of fastest mirrors [root@client ~]# yum list
上一篇: 可以蒸的菜有哪些,蒸这种方式的好处
下一篇: Linux DHCP 中继
推荐阅读