搭建本地yum源

  • 安裝web服務器

yum install -y nginx

cd /etc/nginx

vim conf.d/virtual.conf

server {

listen 80;

server_name mirrors.xdbigdata.com;

autoindex on;

location / {

root /mnt/sdb/html/mirrors;

index index.html index.htm index.php;

}

}

sed -i '1,$d' conf.d/default.conf

mkdir /mnt/sdb/html/mirrors -p

/etc/init.d/nginx start

  • 找阿里雲同步rpm包

yum repolist

cd /mnt/sdb/html/mirrors

reposync -r base

reposync -r epel

reposync -r extras

reposync -r updates

  • 創建索引文件

yum install -y createrepo

生成索引repodata

createrepo -p -d -o base/ base/Packages/

createrepo -p -d -o epel/ epel/

createrepo -p -d -o extras/ extras/Packages/

createrepo -p -d -o updates/ updates/Packages/

  • 編輯創建repo文件

設置yum源時應該把url地址路徑設置到repodata的上級目錄的那一級,設置repo id和repo name以及路徑

cd /etc/yum.repos.d/

vim local.repo

[baselocal]

name=baselocal

baseurl=http://mirrors.xdbigdata.com/base

enabled=1

gpgcheck=0

[epellocal]

name=epellocal

baseurl=http://mirrors.xdbigdata.com/epel

enabled=1

gpgcheck=0

[extraslocal]

name=extraslocal

baseurl=http://mirrors.xdbigdata.com/extras

enabled=1

gpgcheck=0

[updateslocal]

name=updateslocal

baseurl=http://mirrors.xdbigdata.com/updates

enabled=1

gpgcheck=0

配置主機解析/etc/hosts,只要需要這個yum源來下載東西,都必須填寫這個主機解析,如果仍然需要用到阿里源,上面的名稱不能和阿里源一樣

192.168.2.2 mirrors.xdbigdata.com

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章