Minimal安装CentOS 6.7之后要做的基本配置

系统版本:

[root@centos67n1 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@centos67n1 ~]# uname -r
2.6.32-573.el6.x86_64

 

1、配置网络连接

[root@centos67n1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.16.61
NETMASK=255.255.255.0
BROADCAST=192.168.16.255
NETWORK=192.168.16.0
GATEWAY=192.168.16.2
#修改或添加以上内容

[root@centos67n1 ~]# vi /etc/resolv.conf
nameserver 8.8.8.8
#修改DNS

[root@centos67n1 ~]# service network restart
#重启网络连接

2、安装vim和wget

[root@centos67n1 ~]# yum -y install vim wget

[root@centos67n1 ~]# vim /etc/vimrc
set tabstop=4
#设置vim编辑器的tab缩进为4个空格
#如果是CentOS7系统,也要执行该操作

3、配置阿里yum源

[root@centos67n1 ~]# mv /etc/yum.repos.d/CentOS-Base.repo{,.bak}
#备份原来的repo文件
#如果是CentOS7系统,也要执行该操作

[root@centos67n1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo \
http://mirrors.aliyun.com/repo/Centos-6.repo
[root@centos67n1 ~]# wget -O /etc/yum.repos.d/epel.repo \
http://mirrors.aliyun.com/repo/epel-6.repo
#下载阿里的repo文件

#[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo \
http://mirrors.aliyun.com/repo/Centos-7.repo
#[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo \
http://mirrors.aliyun.com/repo/epel-7.repo
#CentOS7下载上面两个文件

[root@centos67n1 ~]# vim /etc/yum.repos.d/CentOS-Media.repo
enabled=0
#确保不启用CentOS-Media.repo

[root@centos67n1 ~]# yum clean all
[root@centos67n1 ~]# yum makecache
#生成缓存;CentOS7也要执行

4、安装bash-completion,以支持增强Tab补全

[root@centos67n1 ~]# yum -y install bash-completion
#[root@centos71d1 ~]# yum -y install bash-completion{,-extras}
#CentOS7加装extras

[root@centos67n1 ~]# reboot

5、安装lrzsz,以支持使用Xshell传输文件

[root@centos67d1 14:28 ~]# yum -y install lrzsz

[root@centos67d1 14:30 ~]# rz
#可使用rz命令,通过Xshell在Windows系统与CentOS系统之间传输文件

#[root@centos71d1 ~]# yum -y install vim wget net-tools tcpdump mailx psmisc tree httpd-tools lftp unzip \
nss curl lbzip2 bzip2 git telnet lsof bash-completion{,-extras}
#CentOS7加装程序包

6、配置hostname和hosts

[root@centos67n1 ~]# vim /etc/sysconfig/network
HOSTNAME=centos67n1
#修改为自己的hostname
#[root@localhost ~]# hostnamectl set-hostname centos71d3
#CentOS7使用hostnamectl set-hostname设置主机名

[root@centos67n1 ~]# vim /etc/hosts
127.0.0.1   localhost centos67n1 localhost4 localhost4.localdomain4
#将第3个字段修改为上面所配置的hostname
#CentOS7也要执行该操作

[root@centos67n1 ~]# reboot
#重启系统,使配置生效

7、修改命令提示符样式

[root@centos67d1 ~]# vim .bashrc 
PS1="\[\e[37;40m\][\[\e[34;40m\]\u@\h \[\e[34;40m\]\A \[\e[34;40m\]\w\[\e[0m\]]\$ "
#增加以上一行
#如果是CentOS7.6,需要使用单引号,不能使用双引号,\
#否则在root用户下,不会显示“#”,而为“$”

[root@centos67d1 ~]# source .bashrc
#重读配置文件,立即生效

[root@centos67d1 11:18 ~]#

8、临时关闭selinux和防火墙

[root@centos67d1 12:26 ~]# vim /etc/selinux/config
SELINUX=disabled

[root@centos67d1 12:27 ~]# chkconfig iptables off
#[root@centos71d1 16:45 ~]# systemctl disable firewalld
#CentOS7则关闭firewalld

[root@centos67d1 12:29 ~]# reboot

9、安装配置NTP,自动对时,确保时间的准确性

[root@centos67n1 ~]# yum -y install ntp
[root@centos67n1 ~]# vim /etc/ntp.conf
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
#在以上4行前面加“#”注释,或删除以上4行

server 2.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
#添加以上两行

#[root@centos71d3 11:44 ~]# vim /etc/chrony.conf
#CentOS7则修改/chrony.conf文件

[root@centos67n1 ~]# chkconfig ntpd on
#设置开机自动启动NTP服务

#[root@centos71d3 11:49 ~]# systemctl start chronyd.service
#[root@centos71d3 11:49 ~]# systemctl enable chronyd.service
#CentOS7则启动chronyd服务

[root@centos67n1 ~]# reboot
[root@centos67n1 ~]# service ntpd status 
ntpd (pid  1347) is running...
#重启系统,确认NTP服务自动启动

[root@centos67n1 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*85.199.214.100  .GPS.            1 u   22   64  347  203.883   -4.243   6.467
+ntp.wdc1.us.lea 130.133.1.10     2 u   40   64  337  228.033   -1.875  15.322
#NTP自动校对时间生效

#[root@centos71d3 11:44 ~]# chronyc sources -v
#CentOS7则使用chronyc命令测试

 
此外,在安装系统时,注意不要勾选System clock uses UTC,UTC(Universe time coordinated)即世界协调时间,也就是0时区的时间。
 

 

发表评论

邮箱地址不会被公开。