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.軟件包的名稱結(jié)構(gòu) ####
[dhcp-server]-[4.3.6-30].[el8].[x86_64].[rpm]
????? 1?????????? 2??????? 3?????? 4????? 5
1.軟件名稱
2.軟件版本
3.軟件的授權(quán)協(xié)議版本
4.軟件架構(gòu)
5.軟件類型后綴
#### 3.rpm命令管理軟件包 ####
rpm?? ?-ivh?? ??? ?##安裝參數(shù)組合 -i install -v verbose -h hash
?? ?-a?? ??? ?##所有
?? ?-f?? ??? ?##文件
?? ?-p?? ??? ?##軟件包
?? ?-q?? ??? ?##查詢
?? ?-l?? ??? ?##軟件安裝文件列表
?? ?-e?? ??? ?##卸載
?? ?-c?? ??? ?##配置文件
?? ?-d?? ??? ?##說(shuō)明
?? ?--info?? ??? ?##軟件信息
?? ?--force?? ??? ?##強(qiáng)制
?? ?--nodeps?? ?##忽略依賴性
?? ?--scripts ?? ##查詢軟件在安裝或卸載過(guò)程中的運(yùn)行腳本
?? ?-Kv?? ??? ?##檢測(cè)軟件md5校驗(yàn)碼
?? ?-V?? ??? ?##檢測(cè)已安裝軟件在系統(tǒng)中的文件被修改信息
#### 4.本地軟件倉(cāng)庫(kù)的搭建 ####
#
#系統(tǒng)軟件倉(cāng)庫(kù)的作用
#
#在系統(tǒng)中對(duì)軟件進(jìn)行管理
#rpm命令是不能解決依賴關(guān)系的
#如果需要軟件在安裝過(guò)程中自動(dòng)解決依賴關(guān)系
#需要大家系統(tǒng)軟件倉(cāng)庫(kù)
##搭建方法##
1.在系統(tǒng)中加載安裝系統(tǒng)時(shí)使用的安裝鏡像
?mount /isos/rhel-8.0-x86_64-dvd.iso /linux
2.編寫軟件倉(cāng)庫(kù)文件
/etc/yum.repos.d/?? ??? ?##軟件源指向文件配置目錄
?? ??? ??? ??? ?##在此目錄中不能有無(wú)法訪問的源指向
vim /etc/yum.repos.d/xxxx.repo?? ?##軟件倉(cāng)庫(kù)指向文件
? 1 [AppStream]?????????????????????????????????????? ##倉(cāng)庫(kù)名稱
? 2 name=linux AppStream???????????????????? ##描述
? 3 baseurl=file:///linux/AppStream????????? ##地址
? 4 gpgcheck=0??????????????????????????????????????? ####不檢測(cè)gpgkey?? ?(跳過(guò)授權(quán)檢測(cè)—)
? 5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release??????????????? (授權(quán)檢測(cè))
? 6 enabled=1???????????????????????????????????????? ##開啟
? 7
? 8 [BaseOS]
? 9 name=linux BaseOS
?10 baseurl=file:///linux/BaseOS
?11 gpgcheck=0
?12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
?13 enabled=1
#### 5.dnf 軟件管理命令 ####
dnf?? ?repolist?? ??? ?##列出倉(cāng)庫(kù)信息
?? ?clean all?? ??? ?##清除系統(tǒng)中已經(jīng)加載的倉(cāng)庫(kù)緩存信息
?? ?list all?? ??? ?##列出所有軟件
?? ?list available?? ??? ?##列出未安裝軟件
?? ?list installed?? ??? ?##列出已安裝軟件
?? ?install?? ??? ??? ?##安裝
?? ?remove ?? ??? ??? ?##卸載
?? ?reinstall?? ??? ?##重新安裝
?? ?search?? ??? ??? ?##搜索
?? ?whatprovides?? ??? ?##搜索包含文件的軟件包
?? ?history?? ??? ??? ?##dnf執(zhí)行歷史
?? ?history info?? ??? ?##dnf執(zhí)行歷史詳細(xì)信息
?? ?group list?? ??? ?##列出軟件組
?? ?group list --installed?? ?##列出已安裝軟件組
?? ?group list --available?? ?##列出未安裝軟件組
?? ?group list --hidden?? ?##列出隱藏軟件案組
?? ?group install ?? ??? ?##安裝軟件組
?? ?group info?? ??? ?##查看軟件組信息
?
[root@westos_student yum.repos.d]# dnf remove linuxqq
[root@westos_student yum.repos.d]# dnf search gcc?????????????????????? 搜索軟件
[root@westos_student yum.repos.d]# dnf whatprovides /bin/ls?????????????? 搜索包含文件的軟件包
??[root@westos_student yum.repos.d]# dnf group list --hidden?????????? 列出隱藏軟件案組
?
[root@westos_student yum.repos.d]# dnf group install "Virtualization Client" "Virtualization Hypervisor" "Virtualization Tools"
安裝軟件組
#### 6.網(wǎng)絡(luò)軟件倉(cāng)庫(kù)的搭建 ####
westos_linux: 172.25.254.10
westos_node1: 172.25.254.20
在westos_node1中已經(jīng)搭建好軟件倉(cāng)庫(kù),
在westos_linux中是無(wú)法訪問的
在企業(yè)中,我們維護(hù)的系統(tǒng)數(shù)量龐大,
當(dāng)我們需要在每個(gè)系統(tǒng)安裝軟件管理軟件時(shí)
可以在每個(gè)系統(tǒng)中各自搭建軟件倉(cāng)庫(kù)
但是這樣管理軟件會(huì)浪費(fèi)大量的資源
如何節(jié)省這部分重復(fù)的資源
需要把大家都要使用的資源共享到互聯(lián)網(wǎng)中
這樣大家就可以利用網(wǎng)絡(luò)訪問資源,不需要在每一臺(tái)
主機(jī)中獨(dú)立建立軟件資源了。
##搭建方法##
1.利用景象搭建本地軟件倉(cāng)庫(kù)
2.安裝共享軟件
?? ?#共享方式http://?? ?超文本傳輸協(xié)議
?? ?#提供此協(xié)議的軟件?? ?Apache
?? ?#軟件包名稱?? ??? ?httpd
?? ?#共享位置?? ???? /var/www/html/linux
?? ?#安裝命令?? ??? ?在westos_node1: dnf install httpd -y
3.啟用共享軟件Apache
?? ?# systemctl stop firewalld
?? ?# systemctl disable firewalld
?? ?# systemctl enable --now httpd
4.建立共享目錄
mkdir -p /var/www/html/linux
5.掛在景象到共享目錄
?? ?# mount /xxxxxxx.iso?? ?/var/www/html/linux ? 當(dāng)鏡像在系統(tǒng)中存在
?? ?# mount /dev/cdrom?? ?/var/www/html/linux ?? 當(dāng)使用光驅(qū)讀取鏡像
?? ?# vim /etc/rc.d/rc.local?? ??? ??? ?在開機(jī)時(shí)自動(dòng)掛在
?? ?# mount /isos/rhe ??? /var/www/html/linux
?? ?# chmod 755 /etc/rc.d/rc.local?????????????? +x
6.在遠(yuǎn)程主機(jī)westos_linux中訪問資源并書寫repo文件
?? ?vim /etc/yum.repos.d/linux.repo
???
1 [AppStream]
? 2 name=linux AppStream
? 3 baseurl=http://192.168.31.139/linux/AppStream
? 4 gpgcheck=0
? 5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
? 6 enabled=1
? 7
? 8 [BaseOS]
? 9 name=linux BaseOS
?10 baseurl=http://192.168.31.139/linux/BaseOS??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?
?11 gpgcheck=0
?12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
?13 enabled=1
#### 6.第三方軟件倉(cāng)庫(kù)的搭建方法 ####
可以使用dnf命令管理第三方軟件
并使第三方軟件在網(wǎng)絡(luò)中共享
##步驟##
1.建立共享目錄
?? ?# mkdir /var/www/html/software
2.把所有的第三方軟件存放到/var/www/html/software中
?? ?# /var/www/html/software中只能存在rpm類型的文件,壓縮包是不能使用dnf管理的
3.采集第三方軟件數(shù)據(jù)生成repodate目錄
?? ?# dnf install ?? ?createrepo -y?? ?安裝采集工具
?? ?# cd /var/www/html/software?? ?進(jìn)入到共享目錄
?? ?# createrepo .?? ??? ??? ?對(duì)共享目錄中進(jìn)行掃描生成repodate數(shù)據(jù)目錄
?
4.在測(cè)試主機(jī)中指定第三方共享源
?? ?# vim /etc/yum.repos.d/linux.repo
[software]
name=software?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? baseurl=http://192.168.31.139/software
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
測(cè)試:列出linuxqq
阿里云庫(kù)搭建
[epel8]
name=aliepel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64
gpgcheck=0
enabled=0
?
總結(jié)
以上是生活随笔為你收集整理的Linux 系统之软件管理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 中的文件传输
- 下一篇: Linux 系统之虚拟化部署