一、实求要求:
1. CentOS 6.4为YUM源, 实现CentOS 6.4从YUM源下载RPM包
二、实验环境:
VMware + CentOS 6.4x64 (2台)
三、配置:
1. 开启CentOS 6.4, 配置静态IP地址
[[email protected] 桌面]# vim /etc/udev/rules.d/70-persistent-net.rules
[[email protected] 桌面]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 -->修改IP地址
DEVICE=eth0
HWADDR=00:0c:29:b0:59:c3 -->把刚复制的MAC地址粘贴在这
TYPE=Ethernet
UUID=94920c12-ddf1-47a2-8f34-5d8a14dc0592
ONBOOT=yes -->将NO改为yes
NM_CONTROLLED=yes
BOOTPROTO=static -->将dhcp(动态)改为static(静态)
IPADDR=192.168.1.10 -->添加IP地址
NETMASK=255.255.255.0 -->子网掩码
GATEWAY=192.168.1.1 -->默认网关
2. 修改主机名、添加本地hosts
[[email protected] 桌面]# vim /etc/sysconfig/network -->修改主机名
NETWORKING=yes
HOSTNAME=yum.y2t08.com
[[email protected] 桌面]# vim /etc/hosts -->修改本地hosts
192.168.1.10 yum yum.y2t08.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] 桌面]# reboot -->重启
[[email protected] CentOS]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:B0:59:C3
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb0:59c3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1144 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:109248 (106.6 KiB) TX bytes:900 (900.0 b)
3. 安装FTP, 挂载CentOS 6.4光盘将所有文件全部拷贝到FTP目录.
[[email protected] 桌面]# mount /dev/cdrom /media/ -->将系统盘挂载到/media (第一张盘)
[[email protected] 桌面]# cd /media/Packages -->进入到/media/Packages
[[email protected] Packages]# rpm -ivh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm -->安装FTP
[[email protected] vsftpd]# cd /var/ftp/
[[email protected] ftp]# mkdir CentOS -->在/var/ftp/下创建CentOS文件
[[email protected] ftp]# cd CentOS/
[[email protected] CentOS]# cp -rf /media/* . -->将系统盘所有文件全部拷贝到当前目录
[[email protected] CentOS]# umount /dev/cdrom -->卸载光盘, 挂载另外一张光盘
[[email protected] CentOS]# mount /dev/cdrom /media/ -->这是另外一张系统盘(第二张盘)
[[email protected] CentOS]# cp -rf /media/* . --> 拷贝时,提示是否覆盖, 输入“N”. 不覆盖
cp:是否覆盖"./CentOS_BuildTag"? n
cp:是否覆盖"./EULA"? n
cp:是否覆盖"./Packages/TRANS.TBL"? n
cp:是否覆盖"./RPM-GPG-KEY-CentOS-6"? n
cp:是否覆盖"./RPM-GPG-KEY-CentOS-Debug-6"? n
cp:是否覆盖"./RPM-GPG-KEY-CentOS-Security-6"? n
cp:是否覆盖"./RPM-GPG-KEY-CentOS-Testing-6"? n
cp:是否覆盖"./TRANS.TBL"? N
4. 搭建YUM源
[[email protected] CentOS]# vim /etc/yum.repos.d/CentOS-Base.repo
[base] -->仓库类别
name=CentOS-$releasever - Base -->仓库名称
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ -->URL访问路径
gpgcheck=1 -->验证软件包的签名
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 ->GPG公钥文件位置
改为:
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=ftp://192.168.1.10/CentOS -->URL访问路径 这是要改的地方
或者填写本地路径:baseurl=file:///var/ftp/CentOS
网站路径:baseurl=htp://XXXXXXXX
[[email protected] CentOS]# yum -y clean all -->清除yum缓存
[[email protected] CentOS]# service vsftpd start -->开启ftp服务
[[email protected] 桌面]# iptables -F -->清除清空所有规则
[[email protected] 桌面]# iptables -X -->删除自定义链
[[email protected] 桌面]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
[[email protected] 桌面]# yum -y install php -->yum安装php
[[email protected] ~]# yum list -->查询软件包列表
[[email protected] ~]# yum info httpd -->查询软件包的描述信息