一、使用网络安装资源安装软件
vim /etc/yum.repos.d/yum.repo ##文件名称必须以repo结尾
yum.repo文件的内容:
[rhel7.2] ##仓库名称
name=rhel7.2 source ##对软件源的描述
baseurl=http://172.25.254.250/rhel7.2/x86_64/dvd ##网络安装源
gpgcheck=0 ##不检测gpgkey状态
enabled ##此安装源语句生效
yum repolist ##列出仓库信息
示例:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim zhao.repo
[root@software_install yum.repos.d]# cat zhao.repo
[redhat]
name=shop
baseurl=http://172.25.254.250/rhel7.3/x86_64/dvd/
gpgcheck=0
[root@localhost yum.repos.d]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
redhat | 4.1 kB 00:00
(1/2): redhat/group_gz | 136 kB 00:00
(2/2): redhat/primary_db | 3.9 MB 00:00
repo id repo name status
redhat shop 4,751
repolist: 4,751
[root@localhost yum.repos.d]# yum install vnc -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package tigervnc.x86_64 0:1.3.1-9.el7 will be installed
--> Processing Dependency: tigervnc-icons for package: tigervnc-1.3.1-9.el7.x86_64
--> Processing Dependency: libfltk.so.1.3()(64bit) for package: tigervnc-1.3.1-9.el7.x86_64
--> Processing Dependency: libfltk_images.so.1.3()(64bit) for package: tigervnc-1.3.1-9.el7.x86_64
--> Running transaction check
---> Package fltk.x86_64 0:1.3.0-13.el7 will be installed
---> Package tigervnc-icons.noarch 0:1.3.1-9.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
tigervnc x86_64 1.3.1-9.el7 redhat 211 k
Installing for dependencies:
fltk x86_64 1.3.0-13.el7 redhat 654 k
tigervnc-icons noarch 1.3.1-9.el7 redhat 36 k
Transaction Summary
================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 900 k
Installed size: 2.1 M
Downloading packages:
(1/3): tigervnc-1.3.1-9.el7.x86_64.rpm | 211 kB 00:00
(2/3): tigervnc-icons-1.3.1-9.el7.noarch.rpm | 36 kB 00:00
(3/3): fltk-1.3.0-13.el7.x86_64.rpm | 654 kB 00:00
--------------------------------------------------------------------------------
Total 1.3 MB/s | 900 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tigervnc-icons-1.3.1-9.el7.noarch 1/3
Installing : fltk-1.3.0-13.el7.x86_64 2/3
Installing : tigervnc-1.3.1-9.el7.x86_64 3/3
redhat/productid | 1.6 kB 00:00
Verifying : fltk-1.3.0-13.el7.x86_64 1/3
Verifying : tigervnc-1.3.1-9.el7.x86_64 2/3
Verifying : tigervnc-icons-1.3.1-9.el7.noarch 3/3
Installed:
tigervnc.x86_64 0:1.3.1-9.el7
Dependency Installed:
fltk.x86_64 0:1.3.0-13.el7 tigervnc-icons.noarch 0:1.3.1-9.el7
Complete!
二、配置本地yum源
1、首先获得与本机系统版本一致的系统镜像
2、挂载镜像
mount /iso/rhel-server-7.3-x86_64-dvd.iso /mnt/iso/ ##把/iso/rhel-server-7.3-x86_64-dvd.iso镜像挂载到/mnt/iso/目录下。
示例:
3、设定永久挂载方法
vim /etc/rc.d/rc.local ##开机自动运行的脚本
mount /iso/rhel-server-7.3-x86_64-dvd.iso /var/www/html/shop/
chmod +x /etc/rc.d/rc.local ##设定执行权限
4、设定系统安装源指向
mkdir /etc/yum.repos.d/backup/
cd /etc/yum.repos.d/
ls
mv redhat.repo backup/
vim yum.repo ##新建yum.repo文件,文件必须以repo结尾
cat yum.repo
[rhel7]
name=rhel7.3
baseurl=file:///mnt/iso
gpgcheck=0
示例:
三、共享型yum源的部署
1、在一台已经连接好本地yum源的主机中安装httpd
2、配置网络yum源
在已经连接好本地yum源的主机中
systemctl start httpd ##开启httpd
systemctl enable httpd ##设定httpd开机启动
systemctl stop firewalld ##关闭防火墙
systemctl disable firewalld ##设定防火墙开机不启动
umount /mnt/iso/ ##卸载光盘镜像文件
mkdir /var/www/html/shop/ ##创建共享仓库
mount /iso/rhel-server-7.3-x86_64-dvd.iso /var/www/html/shop/ ##把镜像文件挂载在仓库中
vim /etc/rc.d/rc.local ##编辑开机启动脚本
cat /etc/rc.d/rc.local 文件内容##
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
#
touch /var/lock/subsys/local
mount /iso/rhel-server-7.3-x86_64-dvd.iso /var/www/html/shop/
chmod 755 /etc/rc.d/rc.local ##给脚本执行权限,开机自动挂载
示例:
测试:
在可以ping通连接好本地yum源的主机的主机中的浏览器中输入地址:
http://ip/shop/
http://172.25.254.33/shop/ ##此地址就是网络yum源地址
四、yum命令
1、yum命令的使用必须是在yum源搭建成功后才能正常运行
2、yum命令的详细用法
yum clean all ##清除原有yum缓存
repolist ##列出仓库信息
install software ##安装
update ##更新
list software ##查看软件
list all ##查看所有软件
list installed ##列出已经安装的软件
list available ##列出可安装软件
reinstall software ##重新安装
remove software ##卸载
info software ##查看软件信息
search software ##根据软件信息查找软件
whatprovides file ##根据软件信息找出包含此文件的软件
groups list ##列出软件组
groups info ##查看软件组的信息
groups remove info 组名 ##卸载组
groups install info 组名 ##安装组
history ##查看系统中软件管理的历史
history info id ##查看此id的软件管理历史操作
示例:
yum clean all
yum repolist
yum install software
yum update
yum list software
yum list all
yum list installed
yum list available
yum reinstall software
yum remove software
扫描二维码关注公众号,回复:
5124218 查看本文章
yum info software ##查看软件信息
yum search software ##根据软件信息查找软件
yum whatprovides file ##根据软件信息找出包含此文件的软件
yum groups list ##列出软件组
yum groups info ##查看软件组的信息
yum groups remove info 组名 ##卸载组
yum groups install info 组名 ##安装组
yum history
yum history info id
五、用rpm命令处理软件
rpm -i ##安装
-v ##显示过程
-h ##hash加密
-e ##卸载
-q ##查看
-a ##所有
-p ##软件包
-ql ##查看软件在系统中的安装文件路径
-qlp ##查看未安装的软件包在系统中如果安装后产生文件的路径
-qf ##根据某个文件找出此文件属于那个安装包
-qc ##查看软件的配置文件名称
-qd ##查看软件的帮助文件
--scritps ##查看脚本
--nodeps ##安装软件忽略软件依赖
--force ##强行安装软件
--Kv ##检测软件包是否被篡改
示例:
安装wps:
结果:
安装画图软件:
首先用
yum install kolourpaint-libs-4.10.5-4.el7.x86_64.rpm --skip-broken
yum install kolourpaint-4.10.5-4.el7.x86_64.rpm --skip-broken
yum install qimageblitz.x86_64 -y
直到出现
使用:
注意:此时桌面应用已经出现画图软件但是并不能正常使用,因为还有一个依赖性没有解决。
解决了依赖性,才可以正常使用。
六、软件包名称解析
kolourpaint-4.10.5-4.el7.x86_64.rpm
[1] [2] [3] [4] [5]
[1]软件名称
[2]版本
[3]适用系统
[4]架构
[5]适用rpm体系软件
redhat packages manager
七、第三方软件仓库的搭建
1.把所有的rpm包放到一个目录中
2.createrepo -v /存放软件包的目录 ##命令执行成功会生成repodate目录
3.vim /etc/yum.repos.d/yum.repo
[software]
name=third software
baseurl=file:///software
gpgcheck=0
yum clean all
yum list linux
示例:
测试:用yum安装wps和画图软件