CentOS 7 build local yum yum source and LAN source

Two days in the deployment of the company's test environment, when you install a variety of middleware, various dependencies are not found; later a check and found that the installation of the operating system is CentOS Mini version, well, I recognized; in order to complete the test built environment, I set up a LAN yum source. Originally set up local yum source is not much difficulty, a lot of online articles, and here I am writing this article is mainly prepared to give junior partner in the group to do the training, then one would like, simply to write a complete , publish it directly to the blog, and share with friends.

I am sure you will encounter more or less at work using yum source; in our company, including network servers, so we need to build yum source LAN, yum source when it comes to construction, mainly in the following two ways:

  • Build local yum source
  • Set up a local area network yum source

Nothing more than these two, here are two ways to build these yum source summarized.

Build local yum source

Local sources yum, yum meant only to build the source of this server can be used, other servers can not use the yum source. All steps up a local source yum follows:

# 在/mnt目录创建挂载镜像的文件夹
cd /mnt mkdir iso # 将iso镜像挂载到/mnt/iso目录 mount -o loop CentOS-7-x86_64-DVD-1810.iso /mnt/iso # 挂载成功后可以使用df -h命令查看 [root@192.168.1.2 iso]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 29G 5.3G 23G 19% / devtmpfs 484M 0 484M 0% /dev tmpfs 496M 0 496M 0% /dev/shm tmpfs 496M 6.8M 489M 2% /run tmpfs 496M 0 496M 0% /sys/fs/cgroup /dev/sda1 1014M 132M 883M 13% /boot tmpfs 100M 0 100M 0% /run/user/0 tmpfs 100M 0 100M 0% /run/user/1000 /dev/loop0 4.3G 4.3G 0 100% /mnt/iso # 修改yum配置文件 cd /etc/yum.repos.d # 先备份配置文件 mkdir bak mv *.repo ./bak # 将备份的CentOS-Media.repo文件拷贝出来 cp ./bak/CentOS-Media.repo ./ # 修改CentOS-Media.repo配置文件,修改后内容如下: [c7-media] name=CentOS-$releasever - Media #baseurl=file:///media/CentOS/ # file:///media/cdrom/ # file:///media/cdrecorder/ baseurl=file:///mnt/iso/ gpgcheck=1 enabled=1 # 设置为1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Thus setting up a local operation is complete source yum, yum then we clear the existing information:

yum clean all

In this way, a new source of local yum ready to use.

Set up a local area network yum source

In addition to setting up a local source outside yum, yum source we can also configure HTTP-based way, so that we can configure yum source can be used within a LAN.

Usually to build by Nginx yum source HTTP, first set up Nginx, I will not elaborate here on how to build a Nginx. Next iso image files to a directory. Now, we can configure Nginx configuration files:

worker_processes  1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8080; server_name localhost; location / { autoindex on; root /home/jelly/iso/; # (这里请换成你的实际目录路径) } } }

Finally, we begin to configure yum configuration file, /etc/yum.repos.dcalled a new Nginx-yum.repoconfiguration file, as follows:

[Nginx-yum] name=Nginx-yum #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=http://192.168.1.3:8080 enabled=1 gpgcheck=1 gpgkey=http://192.168.1.3:8080/RPM-GPG-KEY-CentOS-7

So far set up local area network yum source of the operation is complete, then we clear the existing yum information:

yum clean all

In this way, a new local area network can use the yum source.

to sum up

The article detailed summary of the two methods set up yum source by methods summarized in this article, sufficient to meet the needs of our daily work. Well, something small, but very useful, I hope this summary of the content to be helpful, if felt pretty good, you can click the "a reward" Oh.

Guess you like

Origin www.cnblogs.com/weifeng1463/p/12013693.html