MySQLCluster
是sharednothing分布式架构,ndb存储引擎把数据放置于内存中。可以做到无单点故障。由运行于不同服务器上的的多种进程构成,组件包括SQL节点,NDBD数据节点,管理程序,以及(可能的)数据访问程序。
表(结构)存在SQL节点中。应用程序通过SQL节点访问这些数据表;NDBD数据节点用于保存数据;集群管理通过管理工具ndb_mgmd管理。
MySQLCluster具有高可用性、高性能和可缩放性的Cluster数据管理。关于
Cluster中组件的关系可见下图:
mysql集群
安装
环境:
[[email protected] ~]# uname -a
Linux myqClter1 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
1
下载
mysql-cluster-gpl-7.3.7
http://dev.mysql.com/downloads
2
规划
mysql cluster 5个节点,装在两台机器上
192.168.55.15 做一个数据节点,SQL节点,管理节点
192.168.55.16 做一个数据节点,SQL节点,管理节点
3
查看已装包
[[email protected] ~]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[[email protected] ~]#
4
删除
[[email protected] ~]# yum -y remove mysql-libs-5.1.71-1.el6.x86_64
###################
#部署数据节点和sql节点
###################
5
创建用户和组
[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -r -g mysql mysql
[[email protected] ~]# id mysql
uid=495(mysql) gid=501(mysql) 组=501(mysql)
[[email protected] ~]#
6
解压mysql cluster包
[[email protected] mysql]# tar -zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
[[email protected] mysql]# du -h mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64
。。。
1.6G mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64
[[email protected] mysql]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll
总用量 168
drwxr-xr-x. 2 root root 4096 1月 22 17:47 bin
-rw-r--r--. 1 7161 wheel 17987 10月 9 21:46 COPYING
drwxr-xr-x. 3 root root 4096 1月 22 17:48 data
drwxr-xr-x. 2 root root 4096 1月 22 17:48 docs
drwxr-xr-x. 4 root root 4096 1月 22 17:48 include
-rw-r--r--. 1 7161 wheel 98601 10月 9 21:46 INSTALL-BINARY
drwxr-xr-x. 3 root root 4096 1月 22 17:48 lib
drwxr-xr-x. 4 root root 4096 1月 22 17:47 man
drwxr-xr-x. 10 root root 4096 1月 22 17:48 mysql-test
-rw-r--r--. 1 7161 wheel 2496 10月 9 21:46 README
drwxr-xr-x. 2 root root 4096 1月 22 17:48 scripts
drwxr-xr-x. 32 root root 4096 1月 22 17:47 share
drwxr-xr-x. 4 root root 4096 1月 22 17:48 sql-bench
drwxr-xr-x. 2 root root 4096 1月 22 17:48 support-files
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll bin/
总用量 904716
-rwxr-xr-x. 1 7161 wheel 4708823 10月 9 22:43 innochecksum
-rw-r--r--. 1 7161 wheel 1057 10月 9 22:42 mcc_config.py
-rwxr-xr-x. 1 7161 wheel 494953 10月 9 22:43 memcached
-rwxr-xr-x. 1 7161 wheel 26309 10月 9 22:42 memclient
-rwxr-xr-x. 1 7161 wheel 1551 10月 9 22:42 msql2mysql
-rwxr-xr-x. 1 7161 wheel 7134628 10月 9 22:44 myisamchk
-rwxr-xr-x. 1 7161 wheel 6724681 10月 9 22:44 myisam_ftdump
-rwxr-xr-x. 1 7161 wheel 6612085 10月 9 22:44 myisamlog
-rwxr-xr-x. 1 7161 wheel 6809636 10月 9 22:44 myisampack
-rwxr-xr-x. 1 7161 wheel 4648990 10月 9 22:43 my_print_defaults
-rwxr-xr-x. 1 7161 wheel 8993255 10月 9 22:45 mysql
-rwxr-xr-x. 1 7161 wheel 111803 10月 9 22:42 mysqlaccess
-rwxr-xr-x. 1 7161 wheel 1702 10月 9 22:42 mysqlaccess.conf
-rwxr-xr-x. 1 7161 wheel 8025589 10月 9 22:45 mysqladmin
-rwxr-xr-x. 1 7161 wheel 8817442 10月 9 22:45 mysqlbinlog
-rwxr-xr-x. 1 7161 wheel 11088 10月 9 22:42 mysqlbug
-rwxr-xr-x. 1 7161 wheel 8002737 10月 9 22:45 mysqlcheck
-rwxr-xr-x. 1 7161 wheel 9051624 10月 9 22:45 mysql_client_test
-rwxr-xr-x. 1 7161 wheel 87950310 10月 9 22:46 mysql_client_test_embedded
-rwxr-xr-x. 1 7161 wheel 6590 10月 9 22:42 mysql_config
-rwxr-xr-x. 1 7161 wheel 7228312 10月 9 22:45 mysql_config_editor
-rwxr-xr-x. 1 7161 wheel 4334 10月 9 22:42 mysql_convert_table_format
-rwxr-xr-x. 1 7161 wheel 93009946 10月 9 22:46 mysqld
-rwxr-xr-x. 1 7161 wheel 119414426 10月 9 22:42 mysqld-debug
-rwxr-xr-x. 1 7161 wheel 26543 10月 9 22:42 mysqld_multi
-rwxr-xr-x. 1 7161 wheel 24805 10月 9 22:42 mysqld_safe
-rwxr-xr-x. 1 7161 wheel 8238061 10月 9 22:45 mysqldump
-rwxr-xr-x. 1 7161 wheel 7424 10月 9 22:42 mysqldumpslow
-rwxr-xr-x. 1 7161 wheel 87770340 10月 9 22:46 mysql_embedded
-rwxr-xr-x. 1 7161 wheel 3409 10月 9 22:42 mysql_find_rows
-rwxr-xr-x. 1 7161 wheel 1366 10月 9 22:42 mysql_fix_extensions
-rwxr-xr-x. 1 7161 wheel 34938 10月 9 22:42 mysqlhotcopy
-rwxr-xr-x. 1 7161 wheel 8015676 10月 9 22:45 mysqlimport
-rwxr-xr-x. 1 7161 wheel 4693968 10月 9 22:45 mysql_plugin
-rwxr-xr-x. 1 7161 wheel 10106 10月 9 22:42 mysql_secure_installation
-rwxr-xr-x. 1 7161 wheel 17572 10月 9 22:42 mysql_setpermission
-rwxr-xr-x. 1 7161 wheel 7995210 10月 9 22:45 mysqlshow
-rwxr-xr-x. 1 7161 wheel 8073926 10月 9 22:45 mysqlslap
-rwxr-xr-x. 1 7161 wheel 8661547 10月 9 22:45 mysqltest
-rwxr-xr-x. 1 7161 wheel 87269558 10月 9 22:46 mysqltest_embedded
-rwxr-xr-x. 1 7161 wheel 4377547 10月 9 22:43 mysql_tzinfo_to_sql
-rwxr-xr-x. 1 7161 wheel 4866948 10月 9 22:45 mysql_upgrade
-rwxr-xr-x. 1 7161 wheel 4646218 10月 9 22:43 mysql_waitpid
-rwxr-xr-x. 1 7161 wheel 3976 10月 9 22:42 mysql_zap
-rwxr-xr-x. 1 7161 wheel 13662188 10月 9 22:45 ndb_blob_tool
-rwxr-xr-x. 1 7161 wheel 6374280 10月 9 22:45 ndb_config
-rwxr-xr-x. 1 7161 wheel 29088929 10月 9 22:44 ndbd
-rwxr-xr-x. 1 7161 wheel 13647826 10月 9 22:45 ndb_delete_all
-rwxr-xr-x. 1 7161 wheel 13658297 10月 9 22:45 ndb_desc
-rwxr-xr-x. 1 7161 wheel 13636648 10月 9 22:45 ndb_drop_index
-rwxr-xr-x. 1 7161 wheel 13636686 10月 9 22:45 ndb_drop_table
-rwxr-xr-x. 1 7161 wheel 6206 10月 9 22:42 ndb_error_reporter
-rwxr-xr-x. 1 7161 wheel 14095556 10月 9 22:45 ndb_index_stat
-rwxr-xr-x. 1 7161 wheel 14561221 10月 9 22:45 ndbinfo_select_all
-rwxr-xr-x. 1 7161 wheel 7131043 10月 9 22:44 ndb_mgm
-rwxr-xr-x. 1 7161 wheel 16141964 10月 9 22:45 ndb_mgmd
-rwxr-xr-x. 1 7161 wheel 13757424 10月 9 22:45 ndb_move_data
-rwxr-xr-x. 1 7161 wheel 29256388 10月 9 22:44 ndbmtd
-rwxr-xr-x. 1 7161 wheel 5137404 10月 9 22:44 ndb_print_backup_file
-rwxr-xr-x. 1 7161 wheel 4880055 10月 9 22:45 ndb_print_file
-rwxr-xr-x. 1 7161 wheel 4832691 10月 9 22:44 ndb_print_schema_file
-rwxr-xr-x. 1 7161 wheel 4819461 10月 9 22:44 ndb_print_sys_file
-rwxr-xr-x. 1 7161 wheel 4851417 10月 9 22:44 ndb_redo_log_reader
-rwxr-xr-x. 1 7161 wheel 15181678 10月 9 22:45 ndb_restore
-rwxr-xr-x. 1 7161 wheel 13711687 10月 9 22:45 ndb_select_all
-rwxr-xr-x. 1 7161 wheel 13647237 10月 9 22:45 ndb_select_count
-rwxr-xr-x. 1 7161 wheel 1802 10月 9 21:46 ndb_setup.py
-rwxr-xr-x. 1 7161 wheel 13635801 10月 9 22:45 ndb_show_tables
-rwxr-xr-x. 1 7161 wheel 43994 10月 9 21:46 ndb_size.pl
-rwxr-xr-x. 1 7161 wheel 5738946 10月 9 22:45 ndb_waiter
-rwxr-xr-x. 1 7161 wheel 4819020 10月 9 22:44 perror
-rwxr-xr-x. 1 7161 wheel 4497866 10月 9 22:43 replace
-rwxr-xr-x. 1 7161 wheel 4647922 10月 9 22:43 resolveip
-rwxr-xr-x. 1 7161 wheel 4655497 10月 9 22:43 resolve_stack_dump
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll data/
总用量 4
drwxr-xr-x. 2 root root 4096 1月 22 17:48 test
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll lib/
总用量 492108
-rw-r--r--. 1 7161 wheel 17288902 10月 9 22:45 libmysqlclient.a
lrwxrwxrwx. 1 7161 wheel 16 1月 22 17:47 libmysqlclient_r.a -> libmysqlclient.a
lrwxrwxrwx. 1 7161 wheel 17 1月 22 17:48 libmysqlclient_r.so -> libmysqlclient.so
lrwxrwxrwx. 1 7161 wheel 20 1月 22 17:48 libmysqlclient_r.so.18 -> libmysqlclient.so.18
lrwxrwxrwx. 1 7161 wheel 24 1月 22 17:48 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0
lrwxrwxrwx. 1 7161 wheel 20 1月 22 17:48 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx. 1 7161 wheel 24 1月 22 17:48 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x. 1 7161 wheel 8138299 10月 9 22:45 libmysqlclient.so.18.1.0
-rw-r--r--. 1 7161 wheel 235071862 10月 9 22:46 libmysqld.a
-rw-r--r--. 1 7161 wheel 177976584 10月 9 22:41 libmysqld-debug.a
-rw-r--r--. 1 7161 wheel 14846 10月 9 22:43 libmysqlservices.a
lrwxrwxrwx. 1 7161 wheel 21 1月 22 17:48 libndbclient.so -> libndbclient.so.6.0.0
-rwxr-xr-x. 1 7161 wheel 19349092 10月 9 22:45 libndbclient.so.6.0.0
-rw-r--r--. 1 7161 wheel 29310630 10月 9 22:45 libndbclient_static.a
-rw-r--r--. 1 7161 wheel 754332 10月 9 22:38 libtcmalloc_minimal.so
-rwxr-xr-x. 1 7161 wheel 15990948 10月 9 22:45 ndb_engine.so
drwxr-xr-x. 3 root root 4096 1月 22 17:48 plugin
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll man/
总用量 8
drwxr-xr-x. 2 root root 4096 1月 22 17:47 man1
drwxr-xr-x. 2 root root 4096 1月 22 17:47 man8
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll mysql-test/
总用量 392
drwxr-xr-x. 2 root root 4096 1月 22 17:48 collections
drwxr-xr-x. 4 root root 4096 1月 22 17:48 extra
drwxr-xr-x. 2 root root 20480 1月 22 17:48 include
drwxr-xr-x. 4 root root 4096 1月 22 17:48 lib
lrwxrwxrwx. 1 7161 wheel 19 1月 22 17:48 mtr -> ./mysql-test-run.pl
-rwxr-xr-x. 1 7161 wheel 36862 10月 9 21:46 mysql-stress-test.pl
lrwxrwxrwx. 1 7161 wheel 19 1月 22 17:48 mysql-test-run -> ./mysql-test-run.pl
-rwxr-xr-x. 1 7161 wheel 197168 10月 9 21:46 mysql-test-run.pl
-rw-r--r--. 1 7161 wheel 1481 10月 9 21:46 purify.supp
drwxr-xr-x. 2 root root 40960 1月 22 17:48 r
-rw-r--r--. 1 7161 wheel 2813 10月 9 21:46 README
-rw-r--r--. 1 7161 wheel 655 10月 9 21:46 README.gcov
-rw-r--r--. 1 7161 wheel 4600 10月 9 21:46 README.stress
drwxr-xr-x. 5 root root 4096 1月 22 17:48 std_data
drwxr-xr-x. 27 root root 4096 1月 22 17:48 suite
drwxr-xr-x. 2 root root 40960 1月 22 17:48 t
-rw-r--r--. 1 7161 wheel 17965 10月 9 21:46 valgrind.supp
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll scripts/
总用量 36
-rwxr-xr-x. 1 7161 wheel 34544 10月 9 22:42 mysql_install_db
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll share/
总用量 1516
drwxr-xr-x. 2 root root 4096 1月 22 17:47 aclocal
drwxr-xr-x. 2 root root 4096 1月 22 17:47 bulgarian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 charsets
drwxr-xr-x. 2 root root 4096 1月 22 17:47 czech
drwxr-xr-x. 2 root root 4096 1月 22 17:47 danish
-rw-r--r--. 1 7161 wheel 25575 10月 9 21:46 dictionary.txt
drwxr-xr-x. 2 root root 4096 1月 22 17:47 dutch
drwxr-xr-x. 2 root root 4096 1月 22 17:47 english
-rw-r--r--. 1 7161 wheel 505241 10月 9 21:46 errmsg-utf8.txt
drwxr-xr-x. 2 root root 4096 1月 22 17:47 estonian
-rw-r--r--. 1 7161 wheel 739146 10月 9 21:46 fill_help_tables.sql
drwxr-xr-x. 2 root root 4096 1月 22 17:47 french
drwxr-xr-x. 2 root root 4096 1月 22 17:47 german
drwxr-xr-x. 2 root root 4096 1月 22 17:47 greek
drwxr-xr-x. 2 root root 4096 1月 22 17:47 hungarian
-rw-r--r--. 1 7161 wheel 3963 10月 9 21:46 innodb_memcached_config.sql
drwxr-xr-x. 2 root root 4096 1月 22 17:47 italian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 japanese
drwxr-xr-x. 2 root root 4096 1月 22 17:47 java
drwxr-xr-x. 2 root root 4096 1月 22 17:47 korean
drwxr-xr-x. 5 root root 4096 1月 22 17:47 mcc
drwxr-xr-x. 3 root root 4096 1月 22 17:47 memcache-api
-rw-r--r--. 1 7161 wheel 1695 10月 9 21:46 mysql_security_commands.sql
-rw-r--r--. 1 7161 wheel 3464 10月 9 21:46 mysql_system_tables_data.sql
-rw-r--r--. 1 7161 wheel 111746 10月 9 21:46 mysql_system_tables.sql
-rw-r--r--. 1 7161 wheel 10410 10月 9 21:46 mysql_test_data_timezone.sql
-rw-r--r--. 1 7161 wheel 10958 10月 9 21:46 ndb_dist_priv.sql
drwxr-xr-x. 9 root root 4096 1月 22 17:47 nodejs
drwxr-xr-x. 2 root root 4096 1月 22 17:47 norwegian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 norwegian-ny
drwxr-xr-x. 2 root root 4096 1月 22 17:47 polish
drwxr-xr-x. 2 root root 4096 1月 22 17:47 portuguese
drwxr-xr-x. 2 root root 4096 1月 22 17:47 romanian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 russian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 serbian
drwxr-xr-x. 2 root root 4096 1月 22 17:47 slovak
drwxr-xr-x. 2 root root 4096 1月 22 17:47 spanish
drwxr-xr-x. 2 root root 4096 1月 22 17:47 swedish
drwxr-xr-x. 2 root root 4096 1月 22 17:47 ukrainian
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll sql-bench/
总用量 544
-rwxr-xr-x. 1 7161 wheel 7366 10月 9 22:42 bench-count-distinct
-rwxr-xr-x. 1 7161 wheel 15829 10月 9 22:42 bench-init.pl
-rwxr-xr-x. 1 7161 wheel 16212 10月 9 22:42 compare-results
-rwxr-xr-x. 1 7161 wheel 9821 10月 9 22:42 copy-db
-rwxr-xr-x. 1 7161 wheel 159022 10月 9 22:42 crash-me
drwxr-xr-x. 4 root root 4096 1月 22 17:48 Data
-rwxr-xr-x. 1 7161 wheel 22131 10月 9 22:42 graph-compare-results
-rwxr-xr-x. 1 7161 wheel 4825 10月 9 22:42 innotest1
-rwxr-xr-x. 1 7161 wheel 3893 10月 9 22:42 innotest1a
-rwxr-xr-x. 1 7161 wheel 3461 10月 9 22:42 innotest1b
-rwxr-xr-x. 1 7161 wheel 5064 10月 9 22:42 innotest2
-rwxr-xr-x. 1 7161 wheel 2793 10月 9 22:42 innotest2a
-rwxr-xr-x. 1 7161 wheel 3130 10月 9 22:42 innotest2b
drwxr-xr-x. 2 root root 4096 1月 22 17:48 limits
-rw-r--r--. 1 7161 wheel 4163 10月 9 22:42 README
-rwxr-xr-x. 1 7161 wheel 7258 10月 9 22:42 run-all-tests
-rwxr-xr-x. 1 7161 wheel 105307 10月 9 22:42 server-cfg
-rwxr-xr-x. 1 7161 wheel 6049 10月 9 22:42 test-alter-table
-rwxr-xr-x. 1 7161 wheel 25034 10月 9 22:42 test-ATIS
-rwxr-xr-x. 1 7161 wheel 4447 10月 9 22:42 test-big-tables
-rwxr-xr-x. 1 7161 wheel 9804 10月 9 22:42 test-connect
-rwxr-xr-x. 1 7161 wheel 7038 10月 9 22:42 test-create
-rwxr-xr-x. 1 7161 wheel 50677 10月 9 22:42 test-insert
-rwxr-xr-x. 1 7161 wheel 13830 10月 9 22:42 test-select
-rwxr-xr-x. 1 7161 wheel 7153 10月 9 22:42 test-transactions
-rwxr-xr-x. 1 7161 wheel 12028 10月 9 22:42 test-wisconsin
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]# ll support-files/
总用量 32
-rwxr-xr-x. 1 7161 wheel 1153 10月 9 22:42 binary-configure
-rw-r--r--. 1 7161 wheel 773 10月 9 21:46 magic
-rw-r--r--. 1 7161 wheel 1126 10月 9 22:42 my-default.cnf
-rwxr-xr-x. 1 7161 wheel 1061 10月 9 22:42 mysqld_multi.server
-rwxr-xr-x. 1 7161 wheel 894 10月 9 22:42 mysql-log-rotate
-rwxr-xr-x. 1 7161 wheel 10880 10月 9 22:42 mysql.server
[[email protected] mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64]#
7
解压的是已经编译好的, 直接放到/usr/local/mysql,修改相关属主属组
luster-gpl-7.3.7-linux-glibc2.5-x86_64]# mv mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
luster-gpl-7.3.7-linux-glibc2.5-x86_64]# cd /usr/local/mysql
[[email protected] mysql]# chown -R root:mysql .
[[email protected] mysql]# chown -R mysql data/
8
创建MySQL Server系统表
[[email protected] mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2015-01-22 20:39:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-22 20:39:48 3032 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-22 20:39:48 3032 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-22 20:39:48 3032 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-22 20:39:48 3032 [Note] InnoDB: Memory barrier is not used
2015-01-22 20:39:48 3032 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-22 20:39:48 3032 [Note] InnoDB: Using Linux native AIO
2015-01-22 20:39:48 3032 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-22 20:39:48 3032 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-22 20:39:48 3032 [Note] InnoDB: Completed initialization of buffer pool
2015-01-22 20:39:48 3032 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-01-22 20:39:48 3032 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-01-22 20:39:48 3032 [Note] InnoDB: Database physically writes the file full: wait...
2015-01-22 20:39:49 3032 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-01-22 20:39:49 3032 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-01-22 20:39:49 3032 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-01-22 20:39:49 3032 [Warning] InnoDB: New log files created, LSN=45781
2015-01-22 20:39:49 3032 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-01-22 20:39:49 3032 [Note] InnoDB: Doublewrite buffer created
2015-01-22 20:39:49 3032 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-22 20:39:49 3032 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-01-22 20:39:49 3032 [Note] InnoDB: Foreign key constraint system tables created
2015-01-22 20:39:49 3032 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-01-22 20:39:49 3032 [Note] InnoDB: Tablespace and datafile system tables created.
2015-01-22 20:39:49 3032 [Note] InnoDB: Waiting for purge to start
2015-01-22 20:39:49 3032 [Note] InnoDB: 5.6.21 started; log sequence number 0
2015-01-22 20:39:51 3032 [Note] Binlog end
2015-01-22 20:39:51 3032 [Note] InnoDB: FTS optimize thread exiting.
2015-01-22 20:39:51 3032 [Note] InnoDB: Starting shutdown...
2015-01-22 20:39:52 3032 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2015-01-22 20:39:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-22 20:39:52 3054 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-22 20:39:52 3054 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-22 20:39:52 3054 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-22 20:39:52 3054 [Note] InnoDB: Memory barrier is not used
2015-01-22 20:39:52 3054 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-22 20:39:52 3054 [Note] InnoDB: Using Linux native AIO
2015-01-22 20:39:52 3054 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-22 20:39:52 3054 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-22 20:39:52 3054 [Note] InnoDB: Completed initialization of buffer pool
2015-01-22 20:39:52 3054 [Note] InnoDB: Highest supported file format is Barracuda.
2015-01-22 20:39:52 3054 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-22 20:39:52 3054 [Note] InnoDB: Waiting for purge to start
2015-01-22 20:39:52 3054 [Note] InnoDB: 5.6.21 started; log sequence number 1625977
2015-01-22 20:39:53 3054 [Note] Binlog end
2015-01-22 20:39:53 3054 [Note] InnoDB: FTS optimize thread exiting.
2015-01-22 20:39:53 3054 [Note] InnoDB: Starting shutdown...
2015-01-22 20:39:54 3054 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password ‘new-password‘
./bin/mysqladmin -u root -h myqClter1 password ‘new-password‘
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[[email protected] mysql]#
9
配置启动脚本
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
# 设置mysql服务为开机自启动
# chkconfig --add mysqld
#################
#以上第3-9步部署数据节点和SQL节点,根据规划在另一台服务器做同样操作
#################
#################
# 部署管理节点
#################
管理节点只需ndb_mgm和ndb_mgmd两个文件和一个配置文件,这两个文件从数据节点上copy就行。
ndb_mgmd是 mysql cluster管理服务器,ndb_mgm是客户端管理工具
10
[[email protected] mysql]# ll bin/ndb_mgm
ndb_mgm ndb_mgmd
[[email protected] mysql]# cp mysql/bin/ndb_mgm*/usr/local/bin
[[email protected] mysql]# ll /usr/local/bin/ndb_mgm*
-rwxr-xr-x. 1 root root 7131043 1月 22 21:25 /usr/local/bin/ndb_mgm
-rwxr-xr-x. 1 root root 16141964 1月 22 21:25 /usr/local/bin/ndb_mgmd
#################
# 配置
#################
11
配置mysql服务器成数据节点和SQL节点
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]# vi /etc/my.cnf
增加如下内容
[mysqld]
ndbcluster #运行NDB存储引擎
[mysql_cluster]
ndb-connectstring=192.168.55.15 #管理节点IP
另一个节点上同样操作
#scp /etc/my.cnf 192.168.55.16:/etc/
注意两台服务器都得这样配置。
12
配置管理节点
[[email protected] mysql]# mkdir /var/lib/mysql-cluster
[[email protected] mysql]# vi /var/lib/mysql-cluster/config.ini
加入以下内容:
[ndbd default]
NoOfReplicas=2 #每个数据节点的镜像数量
DataMemory=200M #每个数据节点中给数据分配的内存
IndexMemory=20M #每个数据节点中给索引分配的内存
[tcp default]
portnumber=2202
[ndb_mgmd] #配置管理节点
#NodeId=1
hostname=192.168.55.15
datadir=/var/lib/mysql-cluster/ #管理节点 日志目录
[ndbd]
#数据节点配置,一个数据节点一个[ndbd]
#NodeId=2
hostname=192.168.55.15
datadir=/usr/local/mysql/data/ #数据节点目录
[ndbd]
#NodeId=3
hostname=192.168.55.16
datadir=/usr/local/mysql/data/
[mysqld]
#SQL节点配置
hostname=192.168.55.15
[mysqld]
hostname=192.168.55.16
13
启动:
启动顺序:
管理节点->数据节点->SQL节点
启动管理节点:
[[email protected] bin]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.6.21 ndb-7.3.7
[[email protected] bin]#
启动数据节点
[[email protected] bin]# ./ndbd --initial
2015-01-23 15:31:15 [ndbd] INFO -- Angel connected to ‘192.168.55.15:1186‘
2015-01-23 15:31:15 [ndbd] INFO -- Angel allocated nodeid: 2
[[email protected] bin]#
启动第二个数据节点
[[email protected] bin]# ./ndbd --initial
Unable to connect with connect string: nodeid=0,192.168.55.15:1186
Retrying every 5 seconds. Attempts left: 12 11 10 9 8 7 6 5 4 3 2 1, failed.
2015-01-23 15:35:50 [ndbd] ERROR -- Could not connect to management server, error: ‘‘
[[email protected] bin]#
修改防火墙,放开1186端口
[[email protected] bin]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1186 -j ACCEPT
[[email protected] bin]#
[[email protected] bin]# ./ndbd --initial
2015-01-23 15:36:34 [ndbd] INFO -- Angel connected to ‘192.168.55.15:1186‘
2015-01-23 15:36:34 [ndbd] INFO -- Angel allocated nodeid: 3
[[email protected] bin]#
启动sql节点
[[email protected] bin]# ps -ef | grep mysql
root 3749 1 2 15:25 ? 00:00:33 ndb_mgmd -f /var/lib/mysql-cluster/config.ini
root 3920 3629 0 15:44 pts/1 00:00:00 grep mysql
[[email protected] bin]#
[[email protected] bin]# /etc/init.d/mysqld status
ERROR! MySQL is not running
[[email protected] bin]# /etc/init.d/mysqld start
Starting MySQL.......................................... SUCCESS!
[[email protected] bin]#
[[email protected] bin]# ps -ef | grep mysql
root 3749 1 2 15:25 ? 00:00:37 ndb_mgmd -f /var/lib/mysql-cluster/config.ini
root 3935 1 0 15:44 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/myqClter1.pid
mysql 4062 3935 1 15:44 pts/1 00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/myqClter1.err --pid-file=/usr/local/mysql/data/myqClter1.pid
root 4176 3629 0 15:46 pts/1 00:00:00 grep mysql
[[email protected] bin]#
14
客户端管理使用/usr/local/bin/ndb_mgm
[[email protected] bin]# ls
ndb_mgm ndb_mgmd
[[email protected] bin]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> help
---------------------------------------------------------------------------
NDB Cluster -- Management Client -- Help
---------------------------------------------------------------------------
HELP Print help text
HELP COMMAND Print detailed help for COMMAND(e.g. SHOW)
SHOW Print information about cluster
CREATE NODEGROUP <id>,<id>... Add a Nodegroup containing nodes
DROP NODEGROUP <NG> Drop nodegroup with id NG
START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [<backup id>] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [<backup id>] [SNAPSHOTSTART | SNAPSHOTEND] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
Start backup (default WAIT COMPLETED,SNAPSHOTEND)
ABORT BACKUP <backup id> Abort backup
SHUTDOWN Shutdown all processes in cluster
CLUSTERLOG ON [<severity>] ... Enable Cluster logging
CLUSTERLOG OFF [<severity>] ... Disable Cluster logging
CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off
CLUSTERLOG INFO Print cluster log information
<id> START Start data node (started with -n)
<id> RESTART [-n] [-i] [-a] [-f] Restart data or management server node
<id> STOP [-a] [-f] Stop data or management server node
ENTER SINGLE USER MODE <id> Enter single user mode
EXIT SINGLE USER MODE Exit single user mode
<id> STATUS Print status
<id> CLUSTERLOG {<category>=<level>}+ Set log level for cluster log
PURGE STALE SESSIONS Reset reserved nodeid‘s in the mgmt server
CONNECT [<connectstring>] Connect to management server (reconnect if already connected)
<id> REPORT <report-type> Display report for <report-type>
QUIT Quit management client
<severity> = ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG
<category> = STARTUP | SHUTDOWN | STATISTICS | CHECKPOINT | NODERESTART | CONNECTION | INFO | ERROR | CONGESTION | DEBUG | BACKUP | SCHEMA
<report-type> = BACKUPSTATUS | MEMORYUSAGE | EVENTLOG
<level> = 0 - 15
<id> = ALL | Any database node id
For detailed help on COMMAND, use HELP COMMAND.
ndb_mgm> show
Connected to Management Server at: 192.168.55.15:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.55.15 (mysql-5.6.21 ndb-7.3.7, starting, Nodegroup: 0)
id=3 @192.168.55.16 (mysql-5.6.21 ndb-7.3.7, starting, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.55.15 (mysql-5.6.21 ndb-7.3.7)
[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from 192.168.55.15)
id=5 (not connected, accepting connect from 192.168.55.16)
ndb_mgm>
#退出管理工具
ndb_mgm> quit
[[email protected] bin]#
15
简单测试:
使用mysql cluster中需要注意两点:
一是表必须用ENGINE=NDB或ENGINE=NDBCLUSTER选项创建,使用ALTER TABLE选项更改也可以,以使用NDB Cluster存储引擎在 Cluster内复制它们。
二是每个NDB表必须要有一个主键,如果没有,NDB Cluster存储引擎将自动生成隐含主键。
连到sql节点1上,创建ndb引擎数据表beigang,插入数据,连到sql节点2上,查看beigang表数据,再插入数据,连到sql节点1查看,没问题就OK了。
连接sql节点1,创建下表并插入数据:
[[email protected] bin]# ./mysql -h 192.168.55.15 -p test
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndb_2_fs |
| ndbinfo |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> use test;
Database changed
mysql> create table beigang(
-> id int not null auto_increment primary key,
-> name varchar(30) not null default ‘‘
-> )engine = ndbcluster default charset utf8;
Query OK, 0 rows affected (0.21 sec)
mysql>
mysql> insert into beigang values(1, ‘ndb t1‘);
Query OK, 1 row affected (0.14 sec)
mysql> insert into beigang values(2, ‘ndb t2‘);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> select * from beigang;
+----+--------+
| id | name |
+----+--------+
| 1 | ndb t1 |
| 2 | ndb t2 |
+----+--------+
2 rows in set (0.13 sec)
mysql> \q
Bye
[[email protected] bin]#
连到sql节点2上,查看beigang表数据,再插入数据:
[[email protected] bin]# ./mysql -h 192.168.55.16 -p test
Enter password:
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
mysql> select * from beigang;
+----+--------+
| id | name |
+----+--------+
| 1 | ndb t1 |
| 2 | ndb t2 |
+----+--------+
2 rows in set (0.10 sec)
mysql> insert into beigang values(3, ‘ndb t3‘);
Query OK, 1 row affected (0.09 sec)
mysql> \q
Bye
[[email protected] bin]#
连到sql节点1查看,没问题就OK了。
[[email protected] bin]# ./mysql -h 192.168.55.15 -p test
Enter password:
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
mysql>
mysql>
mysql> select * from beigang;
+----+--------+
| id | name |
+----+--------+
| 3 | ndb t3 |
| 1 | ndb t1 |
| 2 | ndb t2 |
+----+--------+
3 rows in set (0.00 sec)
mysql> \q
Bye
16
关闭顺序应该是:
管理节点->数据节点->SQL节点
命令ndb_mgm -e shutdown关闭管理节点和数据节点,sql节点/etc/init.d/mysqld stop关就可以了
[[email protected] bin]# ndb_mgm -e shutdown
Connected to Management Server at: 192.168.55.15:1186
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
[[email protected] bin]#
[[email protected] bin]# /etc/init.d/mysqld stop
Shutting down MySQL..... SUCCESS!
[[email protected] bin]#
[[email protected] bin]# /etc/init.d/mysqld stop
Shutting down MySQL..... SUCCESS!
附:
ndb_mgmd和ndb_mgm的命令行参数:
[[email protected] bin]# ll
总用量 22728
-rwxr-xr-x. 1 root root 7131043 1月 22 21:25 ndb_mgm
-rwxr-xr-x. 1 root root 16141964 1月 22 21:25 ndb_mgmd
[[email protected] bin]# ndb_mgmd --help
MySQL Cluster Management Server mysql-5.6.21 ndb-7.3.7
Usage: ndb_mgmd [OPTIONS]
MySQL distrib mysql-5.6.21 ndb-7.3.7, for linux-glibc2.5 (x86_64)
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysql_cluster ndb_mgmd
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don‘t read default options from any option file,
except for login file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
Also read groups with concat(group, suffix)
--login-path=# Read this path from the login file.
-?, --usage Display this help and exit.
-?, --help Display this help and exit.
-V, --version Output version information and exit.
-c, --ndb-connectstring=name
Set connect string for connecting to ndb_mgmd. Syntax:
"[nodeid=<id>;][host=]<hostname>[:<port>]". Overrides
specifying entries in NDB_CONNECTSTRING and my.cnf
--ndb-mgmd-host=name
same as --ndb-connectstring
--ndb-nodeid=# Set node id for this node. Overrides node id specified in
--ndb-connectstring.
--ndb-optimized-node-selection
Select nodes for transactions in a more optimal way
(Defaults to on; use --skip-ndb-optimized-node-selection to disable.)
-c, --connect-string=name
same as --ndb-connectstring
--core-file Write core on errors.
--character-sets-dir=name
Directory where character sets are.
-f, --config-file=name
Specify cluster configuration file
-P, --print-full-config
Print full config and exit
-d, --daemon Run ndb_mgmd in daemon mode (default)
(Defaults to on; use --skip-daemon to disable.)
--interactive Run interactive. Not supported but provided for testing
purposes
--no-nodeid-checks Do not provide any node id checks
--nodaemon Don‘t run as daemon, but don‘t read from stdin
--mycnf Read cluster config from my.cnf
--bind-address=name Local bind address
--configdir=name Directory for the binary configuration files (alias for
--config-dir)
--config-dir=name Directory for the binary configuration files
--config-cache Enable configuration cache and change management
(Defaults to on; use --skip-config-cache to disable.)
-v, --verbose Write more log messages
--reload Reload config from config.ini or my.cnf if it has changed
on startup
--initial Delete all binary config files and start from config.ini
or my.cnf
--log-name=name Name to use when logging messages for this node
--nowait-nodes=name Nodes that will not be waited for during start
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
ndb-connectstring 192.168.55.15
ndb-mgmd-host 192.168.55.15
ndb-nodeid 0
ndb-optimized-node-selection TRUE
connect-string 192.168.55.15
core-file FALSE
character-sets-dir (No default value)
config-file (No default value)
print-full-config FALSE
daemon TRUE
interactive FALSE
no-nodeid-checks FALSE
nodaemon FALSE
mycnf FALSE
bind-address (No default value)
configdir /usr/local/mysql/mysql-cluster
config-dir /usr/local/mysql/mysql-cluster
config-cache TRUE
verbose FALSE
reload FALSE
initial FALSE
log-name MgmtSrvr
nowait-nodes (No default value)
[[email protected] bin]#
[[email protected] bin]# ndb_mgmd -e shutdown
MySQL Cluster Management Server mysql-5.6.21 ndb-7.3.7
ndb_mgmd: unknown option ‘-e‘
[[email protected] bin]#
[[email protected] bin]#
[[email protected] bin]# ndb_mgm --help
Usage: ndb_mgm [OPTIONS] [hostname [port]]
MySQL distrib mysql-5.6.21 ndb-7.3.7, for linux-glibc2.5 (x86_64)
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysql_cluster ndb_mgm
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don‘t read default options from any option file,
except for login file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
Also read groups with concat(group, suffix)
--login-path=# Read this path from the login file.
-?, --usage Display this help and exit.
-?, --help Display this help and exit.
-V, --version Output version information and exit.
-c, --ndb-connectstring=name
Set connect string for connecting to ndb_mgmd. Syntax:
"[nodeid=<id>;][host=]<hostname>[:<port>]". Overrides
specifying entries in NDB_CONNECTSTRING and my.cnf
--ndb-mgmd-host=name
same as --ndb-connectstring
--ndb-nodeid=# Set node id for this node. Overrides node id specified in
--ndb-connectstring.
--ndb-optimized-node-selection
Select nodes for transactions in a more optimal way
(Defaults to on; use --skip-ndb-optimized-node-selection to disable.)
-c, --connect-string=name
same as --ndb-connectstring
--core-file Write core on errors.
--character-sets-dir=name
Directory where character sets are.
-e, --execute=name execute command and exit
-t, --try-reconnect=#
Specify number of tries for connecting to ndb_mgmd (0 =
infinite)
-v, --verbose=# Control the amount of printout
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
ndb-connectstring 192.168.55.15
ndb-mgmd-host 192.168.55.15
ndb-nodeid 0
ndb-optimized-node-selection TRUE
connect-string 192.168.55.15
core-file FALSE
character-sets-dir (No default value)
execute (No default value)
try-reconnect 3
verbose 1
[[email protected] bin]#
[[email protected] bin]#
[[email protected] bin]#
[[email protected] bin]#
[[email protected] bin]# ndb_mgm -e shutdown
Connected to Management Server at: 192.168.55.15:1186
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
[[email protected] bin]#
engine=ndbcluster或者engine=ndb的表才能使用Data node所存储。其他engine即放在SQL node本地,就像单机版一样。
这东西用着如何就根据实际场景测吧,其相关的bug可以到http://bugs.mysql.com/search.php查看
参考:
Chapter 18 MySQL Cluster NDB 7.3 and MySQL Cluster NDB 7.4
http://dev.mysql.com/doc/refman/5.6/en/mysql-cluster.html
-----------------
转载请著明出处:
blog.csdn.net/beiigang