歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS 7最小安裝之後應該盡快做好的幾件事情

CentOS 7最小安裝之後應該盡快做好的幾件事情

日期:2017/3/6 9:48:49   编辑:學習Linux

CentOS 7最小安裝之後應該盡快做好的幾件事情


CentOS 7最小安裝之後應該盡快做好的幾件事情


1導言

CentOS的最小系統僅包含內核和必要的工具,派不上多大用處,以後還得安裝很多附加軟件。為了方便以後的工作,還需要對系統做一些調整和補充。

本文涉及的工作均應以root身份執行。

2安裝wget

wget是一個可以從http、ftp服務器上下載文件的程序,可用於下載特定的包或文件,非常有用。後面的一些操作也會用到它。

運行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yuminstallwget

即可安裝wget程序。

3修改yum基本軟件源倉庫

CentOS默認的軟件源倉庫是在國外的官方站點上,速度很慢,所以要調整為國內的,這裡調整為中科大的源,速度比較快,更新也挺及時。

執行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #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文件下載方法為:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.163.com/.help/CentOS7-Base-163.repo

阿裡雲的倉庫文件下載方法:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo

注意:在更換官方源之前,最好把原有的官方源文件做好備份。

4為yum新增DVD軟件倉庫

1) 為虛擬機的光驅設定掛載文件為CentOS的EverythingDVD;

2) 用mkdir命令在/media目錄下創建目錄cdrom;

3) 用mount命令以只讀方式將光驅掛載到/media/cdrom目錄:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #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源。執行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #wgethttp://mirrors.ustc.edu.cn/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm
  2. #rpm–Uvhepel-release-7-5.noarch.rpm

修改/etc/yum.repos.d/epel.repo:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [epel]
  2. name=ExtraPackagesforEnterpriseLinux7-$basearch
  3. baseurl=http://mirrors.ustc.edu.cn/epel/7/$basearch
  4. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  5. failovermethod=priority
  6. enabled=1
  7. gpgcheck=1
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  9. [epel-debuginfo]
  10. name=ExtraPackagesforEnterpriseLinux7-$basearch-Debug
  11. baseurl=http://mirrors.ustc.edu.cn/epel/7/$basearch/debug
  12. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
  13. failovermethod=priority
  14. enabled=0
  15. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  16. gpgcheck=1
  17. [epel-source]
  18. name=ExtraPackagesforEnterpriseLinux7-$basearch-Source
  19. baseurl=http://mirrors.ustc.edu.cn/epel/7/SRPMS
  20. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
  21. failovermethod=priority
  22. enabled=0
  23. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  24. gpgcheck=1

修改/etc/yum.repos.d/epel-testing.repo:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [epel-testing]
  2. name=ExtraPackagesforEnterpriseLinux7-Testing-$basearch
  3. baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/$basearch
  4. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch
  5. failovermethod=priority
  6. enabled=0
  7. gpgcheck=1
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  9. [epel-testing-debuginfo]
  10. name=ExtraPackagesforEnterpriseLinux7-Testing-$basearch-Debug
  11. baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/$basearch/debug
  12. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch
  13. failovermethod=priority
  14. enabled=0
  15. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  16. gpgcheck=1
  17. [epel-testing-source]
  18. name=ExtraPackagesforEnterpriseLinux7-Testing-$basearch-Source
  19. baseurl=http://mirrors.ustc.edu.cn/epel/testing/7/SRPMS
  20. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch
  21. failovermethod=priority
  22. enabled=0
  23. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  24. gpgcheck=1

亦可從阿裡雲直接下載epel的repo文件:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo

隨後執行以下命令重構yum軟件倉庫的cache:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yumcleanall
  2. #yummakecache

執行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yuminstallepel-release

稍候幾分鐘即可完成安裝。

6調整yum倉庫的優先級

目的:使yum首先搜索DVD倉庫,然後再搜索其他倉庫。

步驟如下:

1)安裝priority插件:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yuminstallyum-plugin-priorities

2)修改CentOS-Media.repo文件,在文件末尾添加一行:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. priority=1

3)修改CentOS-Base.repo文件,在每一節的末尾添加一行:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. priority=1

7重構yum緩存

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yumcleanall
  2. #yummakecache

8安裝VMware-Tools

若是在VMware虛擬機中安裝CentOS,則還需要安裝相應版本的VMware-Tools,以啟用客戶機與宿主機之間的數據交換(文件共享、拖-放操作等),在GUI環境下,只有安裝了VMware-Tools,虛擬機的顯示區域才能擴展到整個窗口,並且隨VMware Workstation的窗口變化而調整大小,否則只能使用窗口的部分區域和固定的顯示分辨率。

安裝vmware-tools之前首先要安裝perl解釋器、gcc編譯器、make工具以及內核相關文件,需要執行以下命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #yuminstallperlgccmakekernel-headerskernel-devel

完成基本工具安裝之後,在VMwareWorkstation的“虛擬機”菜單上選擇“安裝VMware-Tools”,稍候,VMware會將工具光盤鏡像掛載到CentOS中。隨後將光盤中的文件VMware-Tools*.tar.gz復制到用戶本地目錄,本例是“VMwareTools-10.0.5-3228253.tar.gz”。然後將這個壓縮文件解壓縮:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #tar-xzfVMwareTools-10.0.5-3228253.tar.gz

這時會得到一個新的目錄vmware-tools-distrib,進入該目錄,並執行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #./vmware-install.pl

在接下來的交互中,全部使用默認選項即可完成vmware-tools的安裝。

完成安裝後,執行命令:

[plain]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. #vmware-user

然後重啟系統,就會發現VMware-Tools已成功安裝,桌面擴展到了窗口的全部區域。

http://xxxxxx/Linuxjc/1134177.html TechArticle

Copyright © Linux教程網 All Rights Reserved