1. 程式人生 > >yum-本地源一鍵配置

yum-本地源一鍵配置

/dev/cdrom —-本地映象掛載路徑,如果是拷貝到伺服器上的需要更改路徑
baseurl=file:///mnt/iso/ —–rhel5 需要新增Server
直接全量複製貼上介面快速建立本地yum源

mkdir /mnt/iso
mkdir /etc/yum.repos.d/old/
mv  /etc/yum.repos.d/* /etc/yum.repos.d/old/
touch /etc/yum.repos.d/local.repo 
cat >/etc/yum.repos.d/local.repo<<EOF
[base]
name=CentOS
baseurl=file:///mnt/iso/
gpgcheck
=0 enabled=1 EOF mount -o loop /dev/cdrom /mnt/iso yum list

附加:
如果出現下面問題需要刪除 :
rm /var/run/yum.pid

yum list
Failed to set locale, defaulting to C
Loaded plugins: product-id, security, subscription-manager
Updating Red Hat repositories.
Existing lock /var/run/yum.pid: another copy is running as pid 8534.
Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 34 M RSS (248 MB VSZ) Started: Thu Mar 2 10:40:35 2017 - 00:06 ago State : Traced/Stopped, pid: 8534