应用部署需要关注的信息【应用部署三要素】

1、应用的部署方式

2、应用的数据挂载(数据,配置文件)

3、应用的可访问性

image-20230129155209779

一、MySQL

1、创建配置

image-20230129155402637

image-20230129155504840

image-20230129155604640

1
2
3
4
5
6
7
8
9
10
11
12
13
[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

2、创建存储卷

注意:如果没有安装 nfs 文件系统,需要提前安装一下,安装方法请参考附加内容

image-20230129155802439

image-20230129161731413

后面点击创建即可。

3、创建有状态应用

image-20230129165642095

image-20230129162107529

image-20230129162220310

image-20230129162257903

image-20230129162442920

image-20230129162600190

image-20230129162738141

image-20230129162803248

image-20230129162900703

之后点击下一步 ==》 创建

4、配置负载均衡网络

  • 自定义集群内服务名访问

在服务里面,删除原先的有状态副本集

image-20230129172456606

创建

image-20230129172541006

image-20230129172626509

image-20230129172720706

image-20230129172802517

image-20230129172851437

最后点击创建即可。

  • 外网访问

创建

image-20230129173254502

image-20230129173447548

image-20230129173502149

image-20230129173529796

image-20230129173603453

image-20230129173640085

image-20230129173841755

测试

image-20230129173830803

二、Redis

1、创建配置

image-20230129232039958

image-20230129232137801

1
2
3
appendonly yes
port 6379
bind 0.0.0.0

点击创建即可

2、创建有状态应用

应用负载 ==》 工作负载

image-20230129232357869

image-20230129232443868

image-20230129232514611

image-20230129232611066

1
2
运行命名 redis-server
参数 /etc/redis/redis.conf

image-20230129232740906

image-20230129232848300

image-20230129232914015

image-20230129233024587

最后点击创建即可。

3、配置负载均衡网络

应用负载 ==》 服务

image-20230130002159940

image-20230130002639249

image-20230130002724916

image-20230130002753523

三、ElasticSearch

在任意节点上创建目录:
mkdir -p /mydata/es-01 && chmod 777 -R /mydata/es-01

1、创建配置文件

image-20230130141142115

image-20230130141503420

1
2
cluster.name: "docker-cluster"
network.host: 0.0.0.0

image-20230130142631820

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
################################################################
##
## 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-20230130142709614

2、创建有状态应用

应用负载 ==》 工作负载

image-20230130142930059

image-20230130143010725

1
elasticsearch:7.13.4

image-20230130143051413

image-20230130143221668

image-20230130143300452

image-20230130143401533

image-20230130143420223

这个地方需要注意:

image-20230130143725462

image-20230130143914422

点击创建即可。

3、配置负载均衡网络

应用负载 ==》 服务

image-20230130154138033

image-20230130154211040

image-20230130154238921

image-20230130154352913

image-20230130154411265

四、Nacos

1、创建配置

image-20230201140415010

image-20230201140756786

图片中的两个配置项请参考 nacos-2.0.3 版本,目录下 conf

image-20230201140848292

cluster.conf

1
2
3
ruoyi-nacos-v1-0.ruoyi-nacos.ruoyi.svc.cluster.local:8848
ruoyi-nacos-v1-1.ruoyi-nacos.ruoyi.svc.cluster.local:8848
ruoyi-nacos-v1-2.ruoyi-nacos.ruoyi.svc.cluster.local:8848

2、创建有状态应用

image-20230201141119776

image-20230201141134249

image-20230201141211264

image-20230201141229521

1
nacos/nacos-server:v2.0.3

image-20230201141332088

image-20230201141416511

这里需要配置一个健康检查:

image-20230201232157515

image-20230201232220508

image-20230202134530703

image-20230201141431684

image-20230201141455898

image-20230201143453676

image-20230201143559597

3、配置负载均衡网络

image-20230201143813427

image-20230201143913036

image-20230201143938739

五、Sentinel

1、创建有状态应用

image-20230202143120511

1
leifengyang/sentinel:1.8.2

image-20230202143053216

image-20230202143214493

后面下一步点击创建即可。

2、配置负载均衡网络

image-20230202143959179

image-20230202144021841

image-20230202144034025