1、yum 安裝ubuntu
CentOS 默認已經安裝了yum,不須要另外安裝,這裏爲了實驗目的,先將yum 卸載再從新安裝。centos
一、查看系統默認安裝的yum服務器
# rpm -qa|grep yumless
二、卸載yum測試
# rpm -e yum-fastestmirror-1.1.16-14.el5.centos.1 yum-metadata-parser-1.1.2-3.el5.centos yum-3.2.22-33.el5.centosthis
三、從新安裝yumurl
這裏能夠經過wget 從網上下載相關包安裝,也能夠掛載系統安裝光盤進行安裝,這裏選擇掛載系統安裝光盤進行安裝。spa
# mount /dev/cdrom /mnt/cdrom/blog
# rpm -ivh yum-3.2.22-33.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpmrem
# yum -v
yum 的基礎安裝包包括:
其餘安裝包根據本身須要安裝。
2、yum 配置
yum 的配置文件分爲兩部分:main 和repository
yum.conf 文件通常位於/etc目錄下,通常其中只包含main部分的配置選項。
# cat /etc/yum.conf
配置國內yum源
系統默認的yum 源速度每每不盡人意,爲了達到快速安裝的目的,在這裏修改yum源爲國內源。
上海交通大學yum源: http://ftp.sjtu.edu.cn/centos
能夠點擊這個網址,而後找到你要安裝的包:
這裏尋找你要的包,
1,選centos
2,選擇系統版本7.3.1611/
3,選擇包類型(系統) os/
4,系統位數 x86_64/
5,包 Packages/
6,ctrl+f 搜索yum
七、yum的安裝須要:
yum-plugin-fastestmirror
yum-updateonboot
yum-utils
yum-metadata-parser
yum-3.4.3-150.el7
如須要安裝yum包,能夠用命令: (centos 7 全部版本的安裝包都在centos/7/os 目錄下面,而不是在 centos/7.XXX/下面)
[root@localhost]#wget http://ftp.sjtu.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
[root@localhost]#wget http://ftp.sjtu.edu.cn/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-40.el7.noarch.rpm
[root@localhost]#wget http://ftp.sjtu.edu.cn/centos/7/os/x86_64/Packages/yum-utils-1.1.31-40.el7.noarch.rpm
[root@localhost]#wget http://ftp.sjtu.edu.cn/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@localhost]#wget http://ftp.sjtu.edu.cn/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
配置yum源
a. 修改/etc/yum.repos.d/CentOS-Base.repo爲
#released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
關於變量
清理以前源,保證只有一個配置文件
[root@localhost]# yum clean all
[root@localhost]# ls /etc/yum.repos.d/
CentOS-Base.repo
安裝你須要的軟件測試是否正常使用
其餘國內yum源列表以下:
1. 企業貢獻:
搜狐開源鏡像站:http://mirrors.sohu.com/
網易開源鏡像站:http://mirrors.163.com/
2. 大學教學:
北京理工大學:
http://mirror.bit.edu.cn (IPv4 only)
http://mirror.bit6.edu.cn (IPv6 only)
北京交通大學:
http://mirror.bjtu.edu.cn (IPv4 only)
http://mirror6.bjtu.edu.cn (IPv6 only)
http://debian.bjtu.edu.cn (IPv4+IPv6)
蘭州大學:http://mirror.lzu.edu.cn/
廈門大學:http://mirrors.xmu.edu.cn/
清華大學:
http://mirrors.tuna.tsinghua.edu.cn/ (IPv4+IPv6)
http://mirrors.6.tuna.tsinghua.edu.cn/ (IPv6 only)
http://mirrors.4.tuna.tsinghua.edu.cn/ (IPv4 only)
天津大學:http://mirror.tju.edu.cn/
中國科學技術大學:
http://mirrors.ustc.edu.cn/ (IPv4+IPv6)
http://mirrors4.ustc.edu.cn/
http://mirrors6.ustc.edu.cn/
東北大學:
http://mirror.neu.edu.cn/ (IPv4 only)
http://mirror.neu6.edu.cn/ (IPv6 only)
電子科技大學:http://ubuntu.uestc.edu.cn/
備註:
我這裏在Centos7.3.1611上配置yum源,測試可使用的配置:
# 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-centos/7 - Base #mirrorlist=http://mirrorlist.centos.org/?release=centos/7&arch=$basearch&repo=os baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/ gpgcheck=1 gpgkey=http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-centos/7 - Updates #mirrorlist=http://mirrorlist.centos.org/?release=centos/7&arch=$basearch&repo=updates baseurl=http://ftp.sjtu.edu.cn/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-centos/7 - Extras #mirrorlist=http://mirrorlist.centos.org/?release=centos/7&arch=$basearch&repo=extras baseurl=http://ftp.sjtu.edu.cn/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-centos/7 - Plus #mirrorlist=http://mirrorlist.centos.org/?release=centos/7&arch=$basearch&repo=centosplus baseurl=http://ftp.sjtu.edu.cn/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-centos/7 - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=centos/7&arch=$basearch&repo=contrib baseurl=http://ftp.sjtu.edu.cn/centos/7/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7