關閉防火墻,關閉SElinux
實驗環境:
一臺HP DL380 G7 服務器,300G硬盤,RHEL7.0 64位操作系統 IP地址:10.49.128.96
需要提前安裝的程序包:
yum-utils (包含reposync命令)
createrepo 編輯yum庫工具
nginx 或httpd
刪除/etc/yum.repos.d/下的原有.repo文件
touch rhel-debuginfo.repo
編輯rhel-debuginfo.repo 輸入以下內容:
[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-7
#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-7
[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 makecache
yum install epel-release -y
yum install yum-utils createrepo -y
yum install nginx -y 或者yum install httpd -y
yum repolist
建立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/Packages
enabled=1
gpgcheck=0
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。