centos7 系统初始化配置
1、设置ip地址
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192 PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" NAME="ens192" DEVICE="ens192" ONBOOT="yes" IPADDR="192.168.82.232" PREFIX="24" GATEWAY="192.168.82.1" DNS1="114.114.114.114" [root@localhost ~]#
2、修改主机名
hostnamectl set-hostname postmail
3、更改yum源、update
#备份现有源配置 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup #rpm安装wget rpm -ivh http://mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm #下载并替代本地源 yum install -y wget wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #修改Centos-7.repo文件将所有$releasever替换为7 yum install -y vim vim /etc/yum.repos.d/CentOS-Base.repo #输入替换命令 %s/$releasever/7/g wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum clean all yum makecache #添加epel源 yum install -y epel-release #update yum -y update
4、关闭防火墙
#查看防火墙状态 systemctl status firewalld #关闭防火墙 systemctl stop firewalld #关闭开机启动防火墙 systemctl disable firewalld
5、关闭selinux
#查看selinux状态 getenforce #临时关闭 setenforce 0 #永久关闭 #SELINUX=enforcing 改为 SELINUX=disabled vim /etc/sysconfig/selinux
6、调整系统时区
timedatectl set-timezone Asia/Shanghai timedatectl set-local-rtc 0 systemctl restart rsyslog systemctl restart crond
7、关闭系统不需要的服务
ss -tnl systemctl stop postfix && systemctl disable postfix
8、安装net-tools
yum install -y net-tools