Configure local yum source

Recently, when configuring zabbix, I encountered the problem that CentOS could not connect to the network. I searched for a method to configure the local yum source, which is hereby recorded.

1. Network installation preprocessing

       Configure cache, modify /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache = 1 #Modify to 1, save the cache

2. Make the installation package

#yum install createrepo -y

#mkdir /opt/CentOS7.3_mitaka_rpm_controller
 
#find /var/cache/yum/x86_64/ -name *.rpm |xargs -i cp {} /opt/CentOS7.3_mitaka_rpm_controller

#createrepo /opt/CentOS7.3_mitaka_rpm_controller

#tar -zcvf /root/CentOS7.3_mitaka_rpm_controller.tar.gz /opt/CentOS7.3_mitaka_rpm_controller

3. Preprocessing using the local installation package: --CentOS7.3_mitaka_rpm_compute.tar.gz

#cd /mnt --- Upload CentOS7.3_mitaka_rpm_controller.tar.gz

Fourth, decompress

tar -zxvf CentOS7.3_mitaka_rpm_controller.tar.gz

5. Delete the network installation source

Need to enter /etc/yum.repos.d/ under the path

cd /etc/yum.repos.d/

perform actions in sequence

mkdir bak_repo_bak

mv * .repo bak_repo_bak

In the current path (/etc/yum.repos.d/), create a new repo.repo file

vi repo.repo

Write the following content to the repo.repo file and: wq! save and exit

[repo]

name=repo

baseurl = file: /// mnt/opt/CentOS7.3_mitaka_rpm_controller/ 

gpgcheck = 0

enabled=1

proxy=_none_

6. Test

Execute the following command to test, if there is a normal echo, if an error is reported, check whether the configuration file and file path are correct.

# yum repolist

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325022441&siteId=291194637