關閉防火牆,關閉SElinuxhtml
實驗環境:
一臺HP DL380 G7 服務器,300G硬盤,RHEL7.0 64位操做系統 IP地址:10.49.128.96
須要提早安裝的程序包:
yum-utils (包含reposync命令)
createrepo 編輯yum庫工具
nginx 或httpdlinux
刪除/etc/yum.repos.d/下的原有.repo文件
touch rhel-debuginfo.repo
編輯rhel-debuginfo.repo 輸入如下內容:nginx
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7apache
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7centos
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/7/extras//$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7緩存
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/7/centosplus//$basearch/
gpgcheck=1
enabled=0服務器
刷新緩存:
yum clean all
yum makecacheide
yum install epel-release -y
yum install yum-utils createrepo -y
yum install nginx -y 或者yum install httpd -y工具
yum repolistui
創建rpm庫存放目錄:
mkdir -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
開始同步下載rpm包:
reposync --repoid=base -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=extras -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=updates -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
reposync --repoid=epel -p /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/
( 使用--repoid 選項會鏡像相應程序包,並建立與--repoid=xx 指定值 同名的文件夾)
建立索引:( createrepo -po 源目錄 索引元數據的輸出位置目錄)
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/base/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/extras/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/updates/Packages
createrepo ./
cd /home/benddijingxiangyuan/wangyi163/CentOS/7/64bit/epel/Packages
設置http服務的根目錄:
方案一:使用nginx提供http服務;
server {
listen 80;
server_name localhost;
root /home/benddijingxiangyuan;
#charset koi8-r;
#access_log logs/host.access.log main; location / { autoindex on; autoindex_exact_size off; autoindex_localtime on; }
方案二:使用httpd(apache)提供http服務:
註釋/etc/httpd/conf/httpd.conf文件中的 DocumentRoot "/var/www/html" 這行
建立目錄/var/log/httpd/bengdiyumyuam/
在/var/log/httpd/bengdiyumyuam/中建立文件,yum_access_log和yum_error_log
在/etc/httpd/conf.d中建立文件Bendiyumyuan.conf,內容以下:
<VirtualHost 10.49.128.96:80>
ServerName localhost
DocumentRoot "/home/benddijingxiangyuan/wangyi163/CentOS/7/64bit"
CustomLog /var/log/httpd/bengdiyumyuam/yum_access_log combined
ErrorLog /var/log/httpd/bengdiyumyuam/yum_error_log
LogLevel warn
<Directory "/home/benddijingxiangyuan/wangyi163/CentOS/7/64bit">
Options Indexes
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
在客戶端服務器/etc/yum.repos.d/下建立local.repo文件,內容以下:
[base]
name=local-Base(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/base/Packages
enabled=1
gpgcheck=0
[updates]
name=local-Updates(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/updates/Packages
enabled=1
gpgcheck=0
[extras]
name=local-Extras(GDS)
baseurl=http://10.49.128.96/wangyi163/CentOS/7/64bit/extras/Packagesenabled=1gpgcheck=0