1. 环境说明
本文系统环境:
1 2 3 4 5 6
| [root@syushin ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core)
[root@syushin ~]# uname -a Linux syushin 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
|
2. 设置网络
修改IP地址、网格、主机名、DNS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| # 编辑配置文件 $ vi /etc/sysconfig/network-scripts/ifcfg-ens33 # 文件内容修改如下: TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static # 修改为静态模式 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=09124a8b-8fd5-4af4-8d96-1e6a56d336ca DEVICE=ens33 ONBOOT=yes # 修改为yes IPADDR=192.168.62.100 # 设置IP地址 NETMASK=255.255.255.0 # 子网掩码 GATEWAY=192.168.62.2 # 网关地址 DNS=119.29.29.29 # 设置DNS
|
注意这里的网络IP地址,如果是 vmware workstation pro创建的虚拟机,并且使用NAT模式,可以点击 编辑 –> 虚拟网络编辑器 –> NAT设置 查看对应的IP网段和网关地址。
修改完成重启network服务:
1 2
| $ /etc/init.d/network restart
|
配置DNS服务:
1 2
| $ echo "nameserver 119.29.29.29" >> /etc/resolv.conf
|
配置主机名:
1 2
| $ hostnamectl set-hostname syushin
|
3. 关闭防火墙
1 2 3
| $ systemctl stop firewalld $ systemctl disable firewalld
|
关闭selinux:
1 2 3
| $ sed -i 's/enforcing/disabled/g' /etc/selinux/config # 永久关闭 $ setenforce 0 # 临时关闭
|
4. 配置yum源,安装常用包
配置yum为阿里云的源,阿里云源镜像站:https://developer.aliyun.com/mirror/
我的系统是 CentOS7,所以选择 CentOS7 的镜像源:
1 2 3 4 5 6 7 8 9 10
| # 如果没有wget工具,先安装它 $ yum install wget -y # 下载镜像源 $ wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo $ sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo # 生成缓存 $ yum makecache # 安装常用包 $ yum install -y vim net-tools lrzsz tree iftop tcpdump zip unzip psmisc rsync bash-completion telnet
|
5. 配置时间同步
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # 安装Chrony $ yum install chrony -y
# 启动并加入开机自启动 $ systemctl enable chronyd.service $ systemctl start chronyd.service
# 时间同步 $ chronyc sources
# 查看时间 $ date Mon Aug 16 23:47:52 CST 2021
|
6. 调整文件描述符大小
默认文件描述符是1024,对于高并发业务来说是不够的,将其调整为65535
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| $ ulimit -n 1024
# 编辑配置文件 $ vim /etc/security/limits.conf # 添加如下配置 * soft nofile 65535 * hard nofile 65535 root soft nofile 65535 root hard nofile 65535
# 修改完退出当前用户终端,重新连接生效 $ ulimit -n 65535
|