CentOS-7.2系统安装完成后的一些基本优化

一、修改主机名

centos7有一个新的修改主机名的命令hostnamectl,或者修改:/etc/hostname  -----主机名的配置文件

# hostnamectl set-hostname zhong.cluster.com

 

# vim /etc/hosts      -------最后加上IP和主机名的绑定
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.111.128 zhong.cluster.com zhong

 

二、关闭防火墙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      ------类似于6系列的chkconfig  XXX  off

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

# systemctl list-unit-files |grep firewalld

firewalld.service                           disabled

 

三、关闭selinux

# setenforce 0
# vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted

 

四、网络配置

# systemctl status NetworkManager      ------查看状态,active是开启,inactive是关闭

# systemctl stop NetworkManager         -------停止服务

# systemctl disable NetworkManager     -------设置开机不自动启动

Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.

# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

TYPE=Ethernet
BOOTPROTO=static
#DEFROUTE=yes
#PEERDNS=yes
#PEERROUTES=yes
#IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
NAME=eno16777736
#UUID=e7e2f04f-6ca3-4753-847f-691c73b80e7d
DEVICE=eno16777736
ONBOOT=yes
IPADDR=192.168.111.128
NETMASK=255.255.255.0
GATEWAY=192.168.111.2
DNS1=114.114.114.114

#
/etc/init.d/network restart -------重启网卡

 

 

五、配置yum源

可选择性的配置一下几种yum源

1.配置163的centos源

# mv /etc/yum.repos.d/CentOS-Base.repo /tmp/     -----将系统自带的yum源移走

# cd /etc/yum.repos.d

# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo  -----下载163yum源

# yum clean all    ------清空之前缓存

# yum makecache  ------生成缓存

  

2.配置epel源

 

# mv /etc/yum.repos.d/CentOS-Base.repo  /tmp/     -----将系统自带的yum源移走

# cd /etc/yum.repos.d # wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm  -----此版本会随时间的推移而变化 # rpm -ivh epel-release-7-11.noarch.rpm ------解压安装epel源 # yum clean all    ---------清空之前缓存 # yum makecache   ---------生成缓存

 

3.配置阿里云yum源

# mv CentOS-Base.repo CentOS-Base.repo.bak      ------备份默认yum源

# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo     ------下载yum源改名为CentOS-Base.repo

# yum clean all

# yum makecache

  

 

4.用光盘配置本地yum源

# mv /etc/yum.repos.d/*.repo  /tmp/

# mkdir /yum

# mount -o loop /dev/cdrom /yum          --挂载本地镜像到yum目录

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

[server]
name=server
baseurl=file:///yum
enabled=1
gpgcheck=0

# yum clean all    ---------清空之前缓存

# yum makecache    ---------生成缓存

  

六、时间同步

# yum install ntp ntpdate -y  ----安装ntp时间同步相关软件包

# 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

#date          ------确认时间与现在时间一致

# ntpdate 0.centos.pool.ntp.org  -------时间不一致手动同步一下

# systemctl enable ntpd    -----设置开机启动ntpd

# systemctl start ntpd    ------立即启动ntpd服务

  

默认centos 7不支持ifconfig,需要安装net-tools

# yum install net-tools

 

posted @ 2018-07-24 14:06  灬龍灬  阅读(120)  评论(0)    收藏  举报