Docker部署mysql ndbcluster8 |
发表者:admin分类:云计算容器2023-08-14 12:48:50 阅读[419] |
Docker部署mysql ndbcluster8
一,环境说明
1,mysql ndbcluster8集群配置文件mysql-cluster.cnf内容:
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
NodeId=1
hostname=192.168.20.2
datadir=/var/lib/mysql
[ndbd]
NodeId=2
NodeGroup=1
hostname=192.168.20.3
datadir=/var/lib/mysql
[ndbd]
NodeId=3
NodeGroup=1
hostname=192.168.20.4
datadir=/var/lib/mysql
[ndbd]
NodeId=4
NodeGroup=2
hostname=192.168.20.5
datadir=/var/lib/mysql
[ndbd]
NodeId=5
NodeGroup=2
hostname=192.168.20.6
datadir=/var/lib/mysql
[mysqld]
NodeId=6
hostname=192.168.20.9
[mysqld]
NodeId=7
hostname=192.168.20.10
2,mysql配置文件my.cnf内容:
[mysqld]
log_timestamps = SYSTEM
max_connections = 5000
max_connect_errors = 10000
ndbcluster
ndb-connectstring=192.168.20.2
user=mysql
default-storage-engine=NDBCLUSTER
[mysql_cluster]
ndb-connectstring=192.168.20.2
二,docker部署命令。
1,创建cluster网络
docker network create cluster --subnet=192.168.20.0/24
2,创建mgmd与ndb,mysql相关节点
docker run -d --net=cluster --name=management1 --ip=192.168.20.2 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 ndb_mgmd
docker run -d --net=cluster --name=ndb1 --ip=192.168.20.3 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 ndbd
docker run -d --net=cluster --name=ndb2 --ip=192.168.20.4 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 ndbd
docker run -d --net=cluster --name=ndb3 --ip=192.168.20.5 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 ndbd
docker run -d --net=cluster --name=ndb4 --ip=192.168.20.6 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 ndbd
docker run -d --net=cluster --name=mysql1 --ip=192.168.20.9 -e MYSQL_RANDOM_ROOT_PASSWORD=true -p 3376:3306 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 mysqld
docker run -d --net=cluster --name=mysql2 --ip=192.168.20.10 -e MYSQL_RANDOM_ROOT_PASSWORD=true -p 3386:3306 -e "TZ=Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro -v /mysqlndb/my.cnf:/etc/my.cnf -v /mysqlndb/mysql-cluster.cnf:/etc/mysql-cluster.cnf container-registry.oracle.com/mysql/community-cluster:8.0 mysqld
3,查看集群节点是否正常。
docker exec -it management1 ndb_mgm -e show
root@os71 ~]# docker exec -it management1 ndb_mgm -e show
Connected to Management Server at: 192.168.20.2:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 4 node(s)
id=2 @192.168.20.3 (mysql-8.0.34 ndb-8.0.34, Nodegroup: 1, *)
id=3 @192.168.20.4 (mysql-8.0.34 ndb-8.0.34, Nodegroup: 1)
id=4 @192.168.20.5 (mysql-8.0.34 ndb-8.0.34, Nodegroup: 2)
id=5 @192.168.20.6 (mysql-8.0.34 ndb-8.0.34, Nodegroup: 2)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.20.2 (mysql-8.0.34 ndb-8.0.34)
[mysqld(API)] 2 node(s)
id=6 @192.168.20.9 (mysql-8.0.34 ndb-8.0.34)
id=7 @192.168.20.10 (mysql-8.0.34 ndb-8.0.34)
三,修改mysql API节点账号与密码
使用随机密码初始化服务器,该密码 需要改变。从日志中获取密码:
docker logs mysql1 2>&1 | grep PASSWORD
如果命令未返回密码,则服务器没有 尚未完成初始化。请稍等片刻,然后重试。一旦你 获取密码,通过使用客户端登录服务器来更改密码:mysql
docker exec -it mysql1 mysql -uroot -p
进入服务器后,使用 以下声明:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
开启 root 账号远程访问
flush privileges;
use mysql;
update user set host='%' where user='root';转载请标明出处【Docker部署mysql ndbcluster8】。
《www.micoder.cc》
虚拟化云计算,系统运维,安全技术服务.
Tags: | [阅读全文...] |
最新评论