1. 虚拟主机配置
[root@k8s3 ~]# more /etc/hosts
[root@k8s1 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.168.20 k8s-master
192.168.168.30 k8s-node01
192.168.168.40 k8s-node02
2、关闭所有节点关闭防火墙、selinux、dnsmasq、swap。
systemctl disable --now firewalld
systemctl disable --now dnsmasq
systemctl disable --now NetworkManager
setenforce 0
#永久关闭SELinux开启自启动
vi /etc/sysconfig/selinux
SELINUX=disabled
swap,linux虚拟内存,将部分内存数据存放到磁盘中,内存不足会使用,如果生产服务器中swap出现swap使用,需要升级资源。
[root@k8s1 ~]# swapoff -a
[root@k8s1 ~]# free -h
total used free shared buff/cache available
Mem: 468M 189M 114M 5.8M 163M 260M
Swap: 0B 0B 0B
[root@k8s1 ~]#
#永久关闭swap 需要修改配置文件
[root@k8s1 ~]# cat /etc/fstab | grep swap
#/dev/mapper/centos-swap swap swap defaults 0 0
[root@k8s1 ~]#
3、NTP时钟服务器配置
timedatectl 查看具体时间时区
timedatectl list-timezones 查看具所有时区
timedatectl set-timezone Asia/Shanghai 设置时区
[root@k8s3 ~]# rpm -qa | grep ntp --查看ntp服务需要的rpm包是否安装
ntp-4.2.6p5-29.el7.centos.2.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
python-ntplib-0.3.2-1.el7.noarch
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
[root@k8s3 ~]#
NTPD服务端配置
vim /etc/ntp.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst --注释
#server 1.centos.pool.ntp.org iburst --注释
#server 2.centos.pool.ntp.org iburst --注释
#server 3.centos.pool.ntp.org iburst --注释
server 127.127.1.0 iburs --配置自己主机或IP
root@k8s1 yum.repos.d]# systemctl stop ntpd
[root@k8s1 yum.repos.d]# ps -ef | grep ntpd
root 4316 1518 0 08:04 pts/0 00:00:00 grep --color=auto ntpd
[root@k8s1 yum.repos.d]#
[root@k8s1 yum.repos.d]# systemctl start ntpd
[root@k8s1 yum.repos.d]# ps -ef | grep ntpd
root 4324 1 0 08:04 ? 00:00:00 /usr/sbin/ntpd -u ntp:ntp -g
root 4326 1518 0 08:04 pts/0 00:00:00 grep --color=auto ntpd
[root@k8s1 yum.repos.d]#
#开机自启
[root@k8s1 yum.repos.d]# systemctl enable ntpd
[root@k8s1 yum.repos.d]# ntpq -p --检查NTP服务
remote refid st t when poll reach delay offset jitter
=========================================================================
*LOCAL(0) .LOCL. 5 l 12 64 1 0.000 0.000 0.000
NTPD客户端配置
[root@k8s3 ~]# vim /etc/ntp.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst --注释
#server 1.centos.pool.ntp.org iburst --注释
#server 2.centos.pool.ntp.org iburst --注释
#server 3.centos.pool.ntp.org iburst --注释
server 192.168.168.20 iburst
[root@k8s3 ~]# systemctl stop ntpd
[root@k8s3 ~]# systemctl start ntpd
[root@k8s3 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
=========================================================================
k8s-master .INIT. 16 u - 64 0 0.000 0.000 0.000
4、环境变量配置
所有节点配置limit:
ulimit -SHn 65535 ---临时配置
vim /etc/security/limits.conf --永久配置需要修改配置文件, 重启服务生效
* soft nofile 655360
* hard nofile 131072
* soft nproc 655350
* hard nproc 655350
* soft memlock unlimited
* hard memlock unlimited
下面是一些Linux资源类命令,仅供参考
[root@k8s1 yum.repos.d]# lsof -n |awk '{print $2}' | sort |uniq | sort -nr |more
4767
4766
统计各进程打开句柄数:lsof -n|awk ‘{print $2}’|sort |uniq -c|sort -nr
统计各用户打开句柄数:lsof -n|awk ‘{print $3}’|sort |uniq -c|sort -nr
统计各命令打开句柄数:lsof -n|awk ‘{print $1}’|sort |uniq -c|sort -nr
查看当前进程实时打开的文件数:lsof -p 进程PID | wc -l
查看某个进程的句柄数限制:cat /proc/进程ID/limits
查看系统限制的最大文件打开数:cat /proc/sys/fs/file-max
查看系统当前已使用的文件句柄数:cat /proc/sys/fs/file-nr