本次安裝的RedHat7.4是安裝在Oracle VM VirtualBox5.2.8虛擬機上面的,本文不對安裝虛擬機步驟做詳細說明。
工具准備:
Oracle VM VirtualBox5.2.8
rhel-server-7.4-x86_64-dvd.iso
安裝平台;
win10_x86_64
解決辦法:
1、修改網絡配置
在RedHat7之后ifconfig命令查看網絡命令受限,在登錄系統后,可以使用下面的命令查看當前的一些ip地址等網絡信息
[root@localhost ~]# ip addr
如果要修改網絡配置,使用下面的命令
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
修改BOOTPRTO=static,ONBOOT=yes,然后在最下面加入下面的配置
IPADDR=192.168.3.210 PREFIXO=24 GATEWAY=192.168.3.1 DNS1=114.114.114.114
修改之后的配置文件內容如下圖所示:
保存並退出之后,使用命令
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ OK ]
測試外網能否請求:
[root@localhost ~]# ping www.baidu.com PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data. 64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=54 time=42.8 ms 64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=54 time=40.9 ms 64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=3 ttl=54 time=41.6 ms 64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=4 ttl=54 time=40.6 ms ^Z [1]+ Stopped ping www.baidu.com
此時,使用yum命令會出現問題
[root@localhost ~]# yum install lrzsz Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register.
2、查看系統中的yum,如果有進行卸載
[root@localhost ~]# rpm -qa |grep yum yum-metadata-parser-1.1.4-10.el7.x86_64 yum-rhn-plugin-2.0.1-9.el7.noarch yum-3.4.3-154.el7.noarch
刪除redhat自帶的yum包
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
再進行檢查,確認卸載完成
[root@localhost ~]# rpm -qa |grep yum [root@localhost ~]#
3、下載163的yum安裝包
在網站:http://mirrors.163.com/有相關的許多開源包下載,我們這兒需要的安裝包在路徑:http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/ 中,需要下載的有下面的內容:
http://mirrors.163.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
除了上述文件之外,還需要一個CentOS6-Base-163.repo文件,可以通過百度雲盤進行搜索下載,在下載完成后通過WinSCP上傳到操作系統中。還需要將CentOS6-Base-163.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-7.4.1708 - Base - 163.com baseurl=http://mirrors.163.com/centos/7.4.1708/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7.4.1708&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-7.4.1708 - Updates - 163.com baseurl=http://mirrors.163.com/centos/7.4.1708/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7.4.1708&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-7.4.1708 - Extras - 163.com baseurl=http://mirrors.163.com/centos/7.4.1708/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7.4.1708&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7.4.1708 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7.4.1708/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7.4.1708&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-7.4.1708 - Contrib - 163.com baseurl=http://mirrors.163.com/centos/7.4.1708/cr/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7.4.1708&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
使用下面的命令開始yum源的安裝,本人安裝的時候兩個都用了,有的資料上只使用了其中的一個,本人安裝使用第一個只安裝了python相關的包,而且提示有警告,再使用第二個命令之后才安裝完yum-抬頭的相關包。
[root@localhost ~]# rpm -ivh *.rpm [root@localhost ~]# rpm -ivh yum-*
如果安裝時出現依賴包的問題,有可能會出現Python包安裝沖突的問題。所以在此處命令可以加上兩個參數強制安裝:
- --force 即使覆蓋屬於其它包的文件也強迫安裝
- --nodeps 如果該RPM包的安裝依賴其它包,即使其它包沒裝,也強迫安裝。
安裝完成之后需要將上傳的CentOS6-Base-163.repo文件以及RPM-GPG-KEY-CentOS-7文件移動到相應的位置中。
[root@localhost ~]# mv CentOS6-Base-163.repo /etc/yum.repos.d/
[root@localhost ~]# mv RPM-GPG-KEY-CentOS-7 /etc/pki/rpm-gpg/
經過這步之后經測試可以使用yum的相關命令的,可以安裝SecureCRT上傳下載相關的組件
[root@localhost yum.repos.d]# yum install lrzsz
但是既然有RPM-GPG-KEY-CentOS-7文檔,我們應該將它也轉入相關的目錄下面,雖然現在測試不轉好像也沒有影響。根據百度查找RPM-GPG-KEY-CentOS-7文件應當放入目錄/etc/pki/rpm-gpg/中。查看/etc/pki/rpm-gpg/中的內容並將RPM-GPG-KEY-CentOS-7文件移動到該目錄中。
[root@localhost yum.repos.d]# cd [root@localhost ~]# cd /etc/pki/rpm-gpg/ [root@localhost rpm-gpg]# ls RPM-GPG-KEY-redhat-beta RPM-GPG-KEY-redhat-legacy-rhx RPM-GPG-KEY-redhat-legacy-former RPM-GPG-KEY-redhat-release RPM-GPG-KEY-redhat-legacy-release [root@localhost rpm-gpg]# cd [root@localhost ~]# mv RPM-GPG-KEY-CentOS-7 /etc/pki/rpm-gpg/
[root@localhost ~]# cd /etc/pki/rpm-gpg/
[root@localhost rpm-gpg]# ls
RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-redhat-legacy-release
RPM-GPG-KEY-redhat-beta RPM-GPG-KEY-redhat-legacy-rhx
RPM-GPG-KEY-redhat-legacy-former RPM-GPG-KEY-redhat-release
在上述完成之后
[root@localhost ~]# yum clear all [root@localhost ~]# yum makecache
至此所有的配置完成。