System initialization
k8s test information
hsot address user password master 192.168.0.10 root 123456 node 192.168.0.30 root 123456
Centos7 initialization
sed -i '/ONBOOT/s/no/yes/' /etc/sysconfig/network-scripts/ifcfg-eth0 && /etc/init.d/network restart
== == == == == == == == == ==
ONBOOT= yes
BOOTPROTO= static
IPADDR= 192.168.0.30
NETMASK= 255.255.255.0
GATEWAY= 192.168.0.1
PEERD= no
DNS1= 8.8.8.8
DNS2= 114.114.114.114
DNS3= 223.6.6.6
== == == == == == == == == ==
yum -y install net-tools wget
wget http://mirrors.aliyun.com/repo/Centos-7.repo
echo nameserver 8.8.8.8 > /etc/resolv.conf
yum clean all && yum makecache
yum install -y conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysstat libseccomp wget vim net-tools git lrzsz
Set iptables
systemctl stop firewalld && systemctl disable firewalld
yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save
Close SELINUX
swapoff -a && sed -i '/ swap /s/^\(.*\)$/#\1/g' /etc/fstab
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
Set kernel
cat > kubernetes.conf << EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0 #禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
vm.overcommit_memory=1 #不检查物理内存是否够用
vm.panic_on_oom=0 #开启 OOM
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
EOF
cp kubernetes.conf /etc/sysctl.d/kubernetes.conf
sysctl -p /etc/sysctl.d/kubernetes.conf
Set timezone
timedatectl set-timezone Asia/Shanghai
timedatectl set-local-rtc 0
systemctl restart rsyslog
systemctl restart crond
Close useless service
systemctl stop postfix && systemctl disable postfix
Set journal log
mkdir /var/log/journal
mkdir /etc/systemd/journald.conf.d
cat > /etc/systemd/journald.conf.d/99-prophet.conf << EOF
[Journal]
# 持久化保存到磁盘
Storage=persistent
# 压缩历史日志
Compress=yes
SyncIntervalSec=5m
RateLimitInterval=30s
RateLimitBurst= 1000
# 最大占用空间 10G
SystemMaxUse=10G
# 单日志文件最大 200M
SystemMaxFileSize=200M
# 日志保存时间 2 周
MaxRetentionSec=2week
# 不将日志转发到 syslog
ForwardToSyslog=no
EOF
systemctl restart systemd-journald
Update kernel(>=4.44)
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo= elrepo-kernel install -y kernel-lt
grub2-set-default 'CentOS Linux (5.4.113-1.el7.elrepo.x86_64) 7 (Core)' && reboot
uname -r