kuberSphere搭建中间件

本文是作者学习kuberSphere过程中的具体搭建流程,供需要的小伙伴一起学习进步,具体中间件包括:MySQL、Redis、ElasticSearch、RabbitMQ。搭建的过程从最基础的部分开始,可能比直接通过应用商店部署应用的方式复杂。但可以更加深入理解整体的搭建过程。后续真实需求场景,为方便起见,可以考虑直接通过应用商店的方式部署。本文的RabbitMQ中间件采用了应用的方式部署,供读者参考。enjoy!

1 MySQL搭建

1631544800244-cd4ed8a8-06d0-40bc-9752-dd0ba9df325c.png

1.1 添加mysql的配置文件

  1. 创建新的配置文件
image-20220429102842467.png
  1. 编辑conf的基本信息,包括名称和描述信息
image-20220429103024950.png
  1. 编辑conf的配置信息,其中的键作为文件名,值作为文件中的内容
image-20220429103135445.png
# my.cnf
[client]
default-character-set=utf8mb4
 
[mysql]
default-character-set=utf8mb4
 
[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
  1. 创建配置文件成功
image-20220429103205231.png

1.2 创建mysql的服务

  1. 创建新的服务
image-20220429103313648.png
  1. 由于mysql需要保存数据,需要创建有状态的服务
image-20220429103356175.png
  1. 编写服务的基本信息
image-20220429103430019.png
  1. 添加容器镜像
image-20220429103521401.png
  1. 初始化密码设置并同步主机时区
MYSQL_ROOT_PASSWORD=199748
image-20220429103558840.png
  1. 添加挂载的存储卷模版(模块会为每个实例挂载对应的data卷,而不是只存在一个卷被所有实例共享)
/var/lib/mysql
image-20220429103937485.png
image-20220429103817368.png
  1. 添加服务的配置文件(会将配置文件挂载至对应的挂载目录下,仅仅包含挂载的文件,其他文件存在也会被覆盖)
/etc/mysql/conf.d
image-20220429104009157.png
image-20220429104038101.png

1.3 配置外网访问端口

  1. 创建自定义方式的服务
image-20220429104348076.png
  1. 编写服务基本信息
image-20220429104436524.png
  1. 指定工作负载,并设置容器端口
image-20220429104527226.png
  1. 指定外网访问
image-20220429104550075.png
image-20220429104605723.png

1.4 连接测试

  1. 集群内部可以通过DNS域名访问mysql
image-20220429104754284.png
  1. 集群外部可以通过NodePort暴露的port访问
image-20220429104940955.png

2 Redis 搭建

1631610241479-a4dc9586-872d-49ef-95a0-2d0116c9b9ed.png

2.1 添加 redis 配置文件

  1. 创建新的配置文件,填写redis的基本信息
image-20220429143957046.png
  1. 编辑conf的配置信息,其中的键作为文件名,值作为文件中的内容
# redis.conf
appendonly yes
port 6379
bind 0.0.0.0
image-20220429144105866.png
  1. 创建配置文件成功
image-20220429144151914.png

2.2 创建 redis 的服务

  1. 创建新的服务,由于redis需要缓存数据至本地,需要创建有状态的服务
image-20220429103356175.png
  1. 编写服务的基本信息
image-20220429144334755.png
  1. 添加容器
image-20220429144431014.png
  1. 添加redis的启动命令并同步主机时区
redis-server /etc/redis/redis.conf
image-20220429144526669.png
  1. 添加挂载的存储卷模版(模块会为每个实例挂载对应的data卷,而不是只存在一个卷被所有实例共享)
/data
image-20220429103937485.png
image-20220429144746259.png
  1. 添加服务的配置文件(会将配置文件挂载至对应的挂载目录下,仅仅包含挂载的文件,其他文件存在也会被覆盖)
/etc/redis/
image-20220429144921859.png

2.3 配置外网访问端口

参考 MySQL 搭建的流程,与其一致,指定为NodePort形式

2.4 连接测试

  1. 集群内部可以通过DNS域名访问 redis
image-20220429150529574.png
  1. 集群外部可以通过NodePort暴露的port访问
image-20220429150716489.png

3 ElasticSearch 搭建

1631609524580-f264a6dc-e619-4843-a717-b8852716785d.png

3.1 添加 ES 配置文件

  1. 编写基础配置信息
image-20220429160349307.png
  1. 添加两个配置信息
  • elasticsearch配置信息
# elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
image-20220429160501597.png
  • jvm配置信息
# jvm.options
################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
image-20220429160557916.png
  1. 创建配置文件成功
image-20220429160801015.png

3.2 创建 es 服务

  1. 创建有状态服务,由于es需要存储数据
image-20220429160845193.png
  1. 编写服务基本信息
image-20220429160920040.png
  1. 添加镜像
image-20220429161005484.png
  1. 添加环境变量
discovery.type     single-node
ES_JAVA_OPTS       -Xms512m -Xmx512m
image-20220429161108687.png
  1. 挂载存储模版
/usr/share/elasticsearch/data
image-20220429161310160.png
  1. 挂载两个配置文件
  • 挂载第一个配置文件
/usr/share/elasticsearch/config/elasticsearch.yml
image-20220429161908750.png
  • 挂载第二个配置文件
/usr/share/elasticsearch/config/jvm.options
image-20220429162017148.png

3.3 配置外网访问端口

参考 MySQL 搭建的流程,与其一致,指定为NodePort形式

3.4 连接测试

  1. 集群内部连接测试
image-20220429163531823.png
  1. 集群外部连接测试
image-20220429163702174.png

4 RabbitMQ 搭建(应用市场)

4.1 添加应用市场仓库

  1. 登陆拥有企业空间权限的账号「beijing-boss」
  2. 添加应用仓库地址
https://charts.bitnami.com/bitnami
image-20220429170102941.png
image-20220429170139336.png
  1. 添加应用仓库成功
image-20220429170214971.png

4.2 通过应用商店部署RabbitMQ

  1. 切换至bitnami的应用商店,并选择 RabbitMQ 应用
image-20220430151644027.png
  1. 填写基本信息和选择版本后,部署
image-20220430151735015.png
  1. 开放外网访问端口
image-20220430152118458.png
  1. 部署成功,可以外网登陆 RabbitMQ
image-20220430152054919.png
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

攻城老湿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值