CentOS7.9-virtual machine yum source environment configuration (local/network)

1. Configure the local yum source

1. Connect the system image to the cdrom, and mount the image file to /mnt/cdrom

#Mount image file

mkdir -p /mnt/cdrom

mount /dev/cdrom /mnt/cdrom

2. Configure the yum source file

#Local yum source configuration

cd /etc/yum.repos.d/

touch centos79.repo

you centos79.repo

        [centos79]

        name=centos79

        baseurl=file:///mnt/cdrom

        enabled=1

        gpgcheck=0

yum clean all        #clear yum cache

Yum repolist        #Display all yum warehouses

Note: This configuration method is convenient for temporarily using the yum source. After restarting, the configuration will fail due to the problem of hanging. If you want to make the configuration not invalid, you can add the hanging information in fstab. The method is as follows:

we /etc/fstab

        /dev/cdrom     /var/www/html/RedHat     iso9660 defaults       0 0

#Make the new configuration of the fstab file take effect immediately

mount -a   

=========================================================================

2. Example of network yum source configuration in intranet environment

#Server 1 (192.168.2.64) starts httpd service to build yum source

#Install and start http service

yum install -y httpd

systemctl start httpd

systemctl enable httpd

# close the firewall

systemctl stop firewalld

systemctl disable firewalld

#Create system file mount path and mount

mkdir -p /var/www/html/RedHat

mount /dev/cdrom /var/www/html/RedHat

we /etc/fstab

  /dev/cdrom      /var/www/html/RedHat            iso9660 defaults        0 0

#Browser access http://192.168.2.64/RedHat/

#Configure yum source

vi /etc/yum.repos.d/redhat79.repo

        [redhat79]

        name=redhat79

        baseurl=file:///var/www/html/RedHat/

        enabled=1

        gpgcheck=0

yum clean all        #clear yum cache

Yum repolist         #Display all yum warehouses

#Server 2 (192.168.2.65) accesses the yum source of the intranet network

vi /etc/yum.repos.d/CentOS79.repo

        [CentOS79]

        name=CentOS79

        baseurl=http://192.168.2.64/RedHat/

        enabled=1

        gpgcheck=0

yum clean all        #clear yum cache

Yum repolist         #Display all yum warehouses

========================================================================= 

3. Example of configuring network yum source and installing EPEL source

#Here, take the Ali yum source as an example, download Ali’s CentOS-Base.repo to /etc/yum.repos.d/, you can directly download and upload it to the official website to the /etc/yum.repos.d/ directory, or you can directly Download (Note: Here you can back up the local yum file in this directory for subsequent recovery, or take a virtual machine snapshot before operation)

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all        #clear yum cache

yum makecache   #generate refresh cache

#Install EPEL source

yum install -y epel-release

yum clean all          #clear yum cache

yum makecache     #generate refresh cache

Yum repolist             #Display all yum warehouses

Guess you like

Origin blog.csdn.net/qq_54952827/article/details/130252659
Recommended