Centos7はyumをAliソースまたは別のソースに置き換えます

原則:元のyum構成ファイルを変更するか、新しいファイルを追加し(新しいファイルはインターネットから直接取得するか、コンテンツを直接コピーできます)、ネットワークソースを使用するように変更します-Alibabaソース

ネットワークソースを使用する場合は、システムがパブリックネットワークに接続できることを確認してください。接続できない場合は、CD-ROMまたはイントラネットソースを使用する必要があります。

ファイルの内容を変更するのが最も簡単です。.repo構成ファイルのURLを新しい形式に直接変更します(変数に注意してください)。

いくつかのyumソースを配置するのはあなた次第です。ただし、利用可能なソースがあることを確認してください。

現在のyumソースを表示します。

yumrepolistが有効

ポジション:

/etc/yum.repos.d/

ファイルを追加する方法を使用します。

新しいバックアップディレクトリを作成します

mkdir /etc/yum.repos.d.bak

すべてのファイルを別のバックアップディレクトリにMvします

mv * .repo ../yum.repos.d.bak/

新しい.reopファイルを作成します

vi centos-7-aliyun.repo

ファイルのコンテンツが実マシン( ' http://mirrors.aliyun.com/repo/Centos-7.repo ')からダウンロードされていない場合は、メモ帳でコピーのコンテンツを開くか、「バックアップCnetos-7。リポジトリコンテンツ」。

ただし、ダウンロードしたファイル「Cnetos-7.repo」を設定ディレクトリに直接移動することも可能です。

現在のyumソースをもう一度確認します。サフィックスは-aliyunまたは新しく追加されたソースとして表示され、最後の項目のステータス値は0ではありません。これは、接続が正常であることを意味します

基本-基本エクストラ-一時的な更新-更新

場合は 、予期せぬ 事態が発生し、「別のプログラムロックはYUM、出口へそれを待って...」強制的にクローズyumのプロセスにRM -f /var/run/yum.pidを実行します。

 

不明な点については、次のプロセスを参照してください。

步骤1
进入配置文件目录
cd /etc/yum.repos.d/

步骤2
只保留新增源的.repo文件,其他的转移到备份目录
创建备份目录
mkdir ../yum.repos.d.bak

步骤3
复制文件
cp *.repo ../yum.repos.d.bak/

步骤4
(此步骤-方式1)删除当前目录的.repo文件,再新建一个.repo文件。为了方便,直接改一个文件的名字,在删除的时候保留下来
用mv改名,比如随便找一个CentOS-Base.repo,改名不是必须的,是为了看到文件名就能知道是什么源。
mv CentOS-Base.repo 1
rm -f *.repo

编辑文件内容,再把名字改成后缀为.repo
vi 1
清空内全部容,粘贴本博客下面“Cnetos-7.repo”里的内容即可。
但是若无法粘贴,可以直接改内容里的url字段,但要保留$变量的部分。
保存退出,改名
mv 1 Centos-7-aliyun.repo

(此步骤-方式2)删除当前目录的.repo文件,再新建一个.repo文件。编辑内容即可。
rm -f *.repo
touch Centos-7-aliyun.repo
vi Centos-7-aliyun.repo
粘贴本博客下面“Cnetos-7.repo”里的内容,保存退出。

步骤5
再查看当前可用源:
yum repolist enabled

连接正常

他の.repoファイルを削除しない場合、利用可能なソースを表示しても変更効果が表示されない場合がありますが、使用中にソースをダウンロードできない場合、または関連するコンテンツが見つからない場合は、すべてのソースがなくなるまで他のソースが自動的に試行されます結果ですが、このように、新しく追加されたソースは最初の選択肢とは呼ばれず、ソースを変更した場合の影響は明らかです。

 

ダウンロードしたCnetos-7.repoコンテンツ:(スペア)

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

 

おすすめ

転載: blog.csdn.net/qq_43750882/article/details/109161148