Redhat 7.4更新为Centos7的yum并安装docker-ce

时间:2024-06-01 18:05:02
以下命令请在root下执行
#删除原有的yum
rpm -qa|grep yum|xargs rpm -e --nodeps #install centos yum
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
#wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm ###原来照上面的思路做 一直有问题,应该是没有安装python-iniparse包所致 随时间的变化 下面的链接可能会失效 需要到网站上确认小版本的变化
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm #安装这些依赖
rpm -ivh yum-* --nodeps ###更新CentosBase.repo
cat <<EOF >/etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/7/os/$basearch/
gpgcheck=
gpgkey=https://mirrors.aliyun.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 [updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.aliyun.com/centos/7/updates/$basearch/
gpgcheck=
gpgkey=https://mirrors.aliyun.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 [extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/7/extras//$basearch/
gpgcheck=
gpgkey=https://mirrors.aliyun.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 [centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.aliyun.com/centos/7/centosplus//$basearch/
gpgcheck=
enabled=
EOF #UPDATE YUM
yum clean all
yum makecache #######DOWNLOAD ALL FILES
yum install docker-ce --downloadonly --downloaddir=/root/docker
#####以下是根据redhat7.4默认新装的情况做的处理,正确的做法 应该根据当前机器是否安装这个包,如果安装则更新,如果没有则安装的思路来做
rpm -U --nodeps audit-2.8.-.el7_5..x86_64.rpm
rpm -U --nodeps audit-libs-2.8.-.el7_5..x86_64.rpm
rpm -ivh --nodeps audit-libs-python-2.8.-.el7_5..x86_64.rpm
rpm -ivh --nodeps checkpolicy-2.5-.el7.x86_64.rpm
rpm -ivh --nodeps containerd.io-1.2.-.el7.x86_64.rpm
rpm -ivh --nodeps python-IPy-0.75-.el7.noarch.rpm
rpm -U --nodeps libselinux-2.5-.el7.x86_64.rpm
rpm -U --nodeps libselinux-python-2.5-.el7.x86_64.rpm
rpm -U --nodeps libselinux-utils-2.5-.el7.x86_64.rpm
rpm -U --nodeps libsemanage-2.5-.el7.x86_64.rpm
rpm -ivh --nodeps libsemanage-python-2.5-.el7.x86_64.rpm
rpm -U --nodeps libsepol-2.5-8.1.el7.x86_64.rpm
rpm -U --nodeps policycoreutils-2.5-.el7.x86_64.rpm
rpm -ivh --nodeps policycoreutils-python-2.5-.el7.x86_64.rpm
rpm -U --nodeps selinux-policy-3.13.-.el7_5..noarch.rpm
rpm -U --nodeps selinux-policy-targeted-3.13.-.el7_5..noarch.rpm
rpm -ivh --nodeps container-selinux-2.68-.el7.noarch.rpm
rpm -ivh --nodeps setools-libs-3.3.-.el7.x86_64.rpm
rpm -ivh --nodeps docker-ce-18.09.-.el7.x86_64.rpm
rpm -ivh --nodeps docker-ce-cli-18.09.-.el7.x86_64.rpm

redhat 需要注册后才能使用yum,所以有以上的操作。