云计算Linux运维——Linux系统——软件管理 - Go语言中文社区

云计算Linux运维——Linux系统——软件管理


点关注不迷路

目录

点关注不迷路

1RPM软件管理

1、软件安装包类型

2、RPM软件安装包的组成

二、RPM软件管理操作 rpm命令

1、安装软件

2、查看软件

3、卸载软件

2yum工具介绍

一、yum工具介绍

1、优势

2、yum源配置文件

二、配置本地源安装软件

1、备份自带的HTTP源

2、编写本地源

3、清除旧的yum缓存

4、查看可用yum源

5、测试安装软件

三、配置FTP源安装ceph-deploy

四、配置HTTP源安装openstack-keystone软件

五、yum缓存、制作yum仓库

1、yum缓存功能

2、制作yum仓库

六、yum常用功能

1、安装软件

2、卸载软件

3、更新软件

4、清除yum缓存

5、查看可用的yum源

6、查询文件对应的软件

3源码软件管理

一、源码软件介绍

1、源码软件格式

2、优势

3、安装流程

二、安装htop软件

1、下载htop的安装包

2、解压缩

3、配置软件的安装目录

4、编译

5、安装

6、打开htop的软件

三、环境变量PATH的使用

1、PATH变量的作用

2、方便htop的执行


1RPM软件管理

1、软件安装包类型

  • rpm
    • 安装简单
  • 源码软件
    • .tar.gz , tar.bz2
    • 安装复杂
    • 灵活性高

2、RPM软件安装包的组成

zilb-1.2.7-18.el7 .x86_64.rpm

软件名

安装版本

软件所对应的系统平台

[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# ls /mnt/Packages/

二、RPM软件管理操作 rpm命令

1、安装软件

命令:rpm -ivh 软件安装包名称

  • i 安装
  • v 显示安装过程
  • h 以#的方式显示软件的安装进度

1)安装dhcp的软件

[root@localhost ~]# rpm -ivh /mnt/Packages/dhcp-4.2.5-82.el7.centos.x86_64.rpm 
警告:/mnt/Packages/dhcp-4.2.5-82.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:dhcp-12:4.2.5-82.el7.centos      ################################# [100%]

2)安装bind的软件

[root@localhost ~]# rpm -ivh /mnt/Packages/bind-9.11.4-26.P2.el7.x86_64.rpm 
警告:/mnt/Packages/bind-9.11.4-26.P2.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:bind-32:9.11.4-26.P2.el7         ################################# [100%]

3)安装httpd的软件

[root@localhost ~]# rpm -ivh /mnt/Packages/httpd-2.4.6-95.el7.centos.x86_64.rpm 
警告:/mnt/Packages/httpd-2.4.6-95.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
	/etc/mime.types 被 httpd-2.4.6-95.el7.centos.x86_64 需要
	httpd-tools = 2.4.6-95.el7.centos 被 httpd-2.4.6-95.el7.centos.x86_64 需要
[root@localhost ~]# rpm -ivh --nodeps /mnt/Packages/httpd-2.4.6-95.el7.centos.x86_64.rpm 
警告:/mnt/Packages/httpd-2.4.6-95.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:httpd-2.4.6-95.el7.centos        ################################# [100%]

2、查看软件

1)查看软件是否安装

[root@localhost ~]# rpm -q dhcp
dhcp-4.2.5-82.el7.centos.x86_64

[root@localhost ~]# rpm -q samba 
未安装软件包 samba 
# rpm -qa 

# rpm -qa | grep "dhcp"

2)查询软件生成的文件

[root@localhost ~]# which vim
/usr/bin/vim
[root@localhost ~]# rpm -qf /usr/bin/vim
vim-enhanced-7.4.629-7.el7.x86_64

3)查询软件生成的文件

# rpm -ql coreutils

# rpm -qa dhcp 

3、卸载软件

[root@localhost ~]# rpm -q dhcp
dhcp-4.2.5-82.el7.centos.x86_64

[root@localhost ~]# rpm -e dhcp
[root@localhost ~]# rpm -q dhcp
未安装软件包 dhcp 
# rpm -e --nodeps coreutils 

2yum工具介绍

一、yum工具介绍

1、优势

  • 自动解决软件的依赖关系

2、yum源配置文件

  • 事先存在合适的yum源配置文件
    • 说明RPM软件安装的存放位置
  • yum源类型
    • 本地源
    • FTP源
    • HTTP源
  • yum源配置文件存放位置
    • /etc/yum.repos.d/*.repo
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

命令:yum install httpd

替换centos的base源(华为、阿里、网易)

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

二、配置本地源安装软件

1、备份自带的HTTP源

[root@localhost ~]# mkdir /etc/yum.repos.d/bak
[root@localhost ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
[root@localhost ~]# ls /etc/yum.repos.d/
bak

2、编写本地源

[root@localhost ~]# vim /etc/yum.repos.d/centos7.repo 
[centos7]
name=centos7
baseurl=file:///opt/software
enabled=1
gpgcheck=0
[root@localhost ~]# mkdir /opt/software
[root@localhost ~]# mount /dev/sr0 /opt/software
mount: /dev/sr0 is write-protected, mounting read-only

3、清除旧的yum缓存

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos7
Cleaning up list of fastest mirrors
Other repos take up 145 M of disk space (use --verbose for details)
[root@localhost ~]# 

4、查看可用yum源

[root@localhost ~]# yum repolist     
Loaded plugins: fastestmirror
Determining fastest mirrors
centos7                                                                                                        | 3.6 kB  00:00:00     
(1/2): centos7/group_gz                                                                                        | 166 kB  00:00:00     
(2/2): centos7/primary_db                                                                                      | 6.0 MB  00:00:00     
repo id                                                         repo name                                                       status
centos7                                                         centos7                                                         10,019
repolist: 10,019

5、测试安装软件

[root@localhost ~]# yum install lrzsz 

[root@localhost ~]# rpm -q lrzsz
lrzsz-0.12.20-36.el7.x86_64
[root@localhost ~]# yum install php vsftpd 

三、配置FTP源安装ceph-deploy

[root@localhost ~]# cat /etc/yum.repos.d/ceph.repo
[ceph]
name=ceph
baseurl=ftp://10.11.0.254/software/ceph-mimic/
enabled=1
gpgcheck=0
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos7 ceph
Cleaning up list of fastest mirrors
Other repos take up 145 M of disk space (use --verbose for details)

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
centos7                                                                                                        | 3.6 kB  00:00:00     
ceph                                                                                                           | 2.9 kB  00:00:00     
(1/3): centos7/group_gz                                                                                        | 166 kB  00:00:00     
(2/3): centos7/primary_db                                                                                      | 6.0 MB  00:00:00     
(3/3): ceph/primary_db                                                                                         | 755 kB  00:00:00     
repo id                                                         repo name                                                       status
centos7                                                         centos7                                                         10,019
ceph                                                            ceph                                                               266
repolist: 10,285
[root@localhost ~]# yum install ceph-deploy 

四、配置HTTP源安装openstack-keystone软件

[root@localhost ~]# cat /etc/yum.repos.d/openstack.repo 
[openstack]
name=openstack
baseurl=http://mirrors.163.com/centos/7.9.2009/cloud/x86_64/openstack-queens/
enabled=1
gpgcheck=0
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
centos7                                                                                                        | 3.6 kB  00:00:00     
ceph                                                                                                           | 2.9 kB  00:00:00     
openstack                                                                                                      | 3.0 kB  00:00:00     
(1/4): centos7/group_gz                                                                                        | 166 kB  00:00:00     
(2/4): centos7/primary_db                                                                                      | 6.0 MB  00:00:00     
(3/4): ceph/primary_db                                                                                         | 755 kB  00:00:00     
(4/4): openstack/primary_db                                                                                    | 1.2 MB  00:00:31     
repo id                                                         repo name                                                       status
centos7                                                         centos7                                                         10,019
ceph                                                            ceph                                                               266
openstack                                                       openstack                                                        3,116
repolist: 13,401
[root@localhost ~]# yum install openstack-keystone

五、yum缓存、制作yum仓库

1、yum缓存功能

  • 缓存软件的安装包
[root@localhost ~]# vim /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
[root@localhost ~]# find /var/cache/yum/ -name "*.rpm" -exec cp {} /openstack/ \;

2、制作yum仓库

命令:createrepo 目录名称

六、yum常用功能

1、安装软件

命令:yum install 软件名称 软件名称

2、卸载软件

命令:yum remove 软件名称 软件名称

3、更新软件

命令:yum update 软件名称 软件名称

4、清除yum缓存

命令:yum clean all

5、查看可用的yum源

命令:yum repolist

6、查询文件对应的软件

命令:yum provides 文件名称


3源码软件管理

一、源码软件介绍

1、源码软件格式

.tar.gz , .tar.bz2

2、优势

灵活性,支持自定义软件的安装目录

3、安装流程

  • 下载软件安装包
  • 解压缩
  • 配置软件的功能参数(指定安装目录)
  • 编译——将代码翻译成计算机可识别的样子
  • 安装

二、安装htop软件

1、下载htop的安装包

[root@localhost ~]# lftp 10.11.0.254
lftp 10.11.0.254:~> ls              
drwxr-xr-x   36 1000     1000         4096 May 10 08:35 software
drwxr-xr-x   16 1000     1000         4096 Jul 18 08:55 upload
lftp 10.11.0.254:/> 
lftp 10.11.0.254:/> cd software/htop/
lftp 10.11.0.254:/software/htop> ls
-rw-rw-r--    1 1000     1000       308109 Apr 10  2018 htop-2.2.0.tar.gz
lftp 10.11.0.254:/software/htop> get htop-2.2.0.tar.gz 
308109 bytes transferred                              
lftp 10.11.0.254:/software/htop> exit

2、解压缩

[root@localhost ~]# tar xf htop-2.2.0.tar.gz 

3、配置软件的安装目录

[root@localhost ~]# cd htop-2.2.0/
[root@localhost htop-2.2.0]# ./configure --prefix=/usr/local/htop 
  • 错误1 :缺少gcc编译器

checking for gcc... no

checking for cc... no

checking for cl.exe... no

[root@localhost htop-2.2.0]# yum install gcc 
  • 错误2:configure: error: You may want to use --disable-unicode or install libncursesw.
# yum install ncurses-devel

4、编译

[root@localhost htop-2.2.0]# make 

5、安装

[root@localhost htop-2.2.0]# make install 

6、打开htop的软件

[root@localhost ~]# /usr/local/htop/bin/htop 

三、环境变量PATH的使用

1、PATH变量的作用

  • 保存命令路径
  • 操作系统执行命令,会在PATH保存的路径中查找命令,能查到就能正常执行

查看PATH变量的值

[root@localhost ~]# echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

2、方便htop的执行

1) 修改PATH变量的值

临时修改

# export PATH=$PATH:/usr/local/htop/bin

永久修改

[root@localhost ~]# vim /etc/profile export PATH=$PATH:/usr/local/htop/bin [root@localhost ~]# source /etc/profile

2) 创建软链接

[root@localhost ~]# ln -s /usr/local/htop/bin/htop /usr/bin/

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_53355777/article/details/125959395
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2023-01-03 18:59:03
  • 阅读 ( 225 )
  • 分类:研发管理

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢