Yum is too slow to bear? That's because you didn't

Posted by damisi on Thu, 27 Jan 2022 08:19:35 +0100

preface

yum is a Shell front-end package manager in Fedora, RedHat and SUSE.
Based on RPM package management, it can automatically download and install RPM packages from the specified server, automatically handle dependencies, and install all dependent software packages at one time without tedious downloading and installation.
We usually use the yum install command to install the software packages of related systems online. Yum installation can automatically handle the dependencies related to the software packages, and install all the dependent software packages at one time. As we all know, downloading software from foreign websites is very slow, and many things cannot be downloaded. Therefore, some large domestic companies will make relevant synchronization of foreign software, so we can also download relevant software by using the domestic download address, and the speed will be much faster than that from foreign websites

1, yum source configuration mode

1. System local yum source

Usually, the installation image of linux system contains the commonly used RPM software package; When networking is not possible, we can consider using our own local CD as the yum source to install the relevant required software packages. The configuration of the local Yum source is as follows:

[root@localhost ~]# mkdir /mnt/dvd / / create a CD mount point directory. We will mount our CD image to this directory later
[root@localhost ~]# mount /dev/cdrom /mnt/dvd / / mount the CD image to the mount point directory
[root@localhost ~]# rm -rf /etc/yum.repos.d/* 		// Delete the yum source configuration file from the system
 be careful: yum The source profile must be.repo ending
[root@localhost ~]# vi /etc/yum.repo.d/local.repo / / create a local Yum source configuration file
[local]      //Unique identifier. Note: no special characters
name=centos 	//yum source description information can be filled in according to your own situation
baseurl=file:///mnt/dvd 			// The mount location of yum software warehouse should point to the image mount point directory at that time
enabled=1		//Whether to start immediately. 1 is on and 0 is not on
gpgcheck=0				//Whether to check the signature. 1 means detection and 0 means no detection
[root@localhost ~]# yum clean all / / clear yum cache
[root@localhost ~]# yum repolist 	// Lists the number of rpm packages available

2. Network yum source (Alibaba cloud yum source)

Need networking

[root@localhost ~]# rm -rf /etc/yum.repos.d/* 		// Delete the yum source configuration file from the system
[root@localhost ~]# cd /etc/yum.repos.d 			// Enter Yum's folder
[root@localhost ~]# wget  -o Centos. repo  http://mirrors.aliyun.com/repo/Centos-7.repo //Use the WGet command to download alicloud repo files
[root@localhost ~]# yum clean all / / clear cache
[root@localhost ~]# yum makecache / / reload cache
[root@localhost ~]# yum repolist 	// Lists the number of rpm packages available

3. Customize yum source

[root@localhost ~]# yum -y install createrepo 		// Install the createrpo package
[root@localhost ~]# mkdir /other_repo/tools 		// Create a custom yum warehouse folder
[root@localhost ~]# mv *.rpm 	/ other_rpeo/tools 	// Collect all RPM packages you downloaded from the Internet into a customized yum warehouse folder
[root@localhost ~]# createrepo 	/ other_repo/tools 	// Automatically generate warehouse data files according to software package collection
[root@localhost ~]# vi /etc/yum.repos.d/centos.repo / / add Yum profile
[tools]  		//Unique identification
name=this is my tools		//Description information
baseurl=file:///other_repo/tools 		//// yum software warehouse points to the custom yum warehouse
enabled=1	//Enable now, 1 is enabled, 0 is not enabled
gpgcheck=0		//Whether to detect the signature. 1 means to detect, 0 means not to detect
[root@localhost ~]# yum clean all / / clear yum cache
[root@localhost ~]# yum repolist 	// List the available Yum source warehouses and the number of rpm packages

2, Self built yum source server

In the process of project implementation, many projects have no external network. At this time, we can set up the yum source server locally for convenience, which can make us install the software more conveniently and quickly. Moreover, our intranet source server can not only be used by the building machine, but also be shared by the whole intranet server

1. Build source server

① Mount the required directory and set the boot auto mount
[root@localhost ~]# mkdir -p /var/www/html  	// Create default path of apache Web page
[root@localhost ~]# cd /var/www/html 	// Switch to the default path of the web page
[root@localhost ~]# mkdir centos-1804 	 other 	// Create a mount directory for mounting CDs and packages
[root@localhost ~]# mount -t iso9660 -o ro,loop /dev/cdrom 	/ var/www/html/centos-1804 	// Mount the local CD to / var / www / HTML / centos-1804
[root@localhost ~]# mkdir /mnt/tools 	// Create a custom yum warehouse directory
[root@localhost ~]# mv *.rpm 	/ mnt/tools 	// Move all RPM packages downloaded from the Internet to the custom warehouse directory
[root@localhost ~]# mount -t iso9660 -o ro,loop /mnt/tools 	/ var/www/html/other / / mount the custom yum warehouse directory to / var/www/html/other
[root@localhost ~]# vi /etc/rc.d/rc.local 	// Append the temporarily mounted command to RC Local file
mount -t iso9660 -o ro,loop /dev/cdrom	/var/www/html/centos-1804
mount -t iso9660 -o ro,loop /mnt/tools	/var/www/html/other
[root@localhost ~]# chmod +x /etc/rc.d/rc.local 		// Add executable permissions to files

② Configure local yum source
[root@localhost ~]# vi /etc/yum.repo.d/local.repo / / create a local Yum source configuration file
[local]      //Unique identifier. Note: no special characters
name=centos 	//yum source description information can be filled in according to your own situation
baseurl=file:///var/www/html/centos-1804 		// The mount location of yum software warehouse should point to the image mount point directory at that time
enabled=1		//Whether to start immediately, 1 is on, 0 is not on
gpgcheck=0				//Whether to check the signature. 1 means detection and 0 means no detection
[root@localhost ~]# yum clean all / / clear the yum cache
[root@localhost ~]# yum repolist 	// Lists the number of rpm packages available
③ Install the httpd package and set the service to start automatically
[root@localhost ~]# yum -y install httpd / / install httpd package
[root@localhost ~]# systemctl start httpd 	// Start httpd service
[root@localhost ~]# systemctl enable httpd / / set the httpd service to start automatically

2. Client yum source configuration mode

[root@localhost ~]# rm -rf /etc/yum.repos.d/* 		// Delete the yum source configuration file from the system
[root@localhost ~]# vi centos.repo 		// Create network yum source
[centos-1804]
name=centos-1804
baseurl=http://Source server ip/centos-1804
enabled=1
gpgcheck=0

[other]
name=other
baseurl=http://Source server ip/other
enabled=1
gpgcheck=0
[root@localhost ~]# yum clean all / / clear the yum cache
[root@localhost ~]# yum repolist 	// Lists the number of rpm packages available

3, Explain related commands using yum

commandnotes
yum listQuery all installed and installable packages
yum search keywordFind all packages related to keywords from yum source server
yum info package nameQuery execution package details
yum -y install package nameInstall the package. If - y is not added, each installed software needs to answer yes manually, and - y means yes automatically
yum -y update package nameUpgrade the software package (ensure that the version of the software package in the yum source is higher than the version of the software package installed on this machine)
yum -y remove package nameUninstall the software package, - y means that all other software packages that depend on the package will be uninstalled at the same time
yum groupinfo software group nameQuerying packages contained in a software group
yum groupinstall software group nameInstall the specified software group
yum groupremove software group nameUninstall the specified software group

Topics: Linux Operation & Maintenance CentOS yum http