查看系统信息
lsb_release -a
配置镜像源
sed -i "s#http://archive.ubuntu.com/ubuntu/#http://mirrors.aliyun.com/ubuntu/#g" /etc/apt/sources.list
安装vim命令
apt update && apt -y install vim
配置静态ip地址
vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
dhcp4: false
addresses:
- 10.1.60.130/24
routes:
- to: default
via: 10.1.60.254
nameservers:
addresses:
- 114.114.114.114
- 116.116.116.116
version: 2
使网络配置生效
netplan apply
关闭防火墙
systemctl disable --now ufw
同步时间
apt -y install ntpdate
timedatectl set-timezone Asia/Shanghai
优化主机配置
#!/bin/bash
#调整最大进程数限制和文件描述符限制
cat >> /etc/security/limits.conf << EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
#内核参数优化
cat >> /etc/sysctl.conf << EOF
fs.file-max=65535
net.ipv4.ip_local_port_range=1025 65000
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_max_tw_buckets=8000
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout=30
net.ipv4.tcp_retries2=5
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_sack=1
net.ipv4.tcp_fack=1
net.ipv4.tcp_timestamps=1
net.ipv4.tcp_keepalive_time=120
net.ipv4.tcp_keepalive_intvl=20
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_max_syn_backlog= 65535
net.ipv4.tcp_mem = 262144 524288 786432
net.ipv4.tcp_wmem = 4096 131072 16777216
net.ipv4.tcp_rmem = 4096 131072 16777216
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.core.wmem_max = 16777216
net.core.wmem_default = 131072
net.core.rmem_max = 16777216
net.core.rmem_default = 131072
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
vm.overcommit_memory = 0
vm.swappiness = 10
net.ipv4.ip_forward = 1
EOF
#使配置生效
sysctl -p