文章目录
一、Linux 中软件包的类型
1.DEB #UBlinux DEBlinux
2.RPM #redhat centOS fc
3.bz2|gz|xz
注意:
1.需要源码安装需要编译
2.绿色软件,直接可用
dnf ntfs-3g_ntfsprogs-2017.3.23.tgz 需要编译 “configure”
Firefox-latest-x86_64.tar.bz2 绿色
“注意在 rhel8 中只能使用绿色软件,源码编译软件和 rpm 软件”
二、软件包的名称结构
[dhcp-server]-[4.3.6-30].[el8].[x86_64].[rpm]
[1] [2] [3] [4] [5]
[1]软件名称
[2]软件版本
[3]软件的授权协议版本
[4]软件架构
[5]软件类型后缀
三、rpm 命令管理软件包
[root@westos_student3 ~]# mkdir /softwear #建立一个文件夹
[root@westos_student3 ~]# cd /softwear/ #到当前文件夹里
[root@westos_student3 softwear]# rpm -ivh 软件安装包名称 #安装参数组合 -i install -v verbose -h hash
[root@westos_student3 ~]# rpm -a #所有
[root@westos_student3 ~]# rpm -f #文件
[root@westos_student3 ~]# rpm -p #软件包
[root@westos_student3 ~]# rpm -q #查询,常与其他命令一起用,-ql ,-qd ,-qa
[root@westos_student3 ~]# rpm -l #软件安装文件列表
[root@westos_student3 ~]# rpm -e #卸载
[root@westos_student3 ~]# rpm -c #配置文件
[root@westos_student3 ~]# rpm -d #说明
[root@westos_student3 ~]# rpm --info #软件信息
[root@westos_student3 ~]# rpm --force #强制
[root@westos_student3 ~]# rpm --nodeps #忽略依赖性
[root@westos_student3 ~]# rpm --script #查询软件在安装或卸载过程中的运行脚本
[root@westos_student3 ~]# rpm -Kv #检测软件 md5 校验码
[root@westos_student3 ~]# rpm -V #检测已安装软件在系统中的文件被修改信息
四、本地软件仓库的搭建
系统软件仓库的作用:在系统中对软件进行管理,但rpm 命令是不能解决依赖关系的,如果需要软件在安装过程中自动解决依赖关系,需要搭建系统软件仓库。
本地资源搭建具体步骤:
1,在系统中加载安装系统时使用的安装镜像
[root@westos_student3 isos]# wget ftp:///172.25.254.250/pub/isos/rhel-8.2-x86_64-dvd.iso #下载,插个光盘,在系统中加载安装系统时使用的安装镜像
2,挂载镜像
[root@westos_student3 isos]# mount /isos/rhel-8.2-x86_64-dvd.iso /mnt/ #挂载镜像 #umount 取消挂载
3,编写软件仓库文件
[root@westos_student3 isos]# vim /etc/yum.repos.d/mnt.repo #软件仓库指向文件
编辑内容:
[AppStream] #仓库名称,相当于软件安装管家
name=AppStream #描述
baseurl=file:///mnt/AppStream #挂载到的目录的地址,挂载点
gpgcheck=0 #不检测,能安装第三方软件#gpgcheck=1就不能安装,需要 用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release (跳过授权检测)
enable=1 #启用仓库,能加载资源
[BaseOS] #内核存放
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enable=1
编辑完成
4,安装gcc
[root@westos_student3 isos]# dnf repolist
[root@westos_student3 isos]# dnf search gcc #查看
[root@westos_student3 isos]# dnf install gcc 安装
搭建完成
注意: vim /etc/rc.d/rc.local在开机时自动挂载
编辑内容:
mount /dev/cdrom /var/www/html/westos_8 #在虚拟机里
mount /isos/rhel-8.2-x86_64-dvd.iso /var/www/html/westos/ #在系统里,挂载
chmod 755 /etc/rc.d/rc.local #设置成可执行
五、dnf 软件管理命令
[root@westos_student3 ~]# dnf repolist #列出仓库信息
[root@westos_student3 ~]# dnf clean all #清除系统中已经加载的仓库缓存信息,=重新加载
[root@westos_student3 ~]# dnf list all #列出所有软件
[root@westos_student3 ~]# dnf list available #列出未安装软件
[root@westos_student3 ~]# dnf list installed #列出已安装软件
[root@westos_student3 ~]# dnf install gcc #安装 dnf install 安装包名称(gcc)
[root@westos_student3 ~]# dnf remove gcc #卸载
[root@westos_student3 ~]# dnf reinstall gcc #重新安装
[root@westos_student3 ~]# dnf search gcc #搜索
[root@westos_student3 ~]# dnf whatprovides #搜索包含文件的软件包
[root@westos_student3 ~]# dnf history #dnf 执行历史
[root@westos_student3 ~]# dnf history info #dnf 执行历史详细信息
[root@westos_student3 ~]# dnf group list #列出软件组
[root@westos_student3 ~]# dnf group list --installed #列出已安装软件组
[root@westos_student3 ~]# dnf group list --available #列出未安装软件组
[root@westos_student3 ~]# dnf group list --hidden #列出隐藏软件案组
[root@westos_student3 ~]# dnf group install #安装软件组
[root@westos_student3 ~]# dnf group info #查看软件组信息
六、网络软件仓库的搭建
在企业中,我们维护的系统数量庞大,当我们需要在每个系统安装软件管理软件时
可以在每个系统中各自搭建软件仓库。但是这样管理软件会浪费大量的资源,如何节省这部分重复的资源,需要把大家都要使用的资源共享到互联网中,这样大家就可以利用网络访问资源,不需要在每一台主机中独立建立软件资源了。
共享资源搭建具体步骤:
1,.安装共享软件
dnf install httpd #安装,网络就可以实现共享
2,启用共享软件 Apache
systemctl disable --now firewalld #防火墙不能用
systemctl enable --now httpd #httpd能用
mkdir /var/www/html/westos #建立一个apache带有的文件目录
3,挂载景象到共享目录
mount /isos/rhel-8.2-x86_64-dvd.iso /var/www/html/westos/ #必须挂载在apache规定的目录下
df #查看挂载位置
4,在远程主机中访问资源并书写 repo 文件
vim /etc/yum.repos.d/westos.repo #编辑软件仓库指向文件
编辑内容:
[AppStream]
name=westosdir AppStream
baseurl=http:///196.128.122.1/westos/AppStream
gpgcheck=0
[BaseOS]
name=westos BaseOS
baseurl=http:///196.128.122.1/westos/BaseOS
gpgcheck=0
编辑完成
5,到网页里访问http:///196.128.122.1/westos/,若能访问,搭建完成
使用阿里云资源搭建具体步骤:
1,先有网,建立网关,(自己有网可跳过这一步)
[root@westos_student3 html]# ip route add default via 172.25.254.250
[root@westos_student3 html]# route -n
[root@westos_student3 html]# vim /etc/resolv.conf
编辑内容
nameserver 114.114.114.114
[root@westos_student3 html]# ping www.baidu.com #访问百度,若能访问,说明网能用
[root@westos_student3 html]# dnf clean all
[root@westos_student3 html]# dnf list httpd
2,[root@westos_student3 html]# vim /etc/yum.repos.d/westos.repo #注意目录/etc/yum.repos.d/,,文件名是westos.repo
编辑内容:
[aliyunrepo]
name=aliyunrepo
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/ #阿里云官网里面的开发者-》开发者社区-》开发工具的镜像站-》epel-》点下载地址的网址-》epel/8/Everything/x86_64/
gpgcheck=0
3,[root@westos_student3 html]# dnf clean all #刷新
[root@westos_student3 html]# dnf search Kolour #查找
[root@westos_student3 html]# dnf install kolourpaint.x86_64 #安装画图软件
[root@westos_student3 html]# dnf search flameshot
[root@westos_student3 html]# dnf install flameshot.x86_64 #安装截图软件
%完成
七、第三方软件仓库的搭建方法
原理:把所有的安装包数据整到一个目录里,通过扫描这个目录来安装软件,可以使用 dnf 命令管理第三方软件,并使第三方软件在网络中共享,其中.xlm可扩展编辑语言
第三方软件仓库的搭建具体步骤:
1,建立共享目录
[root@westos_student3 software1]# mkdir /software1
[root@westos_student3 software1]# cd /software1
2,把所有的第三方软件存放到software1中
[root@westos_student3 software1]# dnf install lftp -y
[root@westos_student3 software1]# lftp 172.25.254.250
lftp 172.25.254.250:~> cd pub/software/
lftp 172.25.254.250:/pub/software> mget *.rpm
lftp 172.25.254.250:/pub/software>quit
3,采集第三方软件数据生成 repodate 目录
[root@westos_student3 software1]# dnf install createrepo -y #在挂载本地镜像时用gcc 安装,再取消挂载
root@westos_student3 software1]# createrepo -v /software1 #进行扫描
[root@westos_student3 software1]# ls
4.在测试主机中指定第三方共享源
[root@westos_student3 software1]# vim /etc/yum.repos.d/westos.repo
编辑内容:
[Appstream]
name=Appstream
baseurl=file:///var/www/html/westos/AppStream
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=file:///var/www/html/westos/BaseOS
gpgcheck=0
[software]
name=third software
baseurl=file:///software1
gpgcheck=0
编辑完成,就可以搜索安装软件了
[root@westos_student3 softw are1]# dnf search linuxqq
[root@westos_student3 software1]# dnf search wps