centos7 裝機後的基本配置

安裝完centos7.3後,做一些基本的操作

下面是我的環境的配置,你們可以根據自己的環境搭配相應的配置。修改下就可以了。



基本操作一:主機名
centos7有一個新的修改主機名的命令hostnatctl

# hostnamectl set-hostname --static feng.cluster.com ----修改主機名

# vim /etc/hosts --最後加上你的IP與主機名的綁定
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.21.250 feng.cluster.com feng ----其中最後的li是主機名的別名
172.16.13.250 feng.cluster.com feng

主機名:內網名字
域名:公網名字
主機名不能是localhost
綁定主機名就相當於內網的dns,非常重要。
綁定主機名的作用?




基本操作二:關閉iptables

# systemctl status firewalld.service
----查看firewalld服務的狀態,active是啓動狀態,inactive是關閉狀態

# systemctl stop firewalld.service ----關閉此服務


# systemctl list-unit-files |grep firewalld --查看firewalld是否開機自動啓動
firewalld.service enabled ----爲自動啓動

# systemctl disable firewalld.service --類似以前的chkconfig xxx off,關閉開機自動啓動

# systemctl list-unit-files |grep firewalld
firewalld.service disabled ----不自啓動



基本操作三:關閉selinux(方法和以前一樣)

# sed -i 7s/enforcing/disabled/ /etc/selinux/config
--改完後,在後面重啓系統生效






基本操作四:網絡配置
# systemctl stop NetworkManager
--停止服務
# systemctl status NetworkManager --查看狀態,確認爲關閉了
# systemctl disable NetworkManager --設置爲開機不自動啓動


# vim /etc/sysconfig/network-scripts/ifcfg-enp2s0 --網卡名如果不一樣,找到對應的文件就行

BOOTPROTO="static"
NAME="enp2s0"
DEVICE="enp2s0"
ONBOOT="yes"
IPADDR=172.16.13.X
NETMASK=255.255.255.0
GATEWAY=172.16.13.254
DNS1=114.114.114.114


# /etc/init.d/network restart --network服務這裏默認還是可以使用原來的管理方法
# chkconfig network on



基本操作五:yum配置

1,通過firefox訪問下面路徑,並下載centos7.3鏡像

wget http://172.16.21.250/CentOS-7-x86_64-DVD-1611.iso


# ll CentOS-7-x86_64-DVD-1611.iso --拷貝完後,確認大小一致
-rw-r--r--. 1 qemu qemu 4379901952 Apr 20 04:56 /share/CentOS-7-x86_64-DVD-1611.iso


# mkdir /yum
# mount /share/CentOS-7-x86_64-DVD-1611.iso /yum --我本地的鏡像在/share下,我把它掛載到/yum目錄

# echo "mount /share/CentOS-7-x86_64-DVD-1611.iso /yum" >> /etc/rc.local
# chmod a+x /etc/rc.d/rc.local
--centos7要把rc.local原文件加執行權限,開機纔會自動執行

注意:步驟1只有物理機裝centos7系統的才需要做,虛擬機直接掛載鏡像即可

2,配置本地yum源
# rm /etc/yum.repos.d/* -rf
--這裏我刪除了它所有的默認的配置(因爲這些默認配置要連公網的源,速度太慢)

# vim /etc/yum.repos.d/local.repo --然後自建了本地yum源配置文件
[local]
name=local
baseurl=file:///yum
enabled=1
gpgcheck=0




3,配置可選163的centos源
163centos源(其實就是centos官方的yum,使用163的國內速度更快)
配置方法兩種
a)直接公網連接網易163,優點:速度快,軟件包會定期更新

# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo


b)使用老師機器上的源(全部從163上下載而來),優點:局域網速度更快,但軟件包不能更新(因爲我沒有寫定期去網上同步)

# vim /etc/yum.repos.d/cento163.repo


[centos163]
name=centos163
baseurl=http://172.16.21.250/centos163/
enabled=1
gpgcheck=0


3,配置可選epel源
配置方法兩種
a)直接公網連接epel,優點:速度快,軟件包會定期更新
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm --此版本信息會隨時間推移而變化
# rpm -ivh epel-release-7-10.noarch.rpm


b)使用老師機器上的源(全部從epel上下載而來),優點:局域網速度更快,但軟件包不能更新(因爲我沒有寫定期去網上同步)

# vim /etc/yum.repos.d/epel.repo


[epel]
name=epel
baseurl=http://172.16.21.250/epel/
enabled=1
gpgcheck=0



配置完上面三個yum後
# yum clean all
# yum makecache fast

可能遇到的問題:

Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 146 M RSS (556 MB VSZ)
Started: Wed Aug 30 12:40:02 2017 - 20:22 ago
State : Sleeping, pid: 2247
原因:可能是系統自動升級正在運行,yum在鎖定狀態中。
已經有一個yum進程在運行了,但是使用kill幹不掉它。
解決方法:# rm -f /var/run/yum.pid






基本操作六:輸入法配置

默認只有拼音中文輸入法,我這裏需要使用極點五筆輸入法(如果不用五筆的話可以不安裝),安裝過程如下:
# yum -y install ibus ibus-table-chinese-wubi-jidian

安裝完後,需要右上角把用戶註銷重登錄

左上角applications--system tools -- settions -- Region & Language -- +或-你的輸入法就可以了

加完之後,使用super+space鍵進行切換






基本操作七:時間同步
# yum -y install ntp ntpdate
--安裝ntp時間同步相關軟件包
# vim /etc/ntp.conf --確認配置文件裏有下列的時間同步源
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

# systemctl enable ntpd --設置開機自動啓動ntpd
# systemctl start ntpd --立即啓動ntpd服務
# date --確認時間與現在時間一致

# ntpdate 0.rhel.pool.ntp.org --如果還沒有同步成功,你可以用此命令手動同步一下



另外一個時間服務器的搭建方法

# yum -y install xinetd -y
# vim /etc/xinet.d/time-dgram

disable = no (--yes改爲no)

# vim /etc/xinetd.d/time-stream
disable = no (--yes改爲no)

# systemctl restart xinetd
# systemctl status xinetd
# systemctl enable xinetd



客戶端同步時間的用法
# rdate -s 時間服務器的ip



基本操作八:
有些命令的參數可以自動補全,如果不能補全,則安裝下面的命令(可能需要註銷一下)
# yum -y install bash-completion




基本操作九:vnc的配置

# vncpasswd
--設定vcn連接的密碼
Password:
Verify:

# x0vncserver --PasswordFile=/root/.vnc/passwd --AlwaysShared=on --AcceptKeyEvents=off AcceptPointerEvents=off &> /dev/null &




基本操作十:桌面鎖屏

左上角applications--system tools -- settions -- Privacy 設置是否自動鎖屏

手動鎖屏
super+l



基本操作十一:圖形界面快捷鍵修改
左上角applications--system tools -- settions -- Keyboard -- Shortcuts 去修改自己習慣的快捷鍵



基本操作十二:設置默認啓動級別爲圖形模式(相當於以前的5級別)

# systemctl get-default
--查看當前的運行模式

# systemctl set-default graphical.target --設置圖形模式爲默認模式




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章