0.虛擬機准備
wmware15安裝centos7.9:https://www.cnblogs.com/uncleyong/p/15261742.html
1.配置靜態ip
TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="none" 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="67760d22-eb54-4a07-9f48-c2306c51c5d3" DEVICE="ens33" ONBOOT="yes" IPADDR="192.168.117.161" PREFIX="24" GATEWAY="192.168.117.2" DNS1="192.168.117.2" IPV6_PRIVACY="no"
2.關閉防火牆
systemctl disable --now firewalld systemctl disable --now dnsmasq systemctl disable --now NetworkManager
3.關閉selinux
setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
4.關閉交換分區
sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab
5.修改yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
6.修改內核參數
vim /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 65535 * hard nproc 655350 * soft memlock unlimited * hard memlock unlimited
7.修改主機名
比如:hostnamectl set-hostname k8s-master01
8.配置hosts文件
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.117.161 k8s-master01 192.168.117.162 k8s-node01 192.168.117.163 k8s-node02
9.安裝常用工具
yum -y install net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server socat ipvsadm conntrack ntpdate yum-utils device-mapper-persistent-data lvm2
10.同步時間
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm yum install ntpdate -y ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'Asia/Shanghai' >/etc/timezone ntpdate time2.aliyun.com */5 * * * * /usr/sbin/ntpdate time2.aliyun.com systemctl restart crond
11.升級系統及內核(4.x)
centos7.x默認內核是3.10
下載4.x的kernel-ml-deve和kernel-ml
安裝: yum localinstall -y kernel-ml*
更改內核啟動順序
grub2-set-default 0&& grub2-mkconfig -o /etc/grub2.cfg grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
reboot重啟后,查看內核是否為升級后的:uname -a
12.安裝docker
添加docker需要的yum源:yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce-19.03.15* docker-ce-cli-19.03.15* -y
mkdir /etc/docker
cd /etc/docker
vim daemon.json
{ "exec-opts": ["native.cgroupdriver=systemd"] }
啟動:systemctl daemon-reload && systemctl enable --now docker && systemctl status docker
虛擬機已經安裝配置好(如需要vof虛擬機模板文件,請微信聯系作者)
原文:https://www.cnblogs.com/uncleyong/p/15471002.html