MySQL NDB Cluster 分布式架构搭建 自定义启动、重启和关闭集群Shell脚本_mysql cluster 架构

#!includedir /etc/my.cnf.d


 在初始化mysqld之前,需要将**data、logs、sock**文件夹创建完毕,否则无法初始化



[hadoop@hadoop103 mysql-cluster]$ pwd
/usr/local/mysql-cluster
[hadoop@hadoop103 mysql-cluster]$ ls
bin docs include lib LICENSE man README share support-files
[hadoop@hadoop103 mysql-cluster]$ mkdir data
[hadoop@hadoop103 mysql-cluster]$ mkdir sock
[hadoop@hadoop103 mysql-cluster]$ mkdir logs


 初始化mysqld,同时没有对root账号设置密码



[hadoop@hadoop103 mysql-cluster]$ bin/mysqld --initialize-insecure --user=hadoop
2024-03-01T22:50:53.201408Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2024-03-01T22:50:53.201412Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
2024-03-01T22:50:53.202613Z 0 [Warning] [MY-011070] [Server] ‘Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it’ is deprecated and will be removed in a future release.
2024-03-01T22:50:53.202952Z 0 [System] [MY-013169] [Server] /usr/local/mysql-cluster/bin/mysqld (mysqld 8.0.36-cluster) initializing of server in progress as process 2947
2024-03-01T22:50:53.211541Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-03-01T22:50:53.873353Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-03-01T22:50:54.189948Z 0 [System] [MY-010865] [NDB] ‘–initialize’ -> ndbcluster plugin disabled
2024-03-01T22:50:55.344321Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[hadoop@hadoop103 mysql-cluster]$ sudo cp support-files/mysql.server /etc/init.d/mysqld
[hadoop@hadoop103 mysql-cluster]$ sudo chmod +x /etc/init.d/mysqld


再初始化初始化数据节点,注意此时初始化完毕会自动连接到管理节点



[hadoop@hadoop103 mysql-cluster]$ bin/ndbd --initial
2024-03-02 06:51:57 [ndbd] INFO – Angel connected to ‘192.168.182.102:1186’
2024-03-02 06:51:57 [ndbd] INFO – Angel allocated nodeid: 2


 集群目前连接情况



[hadoop@hadoop102 mysql-cluster]$ bin/ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration

[ndbd(NDB)] 2 node(s)
id=2 @192.168.182.103 (mysql-8.0.36 ndb-8.0.36, starting, Nodegroup: 0)
id=3 (not connected, accepting connect from 192.168.182.104)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.182.102 (mysql-8.0.36 ndb-8.0.36)

[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 192.168.182.103)
id=5 (not connected, accepting connect from 192.168.182.104)


注意SQL节点需要在数据节点全部启动后,才能开始启动,所以别着急启动mysqld


同时为了防止在之后停止mysqld的时候,出现**rm: cannot remove '/var/lock/subsys/mysql': Permission denied**报错,导致后续无法启动mysqld,需要修改该文件夹的权限



sudo chown -R hadoop:hadoop /var/lock/subsys


第三台服务器操作同第二台操作一致。在第三台服务器完成数据节点初始化之后,便可以启动两个SQL节点。整个集群启动成功后的连接情况如下



[had

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值