本站总访问量 mariadb数据库搭建 - Jerry的小站

Jerry Gao

上帝就是真理,真理就是上帝

MariaDB数据库是MySQL数据库的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB数据库是MySQL数据库的一个分支,主要由开源社区在维护,采用GPL授权许可。

Kubernetes部署

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
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mariadb-data
namespace: stable-db
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storageClassName: standard-rwo
volumeMode: Filesystem
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: mariadb
namespace: stable-db
labels:
app: mariadb
spec:
replicas: 1
selector:
matchLabels:
app: mariadb
template:
metadata:
labels:
app: mariadb
spec:
volumes:
- name: mariadb-data
persistentVolumeClaim:
claimName: mariadb-data
containers:
- name: mariadb
image: mariadb:10.1
imagePullPolicy: IfNotPresent
ports:
- name: mariadb
containerPort: 3306
protocol: TCP
env:
- name: MYSQL_ROOT_PASSWORD
value: <root-password>
- name: MYSQL_USER
value: <user>
- name: MYSQL_PASSWORD
value: <password>
resources:
limits:
cpu: "2"
memory: 4Gi
requests:
cpu: "2"
memory: 4Gi
ephemeral-storage: 10Gi
volumeMounts:
- name: mariadb-data
mountPath: /var/lib/mysql/
livenessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 30
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 30
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File

docker-compose 部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: '3'
services:
mariadb:
image: mariadb:10.1
container_name: mariadb
restart: always
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: <root-password>
MYSQL_USER: <user>
MYSQL_PASSWORD: <password>
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '2'
memory: 4G
volumes:
- /data/mariadb:/var/lib/mysql

评论