Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

MySQL Cluster インストール on RedHat 6.x 覚書き

More than 3 years have passed since last update.

環境

Red Hat Enterprise Linux Server release 6.7 (Santiago)

台数

2台

ノード数

管理、データ、SQLの各ノードを各サーバーに起動させます。

事前処理

# yum install net-tools libaio perl wget

ダウンロード

$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.14-1.el6.x86_64.rpm-bundle.tar

展開

$ tar xvf MySQL-Cluster-gpl-7.4.14-1.el6.x86_64.rpm-bundle.tar

インストール

# rpm -ivh MySQL-Cluster-server-gpl-7.4.14-1.el6.x86_64.rpm
# rpm -ivh MySQL-Cluster-client-gpl-7.4.14-1.el6.x86_64.rpm

管理ノード

管理ノード設定ファイル作成

# mkdir -p /var/lib/mysql-cluster
# vim /var/lib/mysql-cluster/config.ini

管理ノード起動

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini

データノード

データノード起動

# /usr/sbin/ndbd --initial

SQLノード

SQLノード設定ファイル作成

# vim /etc/my.cnf

SQLノード起動

# /etc/init.d/mysql start

config.ini(サンプル)

# cat /var/lib/mysql-cluster/config.ini

[ndbd default]
NoOfReplicas=2
DataMemory=5120M
IndexMemory=768M
MaxNoOfConcurrentOperations=100000
MaxNoOfLocalOperations=110000
MaxNoOfConcurrentTransactions=100000
[ndb_mgmd]
hostname=XXX01
datadir=/var/lib/mysql-cluster
NodeId=1
[ndb_mgmd]
hostname=XXX02
datadir=/var/lib/mysql-cluster
NodeId=2
[ndbd]
hostname=XXX01
datadir=/var/lib/ndbd/db
NodeId=3
[ndbd]
hostname=XXX02
datadir=/var/lib/ndbd/db
NodeId=4
[mysqld]
hostname=XXX01
NodeId=7
[mysqld]
hostname=XXX02
NodeId=8
[mysqld]
[mysqld]

my.cnf(サンプル)

[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
port = 3306
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/slowsql.log
long_query_time = 0.1
character-set-server = utf8
collation-server = utf8_unicode_ci
key_buffer_size = 256M
max_allowed_packet = 2M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length=8k
read_buffer_size = 2M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 1M
query_cache_min_res_unit=4k
query_cache_size= 24M
query_cache_type=1
thread_concurrency = 20
thread_cache_size=200
max_connections=600
sync_binlog=0
innodb_thread_concurrency=20
innodb_fast_shutdown=0
open_files_limit=65535
expire_logs_days=30
transaction-isolation=REPEATABLE-READ
log-bin=mysql-bin
binlog_format=mixed
server-id=51
init_connect = 'SET AUTOCOMMIT=0'
query_cache_limit = 1M
join_buffer_size = 1M
ndbcluster
general_log=1
general_log_file=/var/lib/mysql/query.log
[mysql_cluster]
ndb-connectstring="XXX01,XXX02"
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
log-error=/var/log/mysql/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

動作チェック

# ndb_mgm -e show

Connected to Management Server at: XXX01:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @XX.XX.XX.XX (mysql-5.6.35 ndb-7.4.14, Nodegroup: 0)
id=4 @XX.XX.XX.XY (mysql-5.6.35 ndb-7.4.14, Nodegroup: 0, *)

[ndb_mgmd(MGM)] 2 node(s)
id=1 @XX.XX.XX.XX (mysql-5.6.35 ndb-7.4.14)
id=2 @XX.XX.XX.XY (mysql-5.6.35 ndb-7.4.14)

[mysqld(API)] 7 node(s)
id=7 @XX.XX.XX.XX (mysql-5.6.35 ndb-7.4.14)
id=8 @XX.XX.XX.XY (mysql-5.6.35 ndb-7.4.14)
id=9 (not connected, accepting connect from any host)
id=10 (not connected, accepting connect from any host)

リストア

今回構築した MySQL Cluster に対してリストアする要件がありその際のチューニングポイント

REDOログの容量をリストアするデータに応じて準備する必要があると思われる。

/var/lib/mysql-cluster/config.ini に追加項目

[ndbd default]
NoOfFragmentLogFiles=5000
FragmentLogFileSize=64M

リストア時に nbd_restore が SQLノードして扱われるので

/var/lib/mysql-cluster/config.ini に追加項目

の最後に

[mysqld]
[mysqld]

を、追加しておくと楽です。(空のスロットができるイメージですね)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away