Contents

UBUNTU-24.04-初始化配置

一、系统检查升级:

sudo apt-get update && sudo apt-get upgrade

二、配置主机名

sudo hostnamectl hostname ubuntu

三、安装nfs

sudo apt-get install nfs4-acl-tools nfs-common -y

四、qemu-guest-agent-虚拟机使用-非虚拟机可不用安装

sudo apt-get install qemu-guest-agent -y

启动-开机启动-查看状态

sudo systemctl enable qemu-guest-agent && sudo systemctl start qemu-guest-agent && sudo systemctl status qemu-guest-agent

五、修改hosts文件

1
2
3
4
sudo vim /etc/hosts

>>>
    10.10.10.111    ubuntu  Ubuntu

六、句柄配置

ulimit -SHn 65535


修改limits.conf文件

sudo vim /etc/security/limits.conf


1
2
3
4
5
6
* soft nofile 655360
* hard nofile 131072
* soft nproc 655350
* hard nproc 655350
* seft memlock unlimited
* hard memlock unlimitedd

ulimit -a

七、安装时间同步服务

sudo apt-get install chrony

备份原有配置

sudo mv /etc/chrony/chrony.conf /etc/chrony/chrony.conf.bak

修改配置文件

sudo vim /etc/chrony/chrony.conf


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
server ntp1.aliyun.com iburst
server ntp.aliyun.com iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmaaddress 127.0.0.1
binddaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
Logchange 0.5
logdir /var/log/chrony

八、时区配置

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

启动系统服务chronyd

chronyc sources -v

#重启校时服务并配置开机自启

sudo systemctl restart chronyd && sudo systemctl enable chronyd

查看时间

timedatectl

九、最大可用配置

sudo vim /etc/default/grub

修改 »> GRUB_CMDLINE_LINUX="numa=off"

十、系统优化

sudo vim /etc/sysctl.d/k8s_better.conf


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
vm.swappiness=0
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720

1
2
3
4
sudo modprobe br_netfilter
sudo lsmod |grep conntrack
sudo modprobe ip_conntrack
sysctl -p /etc/sysctl.d/k8s_better.conf

十一、免密登陆

ssh-keygen -t rsa 敲3下回车,生成秘钥

ssh-copy-id xxxxxxxxx

十二、系统依赖包:

sudo apt-get install -y conntrack ipvsadm ipset jq iptables curl sysstat wget vim net-tools git

十三、开启ipvs 转发

sudo modprobe br_netfilter

sudo mkdir -p /etc/sysconfig/modules/

修改配置文件 ipvs.modules

sudo vim /etc/sysconfig/modules/ipvs.modules


1
2
3
4
5
6
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack

1
2
3
sduo chmod 755 /etc/sysconfig/modules/ipvs.modules
sudo bash /etc/sysconfig/modules/ipvs.modules
sudo lsmod | grep -e ip_vs -e nf_conntrack