[MySQLD]
ndbcluster # run NDB engine
ndb-connectstring=192.168.1.251 # location of MGM node
# Options for ndbd process:
[MySQL_CLUSTER]
ndb-connectstring=192.168.1.251 # location of MGM node
A: /var/lib/MySQL-cluster/config.ini
[NDBD DEFAULT]
NoOfReplicas=1 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# TCP/IP options:
[TCP DEFAULT]
portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in cluster
# Note: It is recommended beginning with MySQL 5.0 that
# you do not specify the portnumber at all and simply allow
# the default value to be used instead
# Management process options:
[NDB_MGMD]
hostname=192.168.1.251 # Hostname or IP address of MGM node
datadir=/var/lib/MySQL-cluster # Directory for MGM node logfiles
# Options for data node "A":
[NDBD]
# (one [NDBD] section per data node)
hostname=192.168.1.251 # Hostname or IP address
datadir=/usr/local/MySQL/data # Directory for this data node's datafiles
# SQL node options:
[MySQLD]
hostname=192.168.1.254
#[MySQLD] #这个相当于192.168.1.251
shell>ndb_mgmd -f /var/lib/MySQL-cluster/config.ini
shell>ndbd--initial
shell>MySQLd &
./ndb_mgm
-- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: 192.168.1.251:1186 Cluster Configuration --------------------- [ndbd(NDB)] 1 node(s) id=2 @192.168.1.251 (Version:5.0.22, Nodegroup: 0, Master) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.1.251 (Version:5.0.22) [MySQLd(API)] 1 node(s) id=3 @192.168.1.254 (Version:5.0.22) ok
shell>ndb_mgm -e shutdown
[root@sqltest01 u01]# service iptables status
iptables: Firewall is not running.
[root@sqltest01 u01]# groupadd mysql [root@sqltest01 u01]# useradd -r -g mysql mysql [root@sqltest01 u01]# mkdir -p /usr/local/mysql [root@sqltest01 u01]# chown -R mysql.mysql
[root@sqltest01 u01]# tar -zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/have_plugin_auth.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/kill_query.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/unsafe_binlog.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/have_multi_ndb.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/ipv6_clients.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/setup_fake_relay_log.inc mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/mysql-test/include/wait_for_slave_sql_error_and_skip.inc ......................................................................................................
[root@sqltest03 mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# pwd /u01/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 [root@sqltest03 mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# mv * /usr/local/mysql/
[root@sqltest03 u01]# cd /usr/local/mysql [root@sqltest03 mysql]# mkdir mysql-cluster [root@sqltest03 mysql]# pwd /usr/local/mysql [root@sqltest03 mysql]# cp bin/ndb_mgm* /usr/local/bin/ [root@sqltest03 mysql]# cd /var/lib [root@sqltest03 mysql]# mkdir mysql-cluster [root@sqltest03 mysql]# cd mysql-cluster [root@sqltest03 mysql]# vi config.ini
[root@sqltest03 mysql-cluster]# cat config.ini [ndbd default] NoOfReplicas=1 DataMemory=2048M IndexMemory=512M [tcp default] [ndb_mgmd] hostname=192.168.9.243 datadir=/var/lib/mysql-cluster NodeId=1 [ndbd] hostname=192.168.9.241 datadir=/u01/mysql/data NodeId=2 [ndbd] hostname=192.168.9.242 datadir=/u01/mysql/data NodeId=3 [mysqld] hostname=192.168.9.241 NodeId=4 [mysqld] hostname=192.168.9.242 NodeId=5
[root@sqltest03 bin]# pwd /usr/local/bin [root@sqltest03 bin]# ./ndb_mgmd -f /var/lib/mysql-cluster/config.ini MySQL Cluster Management Server mysql-5.6.21 ndb-7.3.7
[root@sqltest03 bin]# ndb_mgm
-- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from 192.168.9.241) id=3 (not connected, accepting connect from 192.168.9.242) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.9.243 (mysql-5.6.21 ndb-7.3.7) [mysqld(API)] 2 node(s) id=4 (not connected, accepting connect from 192.168.9.241) id=5 (not connected, accepting connect from 192.168.9.242)
[root@sqltest01 mysql]# mkdir -p /usr/local/mysql --用于存放刚才解压的文件,如mysql的bin目录等 [root@sqltest01 mysql]# mkdir -p /u01/mysql/data --用于存储数据文件(innodb) [root@sqltest01 mysql]# chown -R mysql.mysql /u01
[root@sqltest01 mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# pwd /u01/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 [root@sqltest01 mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# mv * /usr/local/mysql/ [root@sqltest01 mysql]# chown -R mysql.mysql /usr/local/mysql/
[root@sqltest01 support-files]# pwd /usr/local/mysql/support-files [root@sqltest01 support-files]# ls -lrt total 32 -rw-r--r--. 1 mysql mysql 773 Oct 9 21:46 magic -rwxr-xr-x. 1 mysql mysql 10880 Oct 9 22:42 mysql.server -rwxr-xr-x. 1 mysql mysql 894 Oct 9 22:42 mysql-log-rotate -rwxr-xr-x. 1 mysql mysql 1061 Oct 9 22:42 mysqld_multi.server -rw-r--r--. 1 mysql mysql 1126 Oct 9 22:42 my-default.cnf -rwxr-xr-x. 1 mysql mysql 1153 Oct 9 22:42 binary-configure [root@sqltest01 support-files]# cp mysql.server /etc/rc.d/init.d/mysqld
[root@sqltest01 tmp]# vi /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
[root@sqltest01 tmp]# source /etc/profile
[root@sqltest01 support-files]# cp my-default.cnf /etc/my.cnf
[mysqld] ndbcluster basedir=/usr/local/mysql datadir=/u01/mysql/data port=3306 [mysql_cluster] ndb-connectstring=192.168.9.243
[root@sqltest01 mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/u01/mysql/data
[root@sqltest01 mysql]# ndbd --initial
2014-12-24 17:55:57 [ndbd] INFO -- Angel connected to '192.168.9.243:1186' 2014-12-24 17:55:57 [ndbd] INFO -- Angel allocated nodeid: 2
ndb_mgm> show
Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.9.241 (mysql-5.6.21 ndb-7.3.7, starting, Nodegroup: 0) --表明已经连接上了 id=3 (not connected, accepting connect from 192.168.9.242) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.9.243 (mysql-5.6.21 ndb-7.3.7) [mysqld(API)] 2 node(s) id=4 (not connected, accepting connect from 192.168.9.241) id=5 (not connected, accepting connect from 192.168.9.242)
[root@sqltest01 mysql]# cd /usr/local/mysql/bin [root@sqltest01 bin]# ./mysqld_safe --user=mysql
141224 17:59:50 mysqld_safe Logging to '/u01/mysql/data/sqltest01.err'. 141224 17:59:51 mysqld_safe Starting mysqld daemon with databases from /u01/mysql/data
ndb_mgm> show
Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.9.241 (mysql-5.6.21 ndb-7.3.7, Nodegroup: 0, *) id=3 (not connected, accepting connect from 192.168.9.242) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.9.243 (mysql-5.6.21 ndb-7.3.7) [mysqld(API)] 2 node(s) id=4 @192.168.9.241 (mysql-5.6.21 ndb-7.3.7)
ndb_mgm> show
Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.9.241 (mysql-5.6.21 ndb-7.3.7, Nodegroup: 0, *) id=3 @192.168.9.242 (mysql-5.6.21 ndb-7.3.7, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.9.243 (mysql-5.6.21 ndb-7.3.7) [mysqld(API)] 2 node(s) id=4 @192.168.9.241 (mysql-5.6.21 ndb-7.3.7) id=5 @192.168.9.242 (mysql-5.6.21 ndb-7.3.7)
[root@sqltest01 ~]# mysql -uroot -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.21-ndb-7.3.7-cluster-gpl MySQL Cluster Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database mydb1; Query OK, 1 row affected (0.07 sec) mysql> use mydb1; Database changed mysql> create table mytb1(id int,birthdate datetime,pername char(10)) engine=ndbcluster; Query OK, 0 rows affected (0.19 sec)
mysql> insert into mytb1(id,birthdate,pername) values(1,'2013-01-23 09:45:10','pengzitong');
Query OK, 1 row affected (0.00 sec) mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> insert into mytb1(id,birthdate,pername) values(2,'2007-07-09 09:45:10','pengzixin'); Query OK, 1 row affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
[root@sqltest02 ~]# mysql -uroot -p
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.21-ndb-7.3.7-cluster-gpl MySQL Cluster Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mydb1 mysql> select * from mytb1; +------+---------------------+------------+ | id | birthdate | pername | +------+---------------------+------------+ | 1 | 2013-01-23 09:45:10 | pengzitong | | 2 | 2007-07-09 09:45:10 | pengzixin | +------+---------------------+------------+
[root@sqltest03 bin]# /usr/local/mysql/ndb_mgm -e shutdown
[root@sqltest01 bin]# /usr/local/mysql/bin/mysqladmin -uroot shutdown
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有