二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

  • Zabbix

  • AWS

  • Prometheus

  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

    • rancher-2-1-6的ha版本部署记录
      • 1,准备工作。
        • 1,主机准备。
        • 2,软件准备。
        • 3,软件版本。
        • 4,架构示意
      • 2,初始化环境。
        • 1,关闭相关服务
        • 2,主机名等设置。
        • 3,操作系统及 kernel 调优
        • 4,安装一些基础软件。
        • 5,创建用户等
      • 3,安装 docker。
      • 4,安装 nginx。
      • 5,Rancher 集群部署
        • 1,安装必要工具
    • rancher-2-1-6的ha版本部署记录
    • 关于rancher集群的高可用的实验
    • 关于rancher中部署应用的高可用的实验
    • 关于rancher-ha集群备份恢复试验
    • rancher-v2-2-2的HA部署文档
    • Rancher-2-2-2学习笔记-rancher-cli的使用
    • 基于Rancher-2-2-2的hpa实验
    • Rancher-2-2-2之Jenkins+rancher+harbor+Gitlab部署应用到生产
    • 使用docker快速部署rancher-2.8.5并投入生产实践
    • rancher如何重新注册托管集群
  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Rancher
二丫讲梵
2019-03-06
目录

rancher-2-1-6的ha版本部署记录

文章发布较早,内容可能过时,阅读注意甄别。

rancher2.1 版本的功能介绍:https://www.cnrancher.com/docs/rancher/v2.x/cn/overview/feature/

# 1,准备工作。

# 1,主机准备。

本次部署所用机器均为CentOS Linux release 7.6.1810 (Core)。

此处的空白是由于右边目录所致,如觉碍眼,点击隐藏即可使页面正常。

节点名称 IP 安装组件
nginx 192.168.10.2 nginx
node1 192.168.10.3 etcd, docker, k8s
node2 192.168.10.4 etcd, docker, k8s
node3 192.168.10.5 etcd, docker, k8s
harbor 192.168.10.6 harbor 私服

# 2,软件准备。

因为软件版本可能中有变更,所以我把这次部署的包都放在百度网盘,下载之后部署,以保证部署过程的流畅。

  • 下载地址:https://pan.baidu.com/s/1fBalGCouDxmiWK8RKHJAzA

  • 提取码: 6rut

文中相关部署软件的命令,可做相对应的调整。

# 3,软件版本。

  • rancher-2.1.6
  • kubernetes-1.11.6
  • helm-2.12

# 4,架构示意

image

# 2,初始化环境。

初始化部分,三台 node 机器都要操作。

# 1,关闭相关服务

  • 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
1
2
  • 关闭 setlinx
$ sudo setenforce 0
$ grep SELINUX /etc/selinux/config
SELINUX=disabled
1
2
3
  • 关闭 swap
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
1

# 2,主机名等设置。

  • 设置永久主机名称,然后重新登录
$ sudo hostnamectl set-hostname node1
$ sudo hostnamectl set-hostname node2
$ sudo hostnamectl set-hostname node3
1
2
3
  • 设置的主机名保存在 /etc/hosts 文件中
$ cat > /etc/hosts << EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.3 node1
192.168.10.4 node2
192.168.10.5 node3
EOF
1
2
3
4
5
6
7

# 3,操作系统及 kernel 调优

  • 文件打开数调优。
echo -e  "root soft nofile 65535\nroot hard nofile 65535\n* soft nofile 65535\n* hard nofile 65535\n"     >> /etc/security/limits.conf
sed -i 's#4096#65535#g' /etc/security/limits.d/20-nproc.conf
1
2
  • kernel 调优
cat >> /etc/sysctl.conf<<EOF
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
vm.swappiness=0
vm.max_map_count=655360
EOF
1
2
3
4
5
6
7

# 4,安装一些基础软件。

yum -y install wget ntpdate lrzsz curl yum-utils device-mapper-persistent-data lvm2 bash-completion && ntpdate -u cn.pool.ntp.org
1

# 5,创建用户等

  • 创建用户并且添加到 docker 组
groupadd docker
useradd rancher -G docker
echo "123456" | passwd --stdin rancher
1
2
3

这一步非常重要,如果没有操作,则后边可能会有报错等问题。

  • ssh 免密登录

在node1服务器上执行下面命令:

su - rancher
ssh-keygen
ssh-copy-id rancher@192.168.10.3
ssh-copy-id rancher@192.168.10.4
ssh-copy-id rancher@192.168.10.5
1
2
3
4
5

通过授权 node1 主机对三台主机的免密码登陆,为后边安装 k8s 的步骤做好准备工作。

# 3,安装 docker。

需要在三台主机上一起安装 docker。

rke工具要求docker版本为v17.03.2,请务必保持版本一致,否则后续安装会报错。

1、安装 repo 源:

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1

2,卸载旧 docker 版本

yum remove -y docker \
              docker-client \
              docker-client-latest \
              docker-common \
              docker-latest \
              docker-latest-logrotate \
              docker-logrotate \
              docker-selinux \
              docker-engine-selinux \
              docker-engine \
              container*
1
2
3
4
5
6
7
8
9
10
11

3、安装 docker-ce-17.03.2

export docker_version=17.03.2
version=$(yum list docker-ce.x86_64 --showduplicates | sort -r|grep ${docker_version}|awk '{print $2}')
yum -y install --setopt=obsoletes=0 docker-ce-${version} docker-ce-selinux-${version}
1
2
3

4、启动 docker

$ systemctl enable docker
$ systemctl start docker
$ systemctl status docker
1
2
3

5、添加国内加速代理,设置 storage-driver

cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://7bezldxe.mirror.aliyuncs.com/","https://kw88y6eh.mirror.aliyuncs.com"],
  "insecure-registries":["192.168.10.6"],
    "storage-driver": "overlay2",
    "storage-opts": [
    "overlay2.override_kernel_check=true"
    ]
}
EOF
1
2
3
4
5
6
7
8
9
10
  • registry-mirrors:表示公网的加速器地址,可设置多个,地址需要添加协议头(https或者http)。
  • insecure-registries:表示内网的私服地址,地址不能添加协议头(http)。
  • storage-driver:表示使用 OverlayFS 的 overlay2 存储驱动。

6、重启 docker

systemctl daemon-reload
systemctl restart docker
1
2

# 4,安装 nginx。

在192.168.10.2服务器上安装 nginx,用于 rancher-server 负载均衡。

安装 nginx:

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx -y
sudo systemctl enable nginx.service
1
2
3

修改配置文件:vi /etc/nginx/nginx.conf

user nginx;
worker_processes 4;
worker_rlimit_nofile 40000;
events {
    worker_connections 8192;
}
http {
    # Gzip Settings
    gzip on;
    gzip_disable "msie6";
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_vary on;
    gzip_static on;
    gzip_proxied any;
    gzip_min_length 0;
    gzip_comp_level 8;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml application/font-woff text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/opentype application/x-font-ttf application/vnd.ms-fontobjectfont/woff2 image/x-icon image/png image/jpeg;
    server {
        listen         80;
        return 301 https://$host$request_uri;
    }
}
stream {
    upstream rancher_servers {
        least_conn;
        server 192.168.10.3:443 max_fails=3 fail_timeout=5s;
        server 192.168.10.4:443 max_fails=3 fail_timeout=5s;
        server 192.168.10.5:443 max_fails=3 fail_timeout=5s;
    }
    server {
        listen     443;
        proxy_pass rancher_servers;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

启动 nginx:

sudo systemctl restart nginx.service
1

# 5,Rancher 集群部署

# 1,安装必要工具

以下操作只需在192.168.10.3这一台上操作即可。

  • 安装 rke:
su root
wget https://www.cnrancher.com/download/rke/rke_linux-amd64
chmod +x rke_linux-amd64
mv rke_linux-amd64 /usr/bin/rke
1
2
3
4
  • 安装 kubectl:
wget https://www.cnrancher.com/download/kubectl/kubectl_amd64-linux
chmod +x kubectl_amd64-linux
mv kubectl_amd64-linux /usr/bin/kubectl
1
2
3
  • 安装 helm:
wget https://www.cnrancher.com/download/helm/helm-linux.tar.gz
tar zxvf helm-linux.tar.gz
mv linux-amd64/helm /usr/bin/helm
mv linux-amd64/tiller /usr/bin/tiller
rm -rf helm-linux.tar.gz linux-amd64/
1
2
3
4
5

其它工具下载地址:https://www.cnrancher.com/docs/rancher/v2.x/cn/install-prepare/download/

当然,如果已经下载了上边我准备的软件包,那么直接解压软件包,然后将里边内容放到/usr/local/bin下即可。

之前原本完整的文章,经过修改竟然无法完整发布了,因此不得不将一篇文章拆分成两篇,以上算是整个部署的准备工作,下一篇进入正式的部署。

微信 支付宝
#k8s#rancher
上次更新: 2024/07/04, 22:40:37
博客已发布过的docker-compose拉起项目文件汇集
rancher-2-1-6的ha版本部署记录

← 博客已发布过的docker-compose拉起项目文件汇集 rancher-2-1-6的ha版本部署记录→

最近更新
01
学习周刊-总第212期-2025年第21周
05-22
02
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
03
学习周刊-总第211期-2025年第20周
05-15
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式