Merge pull request #7146 from lujun9972/translate-MjAxODAxMDMgQ3JlYXRpbmcgYW4gT2ZmbGluZSBZVU0gcmVwb3NpdG9yeSBmb3IgTEFOLm1kCg==

translate done: 20180103 Creating an Offline YUM repository for LAN.md
This commit is contained in:
Ezio 2018-01-13 13:19:27 +08:00 committed by GitHub
commit 170a755842
2 changed files with 108 additions and 111 deletions

View File

@ -1,111 +0,0 @@
translating by lujun9972
Creating an Offline YUM repository for LAN
======
In our earlier tutorial, we discussed " **[How we can create our own yum repository with ISO image& by mirroring an online yum repository][1]** ". Creating your own yum repository is a good idea but not ideal if you are only using 2-3 Linux machines on your network. But it definitely has advantages when you have large number of Linux servers on your network that are updated regularly or when you have some sensitive Linux machines that can't be exposed to Internet directly.
When we have large number of Linux systems & each system is updating directly from internet, data consumed will be enormous. In order to save the data, we can create an offline yum & share it over our Local network. Other Linux machines on network will then fetch system updates directly from this Local yum, thus saving data & also transfer speed also be very good since we will be on our local network.
We can share our yum repository using any of the following or both methods:
* **Using Web Server (Apache)**
* **Using ftp (VSFTPD)**
We will be discussing both of these methods but before we start, you should create a YUM repository using my earlier tutorial ( **[READ HERE][1]** )
## Using Web Server
Firstly we need to install web-server (Apache) on our yum server which has IP address **192.168.1.100**. Since we have already configured a yum repository for this system, we will install apache web server using yum command,
```
$ yum install httpd
```
Next, we need to copy all the rpm packages to default apache root directory i.e. **/var/www/html** or since we have already copied our packages to **/YUM** , we can create a symbolic link from /var/www/html to /YUM
```
$ ln -s /var/www/html/Centos /yum
```
Restart you web-server to implement changes
```
$ systemctl restart httpd
```
### Configuring client machine
Configurations for sharing Yum repository on server side are complete & now we will configure our client machine, with an IP address **192.168.1.101** , to receive updates from our created offline yum.
Create a file named **offline-yum.repo** in **/etc/yum.repos.d** folder & enter the following details,
```
$ vi /etc/yum.repos.d/offline-yum.repo
```
```
name=Local YUM
baseurl=http://192.168.1.100/CentOS/7
gpgcheck=0
enabled=1
```
We have configured your Linux machine to receive updates over LAN from your offline yum repository. To confirm if the repository is working fine, try to install/update packages using yum command.
## Using FTP server
For sharing our YUM over ftp, we will firstly install the required package i.e vsftpd
```
$ yum install vsftpd
```
Default root directory for vsftp is /var/ftp/pub, so either copy rpm packages to this folder or create a symbolic link from /var/ftp/pub,
```
$ ln -s /var/ftp/pub /YUM
```
Now, restart server for implement the changes
```
$ systemctl restart vsftpd
```
### Configuring client machine
We will now create a file named **offline-yum.repo** in **/etc/yum.repos.d** , as we did above & enter the following details,
```
$ vi /etc/yum.repos.d/offline-yum.repo
```
```
[Offline YUM]
name=Local YUM
baseurl=ftp://192.168.1.100/pub/CentOS/7
gpgcheck=0
enabled=1
```
Your client machine is now ready to receive updates over ftp. For configuring vsftpd server to share files with other Linux system , [**read tutorial here**][2].
Both methods for sharing an offline yum over LAN are good & you can choose either of them, both of these methods should work fine. If you are having any queries/comments, please share them in the comment box down below.
--------------------------------------------------------------------------------
via: http://linuxtechlab.com/offline-yum-repository-for-lan/
作者:[Shusain][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://linuxtechlab.com/author/shsuain/
[1]:http://linuxtechlab.com/creating-yum-repository-iso-online-repo/
[2]:http://linuxtechlab.com/ftp-secure-installation-configuration/

View File

@ -0,0 +1,108 @@
创建局域网内的离线 YUM 仓库
======
在早先的教程中,我们讨论了" **[如何使用 ISO 镜像和镜像在线 yum 仓库的方式来创建自己的 yum 仓库 ][1]** "。创建自己的 yum 仓库是一个不错的想法,但若网络中只有 2-3 台 Linux 机器那就没啥必要了。不过若你的网络中有大量的 Linux 服务器,而且这些服务器还需要定时进行升级,或者你有大量服务器无法直接访问因特网,那么创建自己的 yum 仓库就很有必要了。
当我们有大量的 Linux 服务器,而每个服务器都直接从因特网上升级系统时,数据消耗会很可观。为了节省数据量,我们可以创建个离线 yum 源并将之分享到本地网络中。网络中的其他 Linux 机器然后就可以直接从本地 yum 上获取系统更新,从而节省数据量,而且传输速度也会很好。
我们可以使用下面两种方法来分享 yum 仓库:
* **使用 Web 服务器 (Apache)**
* **使用 ftp (VSFTPD)**
在开始讲解这两个方法之前,我们需要先根据之前的教程创建一个 YUM 仓库( **[看这里 ][1]** )
## 使用 Web 服务器
首先在 yum 服务器上安装安装 Web 服务器 (Apache),我们假设服务器 IP 是 **192.168.1.100**。我们已经在这台系统上配置好了 yum 仓库,现在我们来使用 yum 命令安装 apache web 服务器,
```
$ yum install httpd
```
下一步,拷贝所有的 rpm 包到默认的 apache 跟目录下,即 **/var/www/html**,由于我们已经将包都拷贝到了 **/YUM** 下,我们也可以创建一个软连接来从 /var/www/html 指向 /YUM
```
$ ln -s /var/www/html/Centos /yum
```
重启 web 服务器应用变更
```
$ systemctl restart httpd
```
### 配置客户端机器
服务端的配置就完成了,现在需要配置下客户端来从我们创建的离线 yum 中获取升级包,这里假设客户端 IP 为 **192.168.1.101**
`/etc/yum.repos.d` 目录中创建 `offline-yum.repo` 文件,输入如下信息,
```
$ vi /etc/yum.repos.d/offline-yum.repo
```
```
name=Local YUM
baseurl=http://192.168.1.100/CentOS/7
gpgcheck=0
enabled=1
```
客户端也配置完了。试一下用 yum 来安装/升级软件包来确认仓库是正常工作的。
## 使用 FTP 服务器
在 FTP 上分享 YUM首先需要安装所需要的软件包即 vsftpd
```
$ yum install vsftpd
```
vsftp 的默认根目录为 `/var/ftp/pub`,因此你可以拷贝 rpm 包到这个目录或着为它创建一个软连接,
```
$ ln -s /var/ftp/pub /YUM
```
重启服务应用变更
```
$ systemctl restart vsftpd
```
### 配置客户端机器
像上面一样,在 `/etc/yum.repos.d` 中创建 **offline-yum.repo** 文件,并输入下面信息,
```
$ vi /etc/yum.repos.d/offline-yum.repo
```
```
[Offline YUM]
name=Local YUM
baseurl=ftp://192.168.1.100/pub/CentOS/7
gpgcheck=0
enabled=1
```
现在客户机可以通过 ftp 接受升级了。要配置 vsftpd 服务器为其他 Linux 系统分享文件,请[**阅读这篇指南 **][2]。
这两种方法都很不错,你可以任意选择其中一种方法。有任何疑问或这想说的话,欢迎在下面留言框中留言。
--------------------------------------------------------------------------------
via: http://linuxtechlab.com/offline-yum-repository-for-lan/
作者:[Shusain][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://linuxtechlab.com/author/shsuain/
[1]:http://linuxtechlab.com/creating-yum-repository-iso-online-repo/
[2]:http://linuxtechlab.com/ftp-secure-installation-configuration/