centos 7.6——远程部署yum源

远程部署yum源


**

1. yum 查询软件包

yum list
yum info 软件名
yum search 关键字
yum whatprovides 关键字

2. yum 的配置文件

基本设置 : /etc/yum.conf
仓库设置: /etc/yum.repos.d/*.repo
日志文件: /var/log/yum.log

3. 查询软件包组

yum grouplist [包组名]
yum groupinfo [包组名] 查询包组信息
案例
yum grouplist gnome-desktop //桌面安装
yum groupinfo gnome-desktop

4. 软件卸载

yum remove [软件名]
yum groupremove [包组名]

案例

yum -y remove autofs
yum -y groupremove gnome-desktop

centos 7.6——远程部署yum源

实验描述

** (1) 服务端**

  1. 挂载光盘
  2. 安装vsftpd 服务
  3. 新建yum仓库
    新建目录centos7将之前的yum安装包强制复制到centos7目录中
    新建软件包索引other目录
    新建other目录 createrepo -g /mnt/repodata/repomd.xml other/
  4. 目录centos7和other放在/var/ftp/目录下
  • yum update 更新软件包,更新软件和系统内核
  • yum upgrade 只更新软件包 (服务端更新)
    (2)客户端
  1. 安装ftp服务,为了客户端和服务端建立连接和传输远程yum源仓库的安装包。
  2. 验证ftp192.168.75.134连接服务端匿名登录。
  3. 切换到yum.repos.d目录下,将yum安装包移到新建的目录bak中。
  4. vim centos7.repo 输入配置文件。指定服务端。和other软件包索引支持客户端ftp连接yum源仓库。进行远程安装服务端提供的软件包。
  5. 安装httpd服务验证ftp远程部署yum源成功。

实验步骤

一、服务端配置

在这里插入图片描述

[root@localhost ~]# mount /dev/sr0 /mnt  //挂载光盘
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -Th
文件系统       类型      容量  已用  可用 已用% 挂载点
/dev/sda3      xfs       182G  4.0G  178G    3% /
devtmpfs       devtmpfs  2.0G     0  2.0G    0% /dev
tmpfs          tmpfs     2.0G     0  2.0G    0% /dev/shm
tmpfs          tmpfs     2.0G   11M  2.0G    1% /run
tmpfs          tmpfs     2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/sda1      xfs      1014M  174M  841M   18% /boot
tmpfs          tmpfs     406M   64K  406M    1% /run/user/1000
tmpfs          tmpfs     406M     0  406M    0% /run/user/0
/dev/sr0       iso9660   4.3G  4.3G     0  100% /mnt
[root@localhost ~]# yum install -y vsftpd //安装ftp服务用于建立远程站点
[root@localhost ftp]# pwd
/var/ftp
[root@localhost ftp]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月   1 12:55 pub
[root@localhost ftp]# 
[root@localhost ftp]# mkdir centos7   //创建目录centos7放rpm安装包
[root@localhost ftp]# ls  
centos7  pub
[root@localhost ftp]# ls centos7/
[root@localhost ftp]# cp -rf /mnt/* centos7/ &  //复制yum安装包到centos7 目录中
[1] 20035
[root@localhost ftp]# jobs 
[1]+  运行中               cp -i -rf /mnt/* centos7/ &
[root@localhost ftp]# ll
总用量 0
drwxr-xr-x. 8 root root 220 7月  11 15:12 centos7
drwxr-xr-x. 2 root root   6 7月  11 15:15 other
drwxr-xr-x. 2 root root   6 4月   1 12:55 pub
[root@localhost ftp]# createrepo -g /mnt/repodata/repomd.xml other/    部署软件包索引
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost ftp]# cd centos7/
[root@localhost centos7]# ll
总用量 320
-rw-r--r--. 1 root root     14 7月  11 15:12 CentOS_BuildTag
drwxr-xr-x. 3 root root     35 7月  11 15:12 EFI
-rw-r--r--. 1 root root    227 7月  11 15:12 EULA
-rw-r--r--. 1 root root  18009 7月  11 15:12 GPL
drwxr-xr-x. 3 root root     57 7月  11 15:12 images
drwxr-xr-x. 2 root root    198 7月  11 15:12 isolinux
drwxr-xr-x. 2 root root     43 7月  11 15:12 LiveOS
drwxr-xr-x. 2 root root 221184 7月  11 15:12 Packages
drwxr-xr-x. 2 root root   4096 7月  11 15:12 repodata
-rw-r--r--. 1 root root   1690 7月  11 15:12 RPM-GPG-KEY-CentOS-7
-rw-r--r--. 1 root root   1690 7月  11 15:12 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root   2883 7月  11 15:12 TRANS.TBL
[root@localhost centos7]# jobs
[root@localhost centos7]# cd ../other/
[root@localhost other]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 7月  11 15:15 repodata
[root@localhost other]# cat repodata/
cat: repodata/: 是一个目录
[root@localhost other]# cd repodata/
[root@localhost repodata]# ls
01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2
12bbefc88e08f473cf860b4c150a9a8627f68eb256c9d54b80940e5dc224e85c-repomd.xml.gz
401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2
6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
cdcb85c0e4daf1675d1ab6c42b0cacc6f9460d938296f7bf52678514a86a0554-repomd.xml
dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
repomd.xml
[root@localhost repodata]# cd ~
[root@localhost ~]# systemctl start vsftpd  //重启vsftp服务
[root@localhost ~]# netstat -ntap | grep 21  //21端口负责连接FTP服务
tcp6       0      0 :::21                   :::*                    LISTEN      20110/vsftpd        
[root@localhost ~]# netstat -ntap | grep 20   //20端口负责传输FTP数据
tcp6       0      0 :::21                   :::*                    LISTEN      20110/vsftpd        
[root@localhost ~]# systemctl stop firewalld  //关闭防火墙
[root@localhost ~]# setenforce 0  //关闭核心防护
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

二、客户端配置

[root@localhost /]# yum -y install ftp  //安装FTP服务
[root@localhost /]# ftp 192.168.75.134   //验证客户机连接服务端匿名登录
Connected to 192.168.75.134 (192.168.75.134).
220 (vsFTPd 3.0.2)
Name (192.168.75.134:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> bye
221 Goodbye.
[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost mnt]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/    将yum配置文件移到bak目录下
[root@localhost yum.repos.d]# ll
总用量 4
drwxr-xr-x. 2 root root 187 7月  11 15:33 bak
[root@localhost yum.repos.d]#vim centos7.repo  //修改yum仓库
[root@localhost yum.repos.d]yum clean all //清理缓存

密钥是在服务端的centos7文件
在这里插入图片描述

三、尝试安装httpd 服务验证是否搭建FTP远程yum源成功

[root@localhost yum.repos.d]# yum install httpd -y
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
base                                                                        | 3.6 kB  00:00:00     
other                                                                       | 3.6 kB  00:00:00     
(1/4): base/group_gz                                                        | 166 kB  00:00:00     
(2/4): other/group_gz                                                       | 1.1 kB  00:00:00     
(3/4): other/primary_db                                                     | 1.1 kB  00:00:00     
(4/4): base/primary_db                                                      | 3.1 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-88.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-88.el7.centos,它被软件包 httpd-2.4.6-88.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-88.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-88.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===================================================================================================
 Package                 架构               版本                            源                大小
===================================================================================================
正在安装:
 httpd                   x86_64             2.4.6-88.el7.centos             base             2.7 M
为依赖而安装:
 httpd-tools             x86_64             2.4.6-88.el7.centos             base              90 k
 mailcap                 noarch             2.1.41-2.el7                    base              31 k

事务概要
===================================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:2.8 M
安装大小:9.6 M
Downloading packages:
(1/3): httpd-tools-2.4.6-88.el7.centos.x86_64.rpm                           |  90 kB  00:00:00     
(2/3): mailcap-2.1.41-2.el7.noarch.rpm                                      |  31 kB  00:00:00     
(3/3): httpd-2.4.6-88.el7.centos.x86_64.rpm                                 | 2.7 MB  00:00:00     
---------------------------------------------------------------------------------------------------
总计                                                                19 MB/s | 2.8 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : mailcap-2.1.41-2.el7.noarch                                                    1/3 
  正在安装    : httpd-tools-2.4.6-88.el7.centos.x86_64                                         2/3 
  正在安装    : httpd-2.4.6-88.el7.centos.x86_64                                               3/3 
  验证中      : httpd-tools-2.4.6-88.el7.centos.x86_64                                         1/3 
  验证中      : mailcap-2.1.41-2.el7.noarch                                                    2/3 
  验证中      : httpd-2.4.6-88.el7.centos.x86_64                                               3/3 

已安装:
  httpd.x86_64 0:2.4.6-88.el7.centos                                                               

作为依赖被安装:
  httpd-tools.x86_64 0:2.4.6-88.el7.centos              mailcap.noarch 0:2.1.41-2.el7             

完毕!
[root@localhost yum.repos.d]# 

注意

  • yum update 更新软件包,更新软件和系统内核
  • yum upgrade 只更新软件包 (服务端更新)

猜你喜欢

转载自blog.csdn.net/weixin_42099301/article/details/107285060