mysql cluster 日志_mysql cluster

本文详细介绍了一种使用MySQL Cluster在多台服务器上搭建高可用数据库集群的方法。包括环境配置、各节点安装步骤、启动顺序及常见问题解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、环境描述

一台 10.0.0.201 SQL节点、管理节点

一台 10.0.0.202 做一个数据节点

一台 10.0.0.203做一个数据节点

2、安装Mysql_custter

在MGM管理节点、SQL节点、NDB节点执行同一操作

#:groupadd mysql

#: useradd mysql -g mysql -s /sbin/nologin

#: tar –xvf mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23.tar.gz

#:mv mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23 /usr/local/mysql_cluster

#:vim /etc/profile

MYSQL_CLUSTER=/usr/local/mysql_cluster/bin

PATH=$PATH:$HOME/bin:$MYSQL_CLUSTER

export PATH

#: source /etc/profile

3、安装MGM管理节点

#:mkdir -p /opt/mgm/logs

#:mkdir /opt/conf

#:vim /opt/conf/config.ini

# Options affecting ndbd processes on all home/data nodes:

[ndbd default]

NoOfReplicas=2 #每个数据节点的镜像数量

DataMemory=200M #每个数据节点中给数据分配的内存

IndexMemory=18M #每个数据节点中给索引分配的内存

MaxNoOfAttributes=999999

MaxNoOfConcurrentTransactions=10240

LogLevelStatistic=15

LogLevelCheckpoint=15

LogLevelConnection=15

LogLevelError=15

LogLevelInfo=15

[ndb_mgmd]

NodeId=1

Hostname=10.0.0.201

Datadir=/opt/mgm/logs

LogDestination=FILE:filename=ndb_1_cluster.log,maxsize=10000000,maxfiles=6

ArbitrationRank=0

[ndbd]

NodeId=10

Hostname=10.0.0.202

Datadir=/opt/db2/data #管理节点数据(日志)目录

backupdatadir=/opt/db2/databak #管理节点数据(日志)目录的备份

[ndbd]

NodeId=11

Hostname=10.0.0.203

Datadir=/opt/db3/data #管理节点数据(日志)目录

backupdatadir=/opt/db3/databak #管理节点数据(日志)目录的备份

[mysqld]

NodeId=20

[api]

[api]

[api]

[api]

[api]

启动管理节点:ndb_mgmd -f /opt/conf/config.ini --configdir=/opt/conf/

4、安装NDB管理节点

在202上

#:mkdir -p /opt/db2/data && mkdir /opt/db2/databak

#:mkdir /opt/conf

#:vim /opt/conf/my.cnf

[mysqld]

ndbcluster

ndb-connectstring=10.0.0.201

[mysql_cluster]

ndb-connectstring=10.0.0.201

在203上

#:mkdir -p /opt/db3/data && mkdir /opt/db3/databak

#:mkdir /opt/conf

#:vim /opt/conf/my.cnf

[mysqld]

ndbcluster

ndb-connectstring=10.0.0.201

[mysql_cluster]

ndb-connectstring=10.0.0.201

启动NDB节点

安装后第一次启动数据节点时要加上--initial参数,其它时候不要加,除非是在备份、恢复

配置变化后重启时

#: ndbd --defaults-file=/opt/conf/my.cnf --initial

5、安装SQL节点

#:groupadd mysql

#: useradd mysql –g mysql –s /sbin/nologin

#: mkdir -p /dbdata/data && chown mysql:mysql /dbdata/data

#:cp /usr/local/mysql_cluster/support-files/mysql.server /etc/init.d/mysql

#:vim /etc/init.d/mysql

basedir=/usr/local/mysql_cluster

datadir=/dbdadta/data

#:vim /usr/local/mysql_cluster/my.cnf

# Options for mysqld process:

[mysqld]

max_connections=200000

datadir=/dbdata/data/

log-error=/var/log/mysqld.log

port=3307

socket=/tmp/mysql.sock

character-set-server=utf8

default-storage-engine=ndbcluster

server-id=20

ndbcluster

# run NDB storage engine

ndb-connectstring=10.0.0.201

ndb-force-send=1

ndb-use-exact-count=0

ndb-extra-logging=1

ndb-autoincrement-prefetch-sz=512

#engine-condition-pushdown=1

ndb-cluster-connection-pool=1

key_buffer_size=16M

max_allowed_packet=10M

sort_buffer_size=256K

read_buffer_size=128K

read_rnd_buffer_size=256K

#table_lock_wait_timeout=16

memlock

sysdate_is_now

thread-cache-size=512

table-open_cache=512

max_prepared_stmt_count=24576

lower-case-table-names=0

# Timeout

interactive_timeout=43200

wait_timeout=43200

connect_timeout=60

skip-name-resolve

[ndbd]

connect-string=10.0.0.202

[ndbd_mgm]

connect-string=10.0.0.201

[mysql_cluster]

ndb-connectstring=10.0.0.201

# location of management server

#:初始化

#cd /usr/local/mysql_cluster/scripts/

#./mysql_install_db --user=mysql --basedir=/usr/local/mysql_cluster/ --datadir=/dbdata/data/

常见报错:

Installing MySQL system tables.../usr/local/mysql_cluster//bin/mysqld: error while

loading shared libraries: libaio.so.1: cannot open shared object file: No such file

or directory

解决办法:#: yum -y install libaio

启动SQL节点

#:/etc/init.d/mysqld start

如果SQL启动失败。请保持虚拟机或者真实机的内存至少500M以上

6、测试与常见问题

启动顺序

MGM-->NDB-->SQL

关闭顺序

关闭

SQL-->MGM (NDB)

当关闭掉MGM后。NDB也会停掉

关闭MGM

ndb_mgm -e shutdown

测试:

ndb_mgm -e show

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值