linux下的软件管理

1.Linux中软件包的类型

1.DEB #UBlinux DEBlinux

2.RPM #redhat centOS fc

3.bz2|gz|xz #1.需要源码安装需要编译
#2.绿色软件,直接可用
#ntfs-3g_ntfsprogs-2017.3.23.tgz 需要编译 “configure”
#Firefox-latest-x86_64.tar.bz2 绿色

“注意在rhel8中只能使用绿色软件,源码编译软件和rpm软件”

2.软件包的名称结构

[dhcp-server]-[4.3.6-30].[el8].[x86_64].[rpm]
      1             2      3       4      5

1.软件名称
2.软件版本
3.软件的授权协议版本
4.软件架构
5.软件类型后缀

3.rpm命令管理软件包

rpm

命令功能
-ivh安装参数组合-i install -v verbose -h hash
-a所有
-f文件
-p软件包
-q查询
-l软件安装文件列表
-e卸载
-c配置文件
-d说明
–info软件信息
–force强制
–nodeps忽略依赖性 但有些软件包即使忽略依赖性安装成功,也无法使用
–scripts查询软件在安装或卸载过程中的运行脚本
-Kv检测软件md5校验码
-V检测已安装软件在系统中的文件被修改信息
[root@foundation50 ~]# rpm -qa  查询系统中所有安装的软件名字
python3-pycparser-2.14-14.el8.noarch
startup-notification-0.12-15.el8.x86_64
python3-meh-0.47.2-1.el8.noarch
cryptsetup-libs-2.2.2-1.el8.x86_64
sg3_utils-1.44-5.el8.x86_64
liberation-fonts-common-2.00.
[root@foundation50 ~]# which qq  查询qq存放的位置
/usr/local/bin/qq
[root@foundation50 ~]# rm -fr /usr/local/bin/qq  若误删qq存放的文件
[root@foundation50 ~]# rpm -qf /usr/local/bin/qq  -qf可以查询文件对应的是那个安装包
linuxqq-2.0.0-b2.x86_64
[root@foundation50 Downloads]# rpm -ivh linuxqq_2.0.0-b2-1089_x86_64.rpm  重新安装qq报错,显示已经安装
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
	package linuxqq-2.0.0-b2.x86_64 is already installed
[root@foundation50 Downloads]# rpm -ivh linuxqq_2.0.0-b2-1089_x86_64.rpm --force  需要强制安装 后面跟--force 就表示强制安装
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
1:linuxqq-2.0.0-b2                 ################################# [100%]
注意:一般需要用到强制安装就是已经安装过了,需要再一次安装
[root@foundation50 Downloads]# rpm -qp linuxqq_2.0.0-b2-1089_x86_64.rpm   -qp查询软件安装包 ,安装
linuxqq-2.0.0-b2.x86_64
[root@foundation50 Downloads]# rpm -q linuxqq_2.0.0-b2-1089_x86_64.rpm 不加p也可以 ,未安装的软件包也可以查询
linuxqq-2.0.0-b2.x86_64
[root@foundation50 Downloads]# rpm -ql linuxqq_2.0.0-b2-1089_x86_64.rpm  查询软件安装文件列表,没有安装也可以查询
/usr/local/bin
/usr/local/bin/crashpad_handler
/usr/local/bin/qq
/usr/local/lib/tencent-qq
/usr/local/share/tencent-qq
/usr/local/share/tencent-qq/CHANGELOG.txt
/usr/local/share/tencent-qq/credits.html
/usr/local/share/tencent-qq/qq.png
/usr/local/share/tencent-qq/res.db
/usr/share/applications/qq.desktop
[root@foundation50 Downloads]# rpm -qi linuxqq_2.0.0-b2-1089_x86_64.rpm  查询软件信息 或者加 --info,如下
[root@foundation50 Downloads]# rpm -q linuxqq_2.0.0-b2-1089_x86_64.rpm --info  查询软件信
Name        : linuxqq
Version     : 2.0.0
Release     : b2
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 36250379
License     : Commercial
Signature   : (none)
Source RPM  : linuxqq-2.0.0-b2.src.rpm
Build Date  : Thu 18 Mar 2021 09:16:51 AM CST
Build Host  : fengfuliu1556250928808-0.fengfuliu1556250928808.default.svc.cluster.local
Relocations : /usr/local 
Packager    : Tencent <support@tencent.com>
Vendor      : Tencent Inc.
URL         : https://im.qq.com/linuxqq
Summary     : QQ for linux
Description :
腾讯QQ Linux版本。
[root@foundation50 Downloads]# rpm -e linuxqq  卸载软件
[root@foundation50 Downloads]# rpm -qc openssh-server 查询软件的配置文件
/etc/pam.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
[root@foundation50 Downloads]# rpm -qd openssh-server 查询软件的说明
/usr/share/man/man5/moduli.5.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sftp-server.8.gz
/usr/share/man/man8/sshd.8.gz
[root@foundation50 pub]# rpm -ivh google-chrome-stable-49.0.2623.108-1.x86_64.rpm --nodeps  谷歌浏览器有很多依赖性, --nodeps 表示忽略依赖性安装 
[root@foundation50 pub]# rpm -qp  google-chrome-stable-49.0.2623.108-1.x86_64.rpm --scripts  查询软件在安装或卸载过程中的运行脚本
preinstall scriptlet (using /bin/sh):  安装前干的事情

exit 0


#------------------------------------------------------------------------------
#   Post install script   安装后干的事情
#------------------------------------------------------------------------------
postinstall scriptlet (using /bin/sh): 

# Add icons to the system icons
XDG_ICON_RESOURCE="`which xdg-icon-resource 2> /dev/null || true`"
if [ ! -x "$XDG_ICON_RESOURCE" ]; then
。。。。。
[root@foundation50 mnt]# rpm -Kv linuxqq_2.0.0-b2-1089_x86_64.rpm  检测软件md5校验码,校验码都是ok的,说明软件没有被串改
linuxqq_2.0.0-b2-1089_x86_64.rpm:
    Header SHA1 digest: OK   j
    MD5 digest: OK 
[root@foundation50 mnt]# echo westos >> linuxqq_2.0.0-b2-1089_x86_64.rpm  软件包被串改
[root@foundation50 mnt]# rpm -Kv linuxqq_2.0.0-b2-1089_x86_64.rpm 
linuxqq_2.0.0-b2-1089_x86_64.rpm:
    Header SHA1 digest: OK
    Payload SHA256 digest: NOTFOUND     检测不ok,说明软件被传改过
    MD5 digest: BAD (Expected 0f1b878b71b988a16eb3017a041c583a != a994652b824907d2037e57c0f7cb8cd2)
[root@foundation50 mnt]# rpm -V linuxqq   检测已安装软件在系统中的文件是否被修改
[root@foundation50 mnt]# echo westos >> /usr/local/bin/qq  修改qq的文件
[root@foundation50 mnt]# rpm -V linuxqq
S.5....T.    /usr/local/bin/qq   显示文件被修改过

4 、本地软件仓库的搭建

系统软件仓库的作用:在系统中对软件进行管理,rpm命令是不能解决依赖关系的,如果需要软件在安装过程中自动解决依赖关系,需要搭建系统软件仓库,就像手机商店一样

搭建方法

 1、下载系统安装时所需的安装镜像
 [root@foundation50 isos]# ls
rhel-8.2-x86_64-dvd.iso  镜像里有官方准备的安装包,若想查看者需要挂载到目录里,通过目录查看镜像里面的内容
2、建立目录
[root@foundation50 isos]# mkdir /westos
3、挂载
[root@foundation50 isos]# mount rhel-8.2-x86_64-dvd.iso /westos/ 挂载镜像
mount: /westos: WARNING: device write-protected, mounted read-only.
[root@foundation50 isos]# df  查看是否挂载好
Filesystem                         1K-blocks     Used Available Use% Mounted on
devtmpfs                             6054996        0   6054996   0% /dev
tmpfs                                6085392   141976   5943416   3% /dev/shm
tmpfs                                6085392    18252   6067140   1% /run
tmpfs                                6085392        0   6085392   0% /sys/fs/cgroup
/dev/mapper/rhel_foundation50-root 307230136 77438184 229791952  26% /
/dev/sda6                            1038336   213064    825272  21% /boot
/dev/sda2                              98304    31279     67025  32% /boot/efi
tmpfs                                1217076       12   1217064   1% /run/user/42
tmpfs                                1217076       24   1217052   1% /run/user/1000
/dev/loop0                           8238560  8238560         0 100% /westos
[root@foundation50 isos]# cd /westos/ q切换到westos
[root@foundation50 westos]# ls  可以看到镜像里面的内容
AppStream  EULA              images      RPM-GPG-KEY-redhat-beta
BaseOS     extra_files.json  isolinux    RPM-GPG-KEY-redhat-release
EFI        GPL               media.repo  TRANS.TBL

AppStream中是一些应用软件 BaseOS中是一些内核等软件 在安装软件的时候有一些依赖性,不确定依赖性在哪个库中,所以在搭建本地软件仓库的时候,两个库都写

4、编写软件仓库文件

[root@foundation50 westos]# cd /etc/yum.repos.d/  仓库文件指向目录
[root@foundation50 yum.repos.d]# vim /etc/yum.repos.d/westos.repo
 将编写的文件放在仓库文件指向目录中,并且文件的结尾必须是以repo结尾否则不识别
[ AppStream]	##仓库名称    应用软件
name=AppStream		##描述
baseurl=file:///westos/AppStream	##f访问软件存放目录地址       /westos  为自己挂载镜像目录
gpgcheck=0			##等于0不检测gpgkey(跳过授权检测)    =1:等于1检测,此时需要gpgkey
gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release       ### 去检测软件是不是官方授权的

[BaseOS]###系统的核心:函数库,内核
name=BaseOS
baseurl=file:///westos/BaseOS
gpgcheck=0
enable=1 ###表示启用此库    默认为1   =0:不启用此库

[root@foundation50 yum.repos.d]# dnf clean all  将系统中以及读取过软件仓库的信息清理掉
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
25 files removed
[root@foundation50 yum.repos.d]# cd /var/cache/dnf/  清除的就是这个目录里的文件
[root@foundation50 dnf]# ls
AppStream-4002311a1f8f0602  BaseOS-e603ff569954d031         last_makecache
AppStream-b0777c5f74c3405e  commandline-a76fe31ae310b0c7    packages.db
AppStream-ea34aa398f56f4f0  expired_repos.json              rhel8-30c83ab4ec6321af
BaseOS-5c5271346fadac6f     google-chrome-eb0d6f10ccbdafba  tempfiles.json
BaseOS-68a81d68eef9cce1     kolourpaint-a4a8f194f7fcf618
[root@foundation50 dnf]# dnf list gcc  列出gcc软件
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream                                                        32 MB/s | 5.8 MB     00:00    
BaseOS                                                           26 MB/s | 2.3 MB     00:00    
Last metadata expiration check: 0:00:01 ago on Wed 25 Aug 2021 10:51:59 PM CST.
Installed Packages
gcc.x86_64                                8.3.1-5.el8                                 @AppStream     发现已经有了gcc软件包
[root@foundation50 dnf]# dnf install gcc -y  此时就可以安装gcc
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:02:44 ago on Wed 25 Aug 2021 10:51:59 PM CST.
Package gcc-8.3.1-5.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

5.网络软件仓库的搭建

在企业中,我们维护的系统数量庞大,
当我们需要在每个系统安装软件管理软件时
可以在每个系统中各自搭建软件仓库
但是这样管理软件会浪费大量的资源
如何节省这部分重复的资源
需要把大家都要使用的资源共享到互联网中
这样大家就可以利用网络访问资源,不需要在每一台 主机中独立建立软件资源了。

搭建方法:
1、利用镜像搭建系统本地仓库,(如上)
2、安装共享软件

共享方式http://	  超文本传输协议
提供此协议的软件	  Apache
软件包名称		  httpd
共享位置		   /var/www/html   Apache默认发布目录
安装命令	  dnf install httpd -y

3.启用共享软件Apache

 systemctl disable --now firewalld 关闭火墙
 systemctl enable --now httpd      ###设置httpd开机自启动

4.建立共享目录

mkdir /var/www/html/westos

5.挂在景象到共享目录

先卸载掉之前的挂载 umount /westos
挂载:mount /xxxxxxx.iso	/var/www/html/westos当镜像在系统中存在时
mount /dev/cdrom	/var/www/html/westos 不存在镜像时可使用光驱读取镜像

vim /etc/rc.d/rc.local 在开机时自动挂载

mount /isos/rhel-8.2-x86_64-dvd.iso   /var/www/html/westos
chmod +X /etc/rc.d/rc.local ##给予可执行权力

6.在远程主机westos_linux中访问资源并书写repo文件 ##也可以直接在本地测试

vim /etc/yum.repos.d/westos.repo  软件仓库指向目录 ,文件必须以repo结尾
[AppStream]
name=AppStream
baseurl=http://172.25.254.50/westos/AppStream/   172.25.254.50未共享主机的ip
gpgcheck=0

[BaseOS]
name=BaseOS
baseurl=http://172.25.254.50/westos/BaseOS/
gpgcheck=0

6.dnf 软件管理命令

dnf

命令功能
repolist列出仓库信息
clean all清除系统中已经加载的仓库缓存信息
list all列出所有软件
list available列出未安装软件
list installed列出已安装软件
install安装
remove卸载
reinstall重新安装
search搜索
whatprovides搜索包含文件的软件包
historydnf执行历史
history infodnf执行历史详细信息
group list列出软件组
group list --installed列出已安装软件组
group list --available列出未安装软件组
group list --hidden列出隐藏软件案组
group install安装软件组
group info查看软件组信息
[root@foundation50 yum.repos.d]# dnf repolist  列出仓库软件信息
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                          repo name
AppStream                                        AppStream
BaseOS                                           BaseOS
[root@foundation50 yum.repos.d]# cd /var/cache/dnf/  以加载的仓库信息文件
[root@foundation50 dnf]# ls
AppStream-4002311a1f8f0602  BaseOS-5a0b07a03f07bb81       google-chrome-eb0d6f10ccbdafba
AppStream-66c7d678d2cb8d44  BaseOS-5c5271346fadac6f       kolourpaint-a4a8f194f7fcf618
AppStream-b0777c5f74c3405e  BaseOS-68a81d68eef9cce1       last_makecache
AppStream-ea34aa398f56f4f0  BaseOS-e603ff569954d031       packages.db
AppStream-edd56422de0841bf  BaseOS-filenames.solvx        rhel8-30c83ab4ec6321af
AppStream-filenames.solvx   BaseOS.solv                   tempfiles.json
AppStream.solv              commandline-a76fe31ae310b0c7
BaseOS-380ca80269784dd9     expired_repos.json
[root@foundation50 dnf]# dnf clean all  清除以加载的仓库信息文件
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
20 files removed
[root@foundation50 dnf]# dnf list all  列出所有软件
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:05:06 ago on Thu 26 Aug 2021 11:17:04 AM CST.
Installed Packages
GConf2.x86_64                               3.2.6-22.el8                              @AppStream  
ModemManager.x86_64                         1.10.8-2.el8                              @anaconda   
ModemManager-glib.x86_64                    1.10.8-2.el8                              @anaconda   
NetworkManager.x86_64                       1:1.22.8-4.el8                            @anaconda   
NetworkManager-adsl.x86_64                  1:1.22.8-4.el8                            @anaconda   
NetworkManager-bluetooth.x86_64             1:1.22.8-4.el8                            @anaconda   
NetworkManager-config-server.noarch         1:1.22.8-4.el8                            @anaconda   
NetworkManager-libnm.x86_64                 1:1.22.8-4.el8                            @anaconda   
NetworkManager-team.x86_64                  1:1.22.8-4.el8                            @anaconda  
。。。。。。。。
[root@foundation50 dnf]# dnf list available 列出未安装软件
yp-tools.x86_64                                 4.2.3-1.el8                              AppStream
ypbind.x86_64                                   3:2.5-2.el8                              AppStream
ypserv.x86_64                                   4.0-6.20170331git5bfba76.el8             AppStream
yum-utils.noarch                                4.0.12-3.el8                             BaseOS   
zlib.i686                                       1.2.11-13.el8                            BaseOS   
zlib-devel.i686                                 1.2.11-13.el8                            BaseOS   
zlib-devel.x86_64                               1.2.11-13.el8                            BaseOS   
zsh.x86_64                                      5.5.1-6.el8_1.2                          BaseOS   
[root@foundation50 dnf]# dnf  list installed  列出已安装软件
xorg-x11-xinit-session.x86_64              1.3.4-18.el8                               @AppStream  
xorg-x11-xkb-utils.x86_64                  7.7-27.el8                                 @AppStream  
xz.x86_64                                  5.2.4-3.el8                                @anaconda   
xz-libs.x86_64                             5.2.4-3.el8                                @anaconda   
yajl.x86_64                                2.1.0-10.el8                               @AppStream  
yelp.x86_64                                2:3.28.1-3.el8                             @AppStream  
yelp-libs.x86_64                           2:3.28.1-3.el8                             @AppStream  
yelp-tools.noarch                          3.28.0-3.el8                               @AppStream  
[root@foundation50 dnf]# dnf remove gcc  卸载软件
[root@foundation50 dnf]# dnf reinstall gcc -y  安装过的软件要重新安装需要用reinstall
[root@foundation50 dnf]# dnf search httpd  通过关键字搜索软件
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:19:00 ago on Thu 26 Aug 2021 11:17:04 AM CST.
================================== Name Exactly Matched: httpd ===================================
httpd.x86_64 : Apache HTTP Server
================================= Name & Summary Matched: httpd ==================================
redhat-logos-httpd.noarch : Red Hat-related icons and pictures used by httpd
keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client
[root@foundation50 dnf]# rm -fr /bin/ls  删除了ls软件所在文件
[root@foundation50 dnf]# ls
bash: /usr/bin/ls: No such file or directory
[root@foundation50 dnf]# rpm -qf /bin/ls 可以用rpm命令查看是那个安装包
coreutils-8.30-6.el8.x86_64
[root@foundation50 dnf]# dnf whatprovides /bin/ls dnf命令查看需要用 whatprovides
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:22:40 ago on Thu 26 Aug 2021 11:17:04 AM CST.
coreutils-8.30-6.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : @System
Matched from:
Provide    : /bin/ls
[root@foundation50 dnf]# dnf reinstall coreutils-8.30-6.el8.x86_64 -y 进行重新安装,ls命令就可以用了
[root@foundation50 dnf]# dnf history   dnf执行的历史记录
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    15 | reinstall coreutils-8.30 | 2021-08-26 11:40 | R              |    2   
    14 | reinstall gcc            | 2021-08-26 11:33 | R              |    2   
    13 | install gcc -y           | 2021-08-26 11:32 | Install        |    7   
    12 | remove gcc               | 2021-08-26 11:30 | Removed        |    7   
    11 | install gcc -y           | 2021-08-26 11:00 | Install        |    1  <
    10 | install httpd -y         | 2021-08-26 10:50 | Install        |    9 > 
     9 | erase httpd              | 2021-08-26 10:50 | Removed        |    9 EE
[root@foundation50 dnf]# dnf history info 12  查看dnf执行的历史详细信息
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Transaction ID : 12
Begin time     : Thu 26 Aug 2021 11:30:32 AM CST
Begin rpmdb    : 1481:fcd53e2f43d907ff7a8c4af7ab86e6b003c1d2f3
End time       : Thu 26 Aug 2021 11:30:37 AM CST (5 seconds)
End rpmdb      : 1474:7b30c951e73b3fd01189a19cd950283a7b2577ac
User           :  <westos>
Return-Code    : Success
Releasever     : 8
Command Line   : remove gcc
Packages Altered:
    Removed cpp-8.3.1-5.el8.x86_64               @@System
    Removed gcc-8.3.1-5.el8.x86_64               @@System
    Removed glibc-devel-2.28-101.el8.x86_64      @@System
    Removed glibc-headers-2.28-101.el8.x86_64    @@System
    Removed isl-0.16.1-6.el8.x86_64              @@System
    Removed kernel-headers-4.18.0-193.el8.x86_64 @@System
    Removed libxcrypt-devel-4.1.1-4.el8.x86_64   @@Syste
[root@foundation50 dnf]# dnf group list  列出软件组
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 2:57:21 ago on Thu 26 Aug 2021 12:06:20 PM CST.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Virtualization Host
   Custom Operating System
Installed Environment Groups:
   Server with GUI
Installed Groups:
   Container Management
[root@foundation50 dnf]# dnf group list --installed  列出已安装的软件组
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:02:52 ago on Thu 26 Aug 2021 03:06:31 PM CST.
Installed Environment Groups:
   Server with GUI
Installed Groups:
   Container Management
   Headless Management
[root@foundation50 dnf]# dnf group list --available  列出未安装的软件组
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:03:38 ago on Thu 26 Aug 2021 03:06:31 PM CST.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Virtualization Host
   Custom Operating System
[root@foundation50 dnf]# dnf group list  --hidden  列出隐藏的软件组
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:06:59 ago on Thu 26 Aug 2021 03:06:31 PM CST.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Virtualization Host
   Custom Operating System
[root@foundation50 dnf]# dnf group info "Virtualization Client"  查看虚拟化软件组的信息
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:12:50 ago on Thu 26 Aug 2021 03:06:31 PM CST.

Group: Virtualization Client
 Description: Clients for installing and managing virtualization instances.
 Mandatory Packages:
   gnome-boxes
   virt-install
   virt-manager
   virt-viewer
 Default Packages:
   virt-top
 Optional Packages:
   libguestfs-inspect-icons
   libguestfs-tools
   libguestfs-tools-c
[root@foundation50 dnf]# dnf group install "Virtualization Client"  安装虚拟化软件组
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:16:37 ago on Thu 26 Aug 2021 03:06:31 PM CST.
Dependencies resolved.
==================================================================================================
 Package                Architecture          Version                Repository              Size
==================================================================================================
Installing Groups:
 Virtualization Client                                                                           

Transaction Summary
==================================================================================================

Is this ok [y/N]: y
Complete!

自己电脑能上网的两条命令

[root@foundation50 isos]# ip route add default via 172.25.254.250  enp4s0f1 加一个网关
[root@foundation50 isos]# vim /etc/resolv.conf 
[root@foundation50 isos]# cat /etc/resolv.conf 
nameserver 114.114.114.114

7.网络源epel(可以下载系统里面没有的软件,如flameshot,pingyin)

[root@foundation50 yum.repos.d]# vim westos.repo  
[aliyunrepo]
name=aliyunrepo
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/  阿里云镜像
gpgcheck=0  
[aliyunrepo]
name=aliyunrepo
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
gpgcheck=0

[AppStream]               加上系统本地源,仓库就全了                                                                        
name=AppStream
baseurl=http://172.25.254.50/westos/AppStream
gpgcheck=0

[BaseOS]                                                                                          
name=BaseOS
baseurl=http://172.25.254.50/westos/BaseOS
gpgcheck=0
[root@foundation50 yum.repos.d]# dnf search flameshot  搜索flameshot
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:02:14 ago on Thu 26 Aug 2021 04:32:58 PM CST.
================================ Name Exactly Matched: flameshot =================================
flameshot.x86_64 : Powerful and simple to use screenshot software
[root@foundation50 yum.repos.d]# dnf install flameshot -y 下载

8 、java的安装

在这里插入图片描述

[root@foundation50 Desktop]# dnf install java-11-openjdk.x86_64 java-11-openjdk-devel.x86_64 -y 安装java两个安装包
[root@foundation50 Desktop]# vim /etc/profile.d/java.sh 配置系统环境
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH=$PATH:$JAVA_HOME:/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools,jar   
[root@foundation50 Desktop]# vim westos.java 写java代码
public class westos{
public static void main(string args[]){
System.out.println("hello westos");
}
}
[root@foundation50 Desktop]# javac westos.java  编译
[root@foundation50 Desktop]# java westos  java部署成功
hello westos

10 、下载软件安装包

下载yum工具包

[root@foundation50 Desktop]# dnf install yum-utils.noarch -y

把httpd安装包下载到当前目录

[root@foundation50 Desktop]# yumdownloader httpd  
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 5:46:44 ago on Thu 26 Aug 2021 04:56:45 PM CST.
httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64.rpm   

下载httpd安装包到指定的mnt当中

[root@foundation50 Desktop]# yumdownloader httpd --destdir=/mnt  
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 5:49:12 ago on Thu 26 Aug 2021 04:56:45 PM CST.
httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64.rpm   
[root@foundation50 Desktop]# ls /mnt/
httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64.rpm

下载软件包并下载依赖性

[root@foundation50 Desktop]# yumdownloader httpd --destdir=/mnt --resolv

11.第三方软件仓库的搭建方法

官方为什么能读取文件里的软件包,而自己建立的目录放入软件包不能读取,因为缺少repodata/数据目录,repodata目录里面有软件元数据信息,例如软件名、依赖性等属性信息,官方是识别repodata里面数据,而不是识别软件本身
如何实现第三方软件仓库搭建,如下步骤:
##步骤##

1.建立共享目录
mkdir /var/www/html/software
2.把所有的第三方软件存放到/var/www/html/software中
/var/www/html/software中只能存在rpm类型的文件,压缩包是不能使用dnf管理的
3.采集第三方软件数据生成repodate目录
dnf install createrepo -y 安装采集工具
cd /var/www/html/software
进入到共享目录
createrepo . 对目录中进行扫描生成repodate数据目录
cretaerepo -v 指定目录
4.在测试主机中指定第三方共享源
vim /etc/yum.repos.d/westos.repo
[software]
name=software
baseurl=http://172.25.254.50/software
gpgcheck=0

注意:若重新加入软件,需要createrepo -v 去重新扫描

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小莫细说linux

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值