-
Notifications
You must be signed in to change notification settings - Fork 97
/
create.b.mariadb.start.sh
executable file
·160 lines (101 loc) · 2.65 KB
/
create.b.mariadb.start.sh
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
DIR=$(cd $(dirname $0); pwd)
OS_VER="CentOS7"
if grep -Eq "CentOS Linux release 8" /etc/*-release; then
echo "CentOS Linux release 8";
cat /etc/redhat-release
OS_VER="CentOS8"
fi
rm -rf /etc/yum.repos.d/mariadb.repo
if [ "${OS_VER}"x = "CentOS8"x ]; then
# https://downloads.mariadb.org/mariadb/repositories/#mirror=exascale
cat <<EOF > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.4/centos8-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck=1
EOF
dnf clean all
dnf makecache
dnf repolist
dnf install -y MariaDB-client
else
cat <<EOF > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck=1
EOF
yum clean all
yum makecache
yum repolist
yum install -y MariaDB-client
fi
docker pull mariadb:10.4
mkdir -p ${DIR}/mariadb/data
mkdir -p ${DIR}/mariadb/mariadb.conf.d
chmod -R 777 ${DIR}/mariadb/data
chmod -R 777 ${DIR}/mariadb/mariadb.conf.d
kubectl create -f ${DIR}/mariadb/service.yml
kubectl create -f ${DIR}/mariadb/pod.yml
echo "等待 mariadb pod 容器启动成功"
echo "180 秒等待时间"
kubectl get pod
sleep 10s
kubectl get pod
echo "150 秒等待时间"
sleep 10s
kubectl get pod
echo "140 秒等待时间"
sleep 10s
kubectl get pod
echo "130 秒等待时间"
sleep 10s
echo "120 秒等待时间"
sleep 10s
echo "110 秒等待时间"
sleep 10s
echo "100 秒等待时间"
sleep 10s
echo "90 秒等待时间"
sleep 10s
echo "80 秒等待时间"
sleep 10s
echo "70 秒等待时间"
sleep 10s
echo "60 秒等待时间"
sleep 10s
kubectl get pod
echo "50 秒等待时间"
sleep 10s
echo "40 秒等待时间"
sleep 10s
echo "30 秒等待时间"
sleep 10s
echo "20 秒等待时间"
sleep 10s
echo "10 秒等待时间"
sleep 10s
# 这里的休眠只是让数据库容器 尽快创建成功
sleep 10s
kubectl get pod
echo -e "开始 导入 nacos-mysql.sql 数据"
#echo -e "创建 nacos 用户,密码为 nacos"
echo -e "直接使用 数据库默认用户及密码 root/root"
echo -e "创建 库 nacos "
# 导入数据库SQL
mysql -h127.0.0.1 -uroot -proot mysql < ${DIR}/mariadb/sql/nacos-mysql.sql
echo -e "\nnacos-mysql.sql 数据导入成功 \n\n\n"
echo -e "开始 导入 xxl-job sql.sql 数据"
echo -e "使用系统 用户 root,密码为 root"
echo -e "创建 库 xxl_job "
# 导入数据库SQL
mysql -h127.0.0.1 -uroot -proot mysql < ${DIR}/job-xxl-job/sql/sql.sql
echo -e "\nnacos-mysql.sql 数据导入成功 \n\n\n"
kubectl get pod
echo -e "\n\n\n"
echo "mariadb success"