2-8软件包管理
8.1 配置仓库
1.配置本地仓库
#进行代码安装前需要先进行仓库配置和挂载
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vim base.repo
[baseos]
name=baseos
baseurl=/mnt/BaseOS
gpgcheck=0
[appstream]
name=appstream
baseurl=/mnt/AppStream
gpgcheck=0
测试:使用dnf/yum命令安装httpd功能
#使用dnf命令安装httpd
[root@localhost ~]# dnf -y install httpdComplete!
2.配置网络仓库
#以阿里云为例:
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vim base.repo
[baseos]
name=baseos
baseurl=https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/baseos/x86_64/
gpgcheck=0
[appstream]
name=appstream
baseurl=https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/appstream/x86_64/
gpgcheck=0
测试:使用dnf/yum命令安装httpd功能
[root@localhost ~]# dnf -y install httpdComplete!
3.挂载
#临时挂载
[root@localhost yum.repos.d]# mount /dev/sr0
mount: /mnt: /dev/sr0 already mounted on /mnt.
#永久挂载
[root@localhost ~]# vim /etc/fstab
/dev/sr0 /mnt iso9660 defaults 0 0
8.2 源码安装
以MySQL安装为例:
1.下载源码
1.在浏览器输入:www.mysql.com
2.点击:DOWNLOADS -下滑点击:MySQL Community Downloads
3.点击:MySQL Community Server
4.完成规定操作,点击Download
5.点击download下载tar包
2.安装源码
1.把下载的tar包装进虚拟机里并进行解压缩操作
#使用rz -E指令将Windows中命令传输到虚拟机中
[root@localhost ~]# rz -E#使用sz命令可以将虚拟机中文件传输到Windows中[root@localhost ~]# sz 文件名#查看文件传输所需软件包(没有的话需要下载)[root@localhost ~]# rpm -qa |grep lrzlrzsz-0.12.20-55.el9.x86_64
#解压tar包
[root@localhost ~]# tar -zxvf mysql-9.1.0.tar.gz
#将tar包和解压后的目录存放到新建目录,便于后续操作
[root@localhost ~]# mkdir -p ./mysql
[root@localhost ~]# mv mysql-9.1.0 mysql-9.1.0.tar.gz ./mysql
2.进入解压包,查看安装手册
#进入目录
[root@localhost ~]# cd mysql/
#进入解压包
[root@localhost mysql]# cd mysql-9.1.0/
#查看安装手册
[root@localhost mysql-9.1.0]# ll
-rw-r--r--. 1 7161 31415 333 Sep 24 19:37 INSTALL
[root@localhost mysql-9.1.0]# cat INSTALL
You can find information about how to install from a source distribution athttp://dev.mysql.com/doc/refman/8.0/en/source-installation.html
3.在浏览器中输入安装手册网址-多次下滑点击 NEXT>
4.回到虚拟机继续完成安装操作
#创建bld目录
[root@localhost mysql-9.1.0]# mkdir bld
#进入bld目录
[root@localhost mysql-9.1.0]# cd bld
#执行cmake ..命令
[root@localhost bld]# cmake ..
bash: cmake: command not found...
Install package 'cmake' to provide command 'cmake'? [N/y]
5.安装cmake服务
[root@localhost bld]# dnf -y install cmakeComplete!
6.继续执行cmake命令
[root@localhost bld]# cmake ..
#被告知需要安装需求包
CMake Warning at CMakeLists.txt:398 (MESSAGE):You need to install the required packages:yum install gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ gcc-toolset-13-binutils gcc-toolset-13-annobin-annocheck gcc-toolset-13-annobin-plugin-gccCMake Error at CMakeLists.txt:400 (MESSAGE):Or you can set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.
7.安装需求包
#先安装C语言编译环境
[root@localhost bld]# dnf install -y make gcc*
#安装需求包
[root@localhost bld]# yum install gcc-toolset-13-gcc gcc-toolset-13-gcc-c++
gcc-toolset-13-binutils gcc-toolset-13-annobin-annocheck gcc-toolset-13-
annobin-plugin-gcc
8.继续执行cmake命令
[root@localhost bld]# cmake ..
#错误,请先安装需求包
CMake Error at cmake/ssl.cmake:85 (MESSAGE):Please install the appropriate openssl developer package.
9.安装需求包
#在系统中查找需求包
[root@localhost bld]# dnf list |grep openssl-devel
openssl-devel.i686 1:3.0.7-24.el9 appstream
openssl-devel.x86_6 1:3.0.7-24.el9 appstream
#安装需求包
[root@localhost bld]# dnf -y install openssl-develComplete!
10.再次执行cmake命令
#执行cmake命令
[root@localhost bld]# cmake ..
#错误,需要先安装需求包
CMake Error at cmake/readline.cmake:93 (MESSAGE):Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is
libncurses5-dev, on Redhat and derivates it is ncurses-devel.
11.安装需求包
[root@localhost bld]# dnf -y install ncurses-devel
12.再次执行cmake命令
#再次执行cmake命令
[root@localhost bld]# cmake ..
#错误,需安装需求包
CMake Warning at cmake/rpc.cmake:41 (MESSAGE):Cannot find RPC development libraries. You need to install the requiredpackages:RedHat/Fedora/Oracle Linux: yum install libtirpc-devel
13.安装需求包
[root@localhost bld]# yum install libtirpc-devel
#出现错误,在本地仓库找不到需求包
No match for argument: libtirpc-devel
Error: Unable to find a match: libtirpc-devel
14.在网上搜索安装包
#在浏览器输入网址:pkgs.org
#进入网址后输入搜索软件包,并查找对应版本并点击#通过rpm命令查看所需版本[root@localhost bld]# rpm -qa |grep libtirpclibtirpc-1.3.3-2.el9.x86_64
#下滑至Download并复制链接
https://mirror.stream.centos.org/9-stream/CRB/x86_64/os/Packages/libtirpc-devel-1.3.3-2.el9.x86_64.rpm
#回到虚拟机执行wget命令下载链接
[root@localhost bld]# wget https://mirror.stream.centos.org/9-stream/CRB/
x86_64/os/Packages/libtirpc-devel-1.3.3-2.el9.x86_64.rpm
#查看并安装需求包
[root@localhost bld]# ll
-rw-r--r--. 1 root root Jun 7 2023 libtirpc-devel-1.3.3-2.el9.x86_64.rpm
[root@localhost bld]# rpm -i libtirpc-devel-1.3.3-2.el9.x86_64.rpm
15.再次执行cmake命令
#又出错了,缺少需求包
CMake Warning at cmake/rpc.cmake:30 (MESSAGE):Cannot find rpcgen executable. You need to install the required packages:RedHat/Fedora/Oracle Linux: yum install rpcgen
16.安装需求包
[root@localhost bld]# yum install rpcgen
17.再次执行cmake命令
#最终cmake命令执行完毕
[root@localhost bld]# cmake ..
18.执行make命令和make install命令
#这一步需要耗费极长时间,中途可以按Ctrl+c退出(系统会保存)
[root@localhost bld]# make