文章目录
1.yum 基本命令
yum命令必须在有yum源的环境下使用!
命令 | 作用 |
---|---|
yum clean all | 清除所有yum缓存数据 |
yum repolist | 列出所有仓库 |
yum install software | 安装软件 |
yum updte | 更新 |
yum list software | 查看软件 |
yum list(all) | 查看所有软件 |
yum list installed | 显示已安装的软件 |
yum list available | 列出可安装软件 |
yum reinstall software | 重新安装 |
yum remove software | 卸载软件 |
yum info software | 查看软件信息 |
yum search software信息 | 根据软件信息查找软件 |
yum whatprovides file | 根据文件找出包含文件的软件 |
yum history | 查看系统中软件管理信息 |
yum history info 数字 | 对该数字为id的信息进行显示 |
yum groups list | 列出软件组 |
yum groups info | 查看软件组的信息 |
yum groups install sfgroup | 安装软件组 |
yum groups remove sfgroup | 卸载软件组 |
2.镜像yum源搭建(以dhcp安装为例)
(1)创建一个新的目录专门用于iso设备挂载(挂载就相当于将u盘设备插到电脑上,将设备中的内容读出来,成为可读文件)
eg: mkdir /rhel7.3_dhcp
建议将镜像安装包也单独存放在根目录下的某一空文件
(2)mount 【iso设备路径】 【新目录绝对路径】 挂载设备 临时
eg: mount /iso/rhel-server-7.3-x86_64-dvd.iso /rhel7.3_dhcp
(3)本地软件仓库的搭建(yum源搭建) 必须在仓库文件 /etc/yum.repos.d这个目录下且/etc/yum.repos.d中只能有生效的repo文件,如果repo文件无效需移走 ,否则yum不能正常使用。任意命名但后缀必须为.repos xxx.repos
eg: vim /etc/yum.repos.d/dhcp.repos
(4)在文件中编辑仓库路径等信息
模板:
[xxx]##仓库id
name=xxx##仓库名 任意命名
baseurl=file://挂载绝对路径 ##file// 访问方式
gpgcheck=0 ##验证标识 0 不用检验是否为官方厂家软件直接安装 1 会检验软件是否为官方软件 如果不是 系统不会允许你装 一般都为0 直接安装不检验
eg:
[rhel7.3]
name=rhel7.3
basecheck=file:///rhel7.3_dhcp
gpgcheck=0
(5)yum install dhcp
安装dhcp
3.用脚本搭建镜像yum源
mkdir /rhel7.3
mount /iso/rhel-server-7.3-x86_64-dvd.iso /rhel7.3_dhcp
cd /etc/yum.repos.d/
mv * /mnt
mkdir /etc/yum.repos.d/dhcp.repos
cat >>/etc/yum.repos.d/westos.repo <<EOF
[westos]
name=westos
baseurl=file:///rhel7.3
gpgcheck=0
EOF
4. 网络yum源的搭建(yum源共享 虚拟机在没有镜像安装包时如何安装dhcp)
服务器(ip:172.25.254.1):
(1)yum install httpd
安装httpd服务(httpd服务对外提供超文本协议,实现资源共享)
安装httpd服务之后系统会生成/var/www/html文件 只有安装后此文件才存在
systemctl start httpd 打开httpd资源共享服务
systemctl enable httpd
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 设置火墙开机时不自动开启
systemctl mask firewalld 锁定防火墙
(2)
mkdir /var/www/html/rhel7.3
mount /iso/rhel-server-7.3-x86_64-dvd.iso /var/www/html/rhel7.3
(3)客户机(测试):
前提:客户机与服务器在同一网络下,能相互通信 (客户机ip:172.25.254.101)
1)在浏览器中输入地址:http://172.25.254.1/rhel7.3
如果能看到文件内容,则表明资源共享成功
2)创建指向文件
vim /etc/yum.repos.d/westos
指向内容:
[westos]
name=westos
baseurl=http://172.25.254.1/rhel7.3
gpgcheck=0
yum install dhcp -y
5.yum源的永久挂载
vim /etc/rc.d/rc.local
mount /... /...
chmod +x /etc/rc.d/rc.local 为文件添加执行权限让系统能够执行此文件
重启系统 挂载依旧存在
/etc/rc.d/rc.local 系统开机会自动执行此文件中的命令 实现永久挂载