1. Introduction to yum source
yum is a software update mechanism built on RPM packages (the abbreviation of Red Hat Package Manager Red Hat Package Manager), which can automatically resolve dependencies between software packages.
Yum consists of a warehouse and a client, that is, the entire Yum consists of two parts, so Yum can be stored on two servers. It can also be stored on a server. There can be an official service, or it can be provided by a third party, such as Alibaba Cloud, Sohu Cloud, and some non-profit organizations such as schools.
The official source is generally abroad, and the download speed is definitely limited. Manually changing it to the domestic cloud can greatly improve the download speed.
2. YUM related commands
1. Query the software that needs to be installed
//Show available installation packages (show all installation packages without adding software name)[root@localhost ~]# yum list software name //Show installation package details[root@localhost ~]#yum info software name // Find relevant software installation packages based on keywords[root@localhost ~]#yum search keywords // Find which software provides a command[root@localhost ~]#yum whatprovides Command name
2. Install the software
[root@localhost ~]# yum [Options] install software name -y All prompt informationyes -q The installation process is not displayed
3. Uninstall the software
//Uninstalling installed software must add the software name[root@localhost ~]# yum remove httpd //View the history usage records, select IDs 1, 2, 3, 4, 5, you can use yum history undo 4 to uninstall. This compares the advantage of removing, which is that you can delete all dependencies[root@localhost ~]# yum history [root@localhost ~]# yum history undo 3 //3 represents id number //If you regret it, you can use two ways to uninstall ityum history redo 4 (Reinstall it again) Use againyum history undo 6 (反悔卸载等于Reinstall it again)
4. Others
//Download only the installation package [root@localhost ~]# yum install --downloadedonly --downloaddir=save path //Clear the yum cache directory [root@localhost ~]# yum clean all //Re-create metadata after creating a new yum source[root@localhost ~]# yum makecache //Show all yum sources [root@localhost ~]# yum repolist all
3. YUM configuration file
Main configuration file location /etc//
[root@localhost ~]#vim /etc// [main] cachedir=/var/cache/yum/$basearch/$releasever --yumDownloadedRPMPackage cache directory keepcache=0 --Whether to save the cache 0It means not to save,1Save debuglevel=2 --Just understand the debug level logfile=/var/log/ --Log file location exactarch=1 --Whether different versions are allowedrpmInstall obsoletes=1 --update Whether a parameter of the old version can be run gpgcheck=1 --Verify the key plugins=1 --Is it possible to allow plugins installonly_limit=5 --Save several kernels bugtracker_url=/set_project.php?project_id=23&ref=/bug_report_page.php?category=yum distroverpkg=centos-release
Source configuration file location /etc//
[root@localhost2 ~]#cd /etc// //The existing yum sources are all official foreign online sources, and can be built by yourself[root@localhost2 ]#ls CentOS-x86_64
4. Manually build yum source
yum source classification:
- Local source: file://
- Online source: http:// or https://
- ftp source: ftp://
1. Build a local yum source
Reference is availableLinux installation and management software programs
2. Build an online yum source (take Alibaba Cloud yum source as an example)
//Back up the built-in yum to the[root@localhost2 ]#cd /etc/ [root@localhost2 ]#ls CentOS-x86_64 [root@localhost2 ]#mkdir [root@localhost2 ]#mv *.repo [root@localhost2 ]#ls // Create a new Alibaba Cloud yum source configuration file[root@localhost2 ]#vim [ali] name=ali baseurl=/centos/7/os/x86_64/ --Alibaba Cloud Mirror Source Address gpgcheck=0 --No verification //Add update source can be added[aliupdate] name=update baseurl=/centos/7/updates/x86_64/ gpgcheck=0 //Clear the yum cache directory and re-create metadata[root@localhost2 ]#yum clean all Plugin loaded:fastestmirror, langpacks Cleaning up software sources: ali aliupdate Cleaning up list of fastest mirrors Other repos take up 68 k of disk space (use --verbose for details) [root@localhost2 ]#yum makecache Plugin loaded:fastestmirror, langpacks Determining fastest mirrors ali | 3.6 kB 00:00:00 aliupdate | 2.9 kB 00:00:00 (1/7): ali/group_gz | 153 kB 00:00:00 (2/7): ali/primary_db | 6.1 MB 00:00:22 (3/7): ali/filelists_db | 7.2 MB 00:00:25 (4/7): ali/other_db | 2.6 MB 00:00:09 (5/7): aliupdate/filelists_db | 9.4 MB 00:00:35 (6/7): aliupdate/other_db | 1.1 MB 00:00:04 (7/7): aliupdate/primary_db | 17 MB 00:01:01 Metadata cache has been established //The software download was successfully tested[root@localhost2 ]#yum install -y mysql Plugin loaded:fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving dependencies --> Checking transactions ---> Software Package mariadb.x86_64.1.5.5.68-1.el7 Will be Install --> Resolving dependency is completed Dependency resolution ============================================================================================================================================================ Package Architecture Version source size ============================================================================================================================================================ 正在Install: mariadb x86_64 1:5.5.68-1.el7 ali 8.8 M Business Summary ============================================================================================================================================================ Install 1 Software Package Total downloads:8.8 M Installsize:49 M Downloading packages: mariadb-5.5.68-1.el7.x86_64.rpm | 8.8 MB 00:00:34 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在Install : 1:mariadb-5.5.68-1.el7.x86_64 1/1 Verification : 1:mariadb-5.5.68-1.el7.x86_64 1/1 已Install: mariadb.x86_64 1:5.5.68-1.el7 complete!
3. Build the ftp yum source
ftp server
//Download vsftp[root@localhost2 ]#yum install -y vsftpd //Open the service[root@localhost2 ]#systemctl start vsftpd //Close the firewall and selinux[root@localhost2 ~]#systemctl stop firewalld [root@localhost2 ~]#setenforce 0 //Build the ftp source (using the package in the image here) to mount it to /var/ftp/centos7[root@localhost2 ~]#cd /var/ftp [root@localhost2 ftp]#ls pub [root@localhost2 ftp]#mkdir centos7 [root@localhost2 ftp]#mount /dev/sr0 /var/ftp/centos7/ mount: /dev/sr0 Write protection,Will be mounted read-only
Client
//Close the firewall and selinux[root@localhost2 ~]#systemctl stop firewalld [root@localhost2 ~]#setenforce 0 //Back up the built-in yum to the[root@localhost1 ~]#cd /etc/ [root@localhost1 ]#ls CentOS-x86_64 [root@localhost1 ]#mkdir [root@localhost1 ]#mv *.repo / [root@localhost1 ]#ls // Create a new ftp source configuration file[root@localhost1 ]#vim [ftp] name=ftp baseurl=ftp://192.168.116.20/centos7 --Specify the source address of the ftp server (since the root directory of the remote transfer file user login is under /var/ftp, so here specifies the server address /centos7 directory, which is the server's /var/ftp/centos7 directory)gpgcheck=0 ClearyumCache directory and recreate metadata [root@localhost1 ]#yum clean all Plugin loaded:fastestmirror, langpacks Cleaning up software sources: ftp Cleaning up list of fastest mirrors Other repos take up 1.1 G of disk space (use --verbose for details) [root@localhost1 ]#yum makecache Plugin loaded:fastestmirror, langpacks Determining fastest mirrors ftp | 3.6 kB 00:00:00 (1/4): ftp/group_gz | 153 kB 00:00:00 (2/4): ftp/primary_db | 3.3 MB 00:00:00 (3/4): ftp/filelists_db | 3.3 MB 00:00:00 (4/4): ftp/other_db | 1.3 MB 00:00:00 Metadata cache has been established //The test and installation software are successful[root@localhost1 ]#yum install -y tftp Plugin loaded:fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving dependencies --> Checking transactions ---> Software Package tftp.x86_64.0.5.2-22.el7 Will be Install --> Resolving dependency is completed Dependency resolution ========================================================================================================================================================= Package Architecture Version source size ========================================================================================================================================================= 正在Install: tftp x86_64 5.2-22.el7 ftp 38 k Business Summary ========================================================================================================================================================= Install 1 Software Package Total downloads:38 k Installsize:52 k Downloading packages: tftp-5.2-22.el7.x86_64.rpm | 38 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在Install : tftp-5.2-22.el7.x86_64 1/1 Verification : tftp-5.2-22.el7.x86_64 1/1 已Install: tftp.x86_64 0:5.2-22.el7 complete!
5. Configure yum source priority
When there are both local yum sources and aliyun sources or other yum sources, we certainly hope to use the local yum source to install it first when installing the software package. When no available packages are found locally, then use the aliyun source to install the software. This involves the priority issue. The plug-ins provided by yum can solve this problem.
// Check whether the yum-plugin priority plugin is installed[root@localhost2 ~]# rpm -q No software package installed //If it is not installed, you need to install it[root@localhost2 ~]# yum install -y //If we need to use which yum source we have priority, add priority=1 field to its configuration file (the smaller the number, the higher the priority)[root@localhost2 ~]vim [local] name=local baseurl=file:///mnt/ enabled=1 gpgcheck=1 priority=1 --The smaller the number, the higher the priority
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.