1 導言
CentOS的最小系統僅包含內核和必要的工具,派不上多大用處,之後還得安裝不少附加軟件。爲了方便之後的工做,還須要對系統作一些調整和補充。linux
本文涉及的工做均應以root身份執行。centos
2 安裝wget
wget是一個能夠從http、ftp服務器上下載文件的程序,可用於下載特定的包或文件,很是有用。後面的一些操做也會用到它。緩存
運行命令:服務器
便可安裝wget程序。oracle
3 修改yum基本軟件源倉庫
CentOS默認的軟件源倉庫是在國外的官方站點上,速度很慢,因此要調整爲國內的,這裏調整爲中科大的源,速度比較快,更新也挺及時。工具
執行命令:網站
- # wget -O /etc/yum.repos.d/CentOS-Base.repohttps://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3
會從中科大的Linux User Group網站上下載CentOS-Base.repo文件,替換原有的CentOS-Base.repo。阿里雲
還有一些國內站點也提供相似的repo文件下載途徑,好比163的鏡像repo文件下載方法爲:url
- # wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里雲的倉庫文件下載方法:spa
- # wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
注意:在更換官方源以前,最好把原有的官方源文件作好備份。
4 爲yum新增DVD軟件倉庫
1) 爲虛擬機的光驅設定掛載文件爲CentOS的EverythingDVD;
2) 用mkdir命令在/media目錄下建立目錄cdrom;
3) 用mount命令以只讀方式將光驅掛載到/media/cdrom目錄:
- # mount -r /dev/sr0 /media/cdrom
4) 修改yum的軟件倉庫,使能基於光盤的軟件倉庫:
用vi打開/etc/yum.repos.d/CentOS-Media.repo,將其中的enabled=0改成enabled=1,保存並退出。
5 安裝EPEL
EPEL——Extra Packages forEnterprise Linux,企業版Linux 附加軟件包。是一個由特別興趣小組建立、維護並管理的,針對紅帽企業版 Linux(RHEL)及其衍生髮行版(好比 CentOS、Scientific Linux、Oracle Enterprise Linux)的一個高質量附加軟件包項目。EPEL 的軟件包一般不會與企業版 Linux 官方源中的軟件包發生衝突,或者互相替換文件。EPEL 項目與 Fedora 基本一致,包含完整的構建系統、升級管理器、鏡像管理器等等。
國外的EPEL站點太慢,因此首先要製做國內的EPEL鏡像倉庫。這裏選用中科大的EPEL源。執行命令:
- # wget http://mirrors.ustc.edu.cn/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm
- # rpm –Uvhepel-release-7-5.noarch.rpm
修改/etc/yum.repos.d/epel.repo:
- [epel]
- name=ExtraPackages for Enterprise Linux 7 - $basearch
- baseurl=http://mirrors.ustc.edu.cn/epel/7/$basearch
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
- failovermethod=priority
- enabled=1
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
-
- [epel-debuginfo]
- name=ExtraPackages for Enterprise Linux 7 - $basearch - Debug
- baseurl=http://mirrors.ustc.edu.cn/epel/7/$basearch/debug
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
- failovermethod=priority
- enabled=0
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
- gpgcheck=1
-
- [epel-source]
- name=ExtraPackages for Enterprise Linux 7 - $basearch - Source
- baseurl=http://mirrors.ustc.edu.cn/epel/7/SRPMS
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
- failovermethod=priority
- enabled=0
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
- gpgcheck=1
修改/etc/yum.repos.d/epel-testing.repo:
- [epel-testing]
- name=ExtraPackages for Enterprise Linux 7 - Testing - $basearch
- baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/$basearch
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch
- failovermethod=priority
- enabled=0
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
-
- [epel-testing-debuginfo]
- name=ExtraPackages for Enterprise Linux 7 - Testing - $basearch - Debug
- baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/$basearch/debug
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch
- failovermethod=priority
- enabled=0
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
- gpgcheck=1
-
- [epel-testing-source]
- name=ExtraPackages for Enterprise Linux 7 - Testing - $basearch - Source
- baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/SRPMS
- #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch
- failovermethod=priority
- enabled=0
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
- gpgcheck=1
亦可從阿里雲直接下載epel的repo文件:
- # wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo
隨後執行如下命令重構yum軟件倉庫的cache:
- # yum clean all
- # yum makecache
執行命令:
- # yum install epel-release
稍候幾分鐘便可完成安裝。
6 調整yum倉庫的優先級
目的:使yum首先搜索DVD倉庫,而後再搜索其餘倉庫。
步驟以下:
1)安裝priority插件:
- # yum install yum-plugin-priorities
2)修改CentOS-Media.repo文件,在文件末尾添加一行:
3)修改CentOS-Base.repo文件,在每一節的末尾添加一行:
7 重構yum緩存
- # yum clean all
- # yum makecache
8 安裝VMware-Tools
如果在VMware虛擬機中安裝CentOS,則還須要安裝相應版本的VMware-Tools,以啓用客戶機與宿主機之間的數據交換(文件共享、拖-放操做等),在GUI環境下,只有安裝了VMware-Tools,虛擬機的顯示區域才能擴展到整個窗口,而且隨VMware Workstation的窗口變化而調整大小,不然只能使用窗口的部分區域和固定的顯示分辨率。
安裝vmware-tools以前首先要安裝perl解釋器、gcc編譯器、make工具以及內核相關文件,須要執行如下命令:
- # yum install perl gcc makekernel-headers kernel-devel
完成基本工具安裝以後,在VMwareWorkstation的「虛擬機」菜單上選擇「安裝VMware-Tools」,稍候,VMware會將工具光盤鏡像掛載到CentOS中。隨後將光盤中的文件VMware-Tools*.tar.gz複製到用戶本地目錄,本例是「VMwareTools-10.0.5-3228253.tar.gz」。而後將這個壓縮文件解壓縮:
- # tar -xzfVMwareTools-10.0.5-3228253.tar.gz
這時會獲得一個新的目錄vmware-tools-distrib,進入該目錄,並執行命令:
在接下來的交互中,所有使用默認選項便可完成vmware-tools的安裝。
完成安裝後,執行命令:
而後重啓系統,就會發現VMware-Tools已成功安裝,桌面擴展到了窗口的所有區域。