4.Linux开机设置项
开机建议优化项:
//关闭防火墙 systemctl stop firewalld systemctl disable firewalld //关闭SELinux: setenforce 0 sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config //--------------------------------------------------------------------------- //更改网卡配置文件(将当前ip地址等信息固化到网卡): //设置地址获取方式为静态文件设置: sed -i 's#dhcp#static#g' /etc/sysconfig/network-scripts/ifcfg-ens33 //设置网卡信息开机自动加载: sed -i 's#ONBOOT=no#ONBOOT=yes#g' /etc/sysconfig/network-scripts/ifcfg-ens33 //将当前ip地址信息写入网卡配置文件: echo $(ip addr |grep 192 | awk -F ' ' {' print $2'} |awk -F'/' {'print "IPADDR="$1'}) >> /etc/sysconfig/network-scripts/ifcfg-ens33 //将子网掩码信息写入到网卡配置文件: echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-ens33 //写入网关地址: echo "GAETWAY=$(ip addr |grep 192 | awk -F ' ' {' print $2'} |awk -F'/' {'print $1'}|awk -F '.' {'print $1"."$2"."$3"."2'})" >> /etc/sysconfig/network-scripts/ifcfg-ens33 //写入DNS解析地址: echo "DNS1=114.114.114.114" >> /etc/sysconfig/network-scripts/ifcfg-ens33
//重启网络服务: systemctl restart network
//将yum源修改为国内阿里云源: curl /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo >> /etc/yum.repos.d/CentOS-Base.repo yum makecache
//安装最基本的工具: yum -y install vim wget net-tools