二进制部署1.23.4版本k8s集群-1-系统安装及环境准备

博客 分享
0 280
张三
张三 2022-03-13 18:56:29
悬赏:0 积分 收藏

二进制部署1.23.4版本k8s集群-1-系统安装及环境准备

1. 致谢

这篇文章参考了老男孩王导的视频,在此表示感谢和致敬!

2. 安装CentOS操作系统

系统镜像:CentOS-7-x86_64-DVD-2009.iso
安装过程略。

3. 环境准备

3.1 修改主机名

[root@CentOS-11 ~]# hostnamectl set-hostname cfzx55-11.host.com[root@CentOS-11 ~]# logout[root@cfzx55-11 ~]# hostnamecfzx55-11.host.com[root@cfzx55-11 ~]#

3.2 修改IP地址

[root@cfzx55-11 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0[root@cfzx55-11 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0TYPE="Ethernet"PROXY_METHOD="none"BROWSER_ONLY="no"BOOTPROTO="static"DEFROUTE="yes"IPV4_FAILURE_FATAL="no"NAME="eth0"DEVICE="eth0"ONBOOT="yes"IPADDR=10.211.55.11NETMASK=255.255.255.0GATEWAY=10.211.55.1DNS1=10.211.55.1

3.3 关闭IPV6地址

[root@cfzx55-11 ~]# vi /etc/default/grub[root@cfzx55-11 ~]# cat /etc/default/grubGRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos_centos-11/root rd.lvm.lv=centos_centos-11/swap rhgb quiet"GRUB_DISABLE_RECOVERY="true"[root@cfzx55-11 ~]#

GRUB_CMDLINE_LINUX中增加ipv6.disable=1

[root@cfzx55-11 ~]# grub2-mkconfig -o /boot/grub2/grub.cfgGenerating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-64ff7fa49756f945a81d0b1b41f366c5Found initrd image: /boot/initramfs-0-rescue-64ff7fa49756f945a81d0b1b41f366c5.imgdone[root@cfzx55-11 ~]# reboot

3.4 关闭SELinux

[root@cfzx55-11 ~]# vi /etc/selinux/config[root@cfzx55-11 ~]# cat /etc/selinux/config | grep SELINUX=# SELINUX= can take one of these three values:SELINUX=disabled[root@cfzx55-11 ~]#

3.5 关闭防火墙

[root@cfzx55-11 ~]# systemctl stop firewalld[root@cfzx55-11 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@cfzx55-11 ~]#

3.6 关闭邮件服务

[root@cfzx55-11 ~]# systemctl stop postfix[root@cfzx55-11 ~]# systemctl disable postfixRemoved symlink /etc/systemd/system/multi-user.target.wants/postfix.service.[root@cfzx55-11 ~]#

3.7 安装常用软件

[root@cfzx55-11 ~]# yum install -y wget vim net-tools

3.8 调整base源、EPEL源,添加K8S源

# 备份[root@cfzx55-11 ~]# mv /etc/yum.repos.d/CentOS-Base.repo{,.bak}# 使用阿里镜像源[root@cfzx55-11 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo2022-02-27 14:25:05 (2.06 MB/s) - '/etc/yum.repos.d/CentOS-Base.repo' saved [2523/2523]# 安装epel源[root@cfzx55-11 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo2022-02-27 14:26:02 (84.3 MB/s) - '/etc/yum.repos.d/epel.repo' saved [664/664][root@cfzx55-11 ~]# vim /etc/yum.repos.d/k8s.repo[root@cfzx55-11 ~]# cat /etc/yum.repos.d/k8s.repo[kubernetes]name=Kubernetesbaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0# 清除系统yum缓存,重新生成[root@cfzx55-11 ~]# yum clean all[root@cfzx55-11 ~]# yum makecache -y# 查看系统可用yum源和所有yum源[root@cfzx55-11 ~]# yum repolist enabledFailed to set locale, defaulting to CLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comrepo id                             repo name                                                          statusbase/7/x86_64                       CentOS-7 - Base - mirrors.aliyun.com                               10072epel/x86_64                         Extra Packages for Enterprise Linux 7 - x86_64                     13746extras/7/x86_64                     CentOS-7 - Extras - mirrors.aliyun.com                               509kubernetes                          Kubernetes                                                           775updates/7/x86_64                    CentOS-7 - Updates - mirrors.aliyun.com                             3572repolist: 28674[root@cfzx55-11 ~]#

3.9 时间同步

# 查看系统时间、时区[root@cfzx55-11 ~]# timedatectl[root@cfzx55-11 ~]# timedatectl list-timezones | grep -i shanghaiAsia/Shanghai[root@cfzx55-11 ~]# timedatectl set-timezone Asia/Shanghai[root@cfzx55-11 ~]# timedatectl status      Local time: Sat 2022-03-12 14:36:48 CST  Universal time: Sat 2022-03-12 06:36:48 UTC        RTC time: Sat 2022-03-12 06:36:48       Time zone: Asia/Shanghai (CST, +0800)     NTP enabled: yesNTP synchronized: yes RTC in local TZ: no      DST active: n/a[root@cfzx55-11 ~]## 安装chrony [root@cfzx55-11 ~]# yum -y install chrony# 配置chrony[root@cfzx55-11 ~]# vim /etc/chrony.conf[root@cfzx55-11 ~]# cat /etc/chrony.conf# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).server ntp1.alyun.comserver ntp2.alyun.comserver ntp3.alyun.com# 启动 chrony[root@cfzx55-11 ~]# systemctl start chronyd# 设为开机自启动[root@cfzx55-11 ~]# systemctl enable chronyd

3.10 关闭swap分区

[root@cfzx55-11 ~]# vim /etc/fstab# 注释swap一行

3.11 内核优化

[root@cfzx55-11 ~]# vim /etc/sysctl.d/k8s.conf[root@cfzx55-11 ~]# cat /etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-iptables=1net.bridge.bridge-nf-call-ip6tables=1net.ipv4.ip_forward=1net.ipv4.tcp_tw_recycle=0[root@cfzx55-11 ~]# sysctl --system 

3.12 克隆虚拟机:

共5台虚拟机,克隆完成后,修改IP地址和hostname

序号IP地址hostname
110.211.55.11cfzx55-11.host.com
210.211.55.12cfzx55-12.host.com
310.211.55.21cfzx55-21.host.com
410.211.55.22cfzx55-22.host.com
510.211.55.200cfzx55-200.host.com
posted @ 2022-03-13 18:51 itteer 阅读(0) 评论(0) 编辑 收藏 举报
回帖
    张三

    张三 (王者 段位)

    821 积分 (2)粉丝 (41)源码

     

    温馨提示

    亦奇源码

    最新会员