CentOS-6下搭建本地yum仓库, 采用NFS服务
2014-04-22 18:17
676 查看
由于服务器不能联网, 不能通过网络利用yum进行软件安装, 所以就考虑搭建一个本地仓库, 供服务器安装软件. 本文会解释如何创建一个 NFS 分享,然后容让其它相同发行版本的系统以统一的方式访问这些组件.
当然也可以用其它方式提供软件库的访问权,例如 HTTP 及/或 FTP 服务器。
一. 前提
(1) Centos6.5 镜像文件, 在centos 官网下载即可(2) 安装了Centos6.5系统的电脑
(3) 配置该电脑的ip与服务器在同一个局域网内, 假设client: 10.200.4.40, server: 10.25.0.38
二. 步骤
本文以x86_64 结构的 CentOS6为例, 该方法亦适用于其它结构及版本。1. 准备工作
(1) 首先在服务器上创建目录结构,:[root@server ~]# mkdir -p /share/CentOS/6/local/x86_64/RPMS(2) 安装createrepo
[root@server1 ~]# yum install createrepo(3) 挂载Centos6.5 镜像文件
[root@server ~]# mkdir /media/centos6 [root@server ~]# mount –o loop –t iso9660 mount –o loop –t iso9660 /media/centos6
2. 使用createrepo命令创建yum仓库
(1) 将所有rpm文件拷贝到本地仓库文件夹下 [3][root@server ~]# cp -rv /media/centos6/Packages/* /share/CentOS/6/local/x86_64/RPMS
/media/centos6/repodata/*comps*的还存在分组信息, 创建文件夹comps, 用以下命令就完成了yum仓库的建立, 如果没有分组信息则按照(2)执行 ...
[root@server ~]# cp -rv /media/centos6/repodata/*comps* ~/comps/ [root@server ~]# createrepo -g ~/comps/*-comps.xml /share/CentOS/6/local/x86_64
(2) create metadata [1]
[root@server ~]# chown -R root.root /share/CentOS/6/local [root@server ~]# createrepo /share/CentOS/6/local/x86_64 [root@server ~]# chmod -R o-w+r /share/CentOS/6/local如果有新rpm被加进软件库时,请重复以上第2步。
3. 创建 /etc/yum.repos.d/local.repo
(1) 创建llocal.repo, 并设置以下配置[local] name=CentOS-6 - local packages for x86_64 baseurl=file:///share/CentOS/6/local/x86_64 enabled=1 gpgcheck=0 protect=1
(2) 本机测试
yum install gcc
4. 配置NFS服务器
(1) 安装[root@server ~]# yum install nfs-utils portmap (适用centos 5) [root@server ~]# yum install nfs-utils rpcbind (适用centos 6)(2) NFS文件配置, 具体参数见[4]
[root@server ~]# vi /etc/exports /share 10.200.4.40/24(rw,async)
使配置生效:
[root@server ~]# exportfs -r
(3) 设置开机自启动
[root@server ~]# /etc/init.d/rpcbind start && chkconfig --level 2345 rpcbind on [root@server ~]# /etc/init.d/nfs start && chkconfig --level 2345 nfs on
5. 配置NFS客户端
(1) 查看服务端共享的目录[root@server ~]# showmount -e 10.25.0.38 #查看服务端共享的目录 Export list for 10.25.0.38: /share 10.200.4.40(2) 若遇到以下错误
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)是由于防火墙的问题, 重新进server端, 请参考 [5]解决, 这里只对关键步骤摘录
(a) Edit the NFS port definitions file
vi /etc/sysconfig/nfsUn-comment the following lines and save the file.
LOCKD_TCPPORT=32803 LOCKD_UDPPORT=32769 MOUNTD_PORT=892(b) Lets go about sticking 2 new rules at the beginning of the INPUT chain that allows our NFS and RPC services to work.
iptables -I INPUT -m state --state NEW -p tcp \ -m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT iptables -I INPUT -m state --state NEW -p udp \ -m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT(c) Lets save our iptables config to make it persistent through reboots
service iptables save
(3) 挂载
[root@client ~]# mount -t nfs 10.25.0.38:/share /share(4) 设置开机自动挂载
[root@client ~]# vi /etc/fstab 10.25.0.38:/share /share nfs defaults 1 2
6. 若想通过HTTP 及/或 FTP 服务器创建本地仓库可参考以下文章(未验证)
(1) 搭建本地yum仓库 第2部分(2)
搭建本地yum软件仓库
Reference
[1] 创建本地软件库[2] Create Local Repos
[3] Centos6.4建立本地yum源
[4] CentOS 6.4安装配置NFS服务器
[5] Tutorial – Configure IPTables for NFS Server on CentOS 6
[6] Centos 6.3安装NFS服务器配置及挂载教程
相关文章推荐
- Centos 7 搭建本地yum源(离线yum仓库)
- CentOS 7下 YUM 本地仓库的搭建
- CentOS 7下YUM 本地仓库的搭建详细步骤
- centos 创建本地yum源搭建本地yum仓库 亲测可用
- centos 7 搭建本地yum仓库
- centOS搭建本地yum
- Centos7 mount/ rpm/ yum 软件仓库搭建
- 搭建本地yum仓库
- vsftpd-本地yum仓库搭建介绍
- centos 6 nfs服务的搭建
- linux通过挂载系统光盘搭建本地yum仓库的方法
- 软件安装和卸载(rpm、yum工具),yum搭建本地仓库
- 5周第1次课 安装软件包的三种方法 rpm包介绍 yum工具用法 yum搭建本地仓库
- NFS文件共享服务搭建(ubuntu-centos)
- 通过挂载系统光盘搭建本地yum仓库的方法
- 本地Yum仓库搭建部署
- 记一次Red Hat Linux手动搭建本地Yum仓库
- centos 的yum仓库搭建
- linux——如何搭建本地仓库 以及 httpd网络yum仓库?
- 7.1 安装软件包的三种方法7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法7.5 yum搭建本地仓库