Cluster environment
Management node 10.0.0.19 data node 10.0.0.12 10.0.0.17sql node 10.0.0.18 10.0.0.22
Add MySQL User
Groupadd mysqluseradd mysql-g MySQL
Installing mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64.tar.gz
CD/HOME/TESTTAR-ZXVF mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64.tar.gz-c/USR/LOCALMV mysql-cluster-gpl-7.3.5-linux-glibc2.5-x86_64/ MYSQLCD. /chown-r mysql:mysql mysql/ cd mysql./scripts/mysql_install_db--user=mysql This step all servers need to be executed (5 units)
Cluster Configuration Management node
VIM/USR/LOCAL/MYSQL/CONFIG.INI#LIZHENGHUA[NDBD Default] noofreplicas=1 [NDB_MGMD] hostname= 192.168.145.138datadir=/usr/local/mysql/data [ndbd]hostname=192.168.145.140datadir=/usr/local/mysql/data[ MYSQLD] hostname=192.168.145.141 [MYSQLD] [MYSQLD] #博客园 [ndbd DEFAULT] noofreplicas=2 [TCP DEFAULT] portnumber=3306 [NDB_MGMD] #设置管理节点服务器 nodeid=1 hostname=10.0.0.19 Datadir=/var/mysql/data [ndbd] id=2 hostname=10.0.0.12 datadir=/var/mysql/data [NDBD] id=3 hostname=10.0.0.17 datadir=/var/mysql/data [MYSQLD] id=4 hostname=10.0.0.18 [MYSQLD] id=5 hostname=10.0.0.22 #必须有空的mysqld节点, otherwise the data node was disconnected and started with an error [MYSQLD] id=6 [MYSQLD] id=7
Start the Management node
Ndb_mgmd-f/usr/local/mysql/config.ini
Close the Management node
[[email protected] bin] #ndb_mgm ndb_mgm> shutdowm
Note:
The NDB_MGMD on the command line is the Management Server for MySQL cluster, followed by-F to indicate that the parameter that follows is the parameter configuration file that is started.
If you have added a data node A few days after startup, you must add the--initial parameter when you modify the configuration file, otherwise the added node will not function in MySQL cluster.
Ndb_mgmd-f/usr/local/mysql/config.ini--initial
Managing node State
Ndb_mgm> Show to view the individual node conditions. ndb_mgm> All report memory View data node usage ndb_mgm>create nodegroup 3; Create data node groupings mysql> alter online Table Data_house Reorganize partition; Adjust partition data
Data node
VIM/ETC/MY.CNF (Add the following content)
#lizhenghua [mysqld]basedir=/usr/local/mysqldatadir=/usr/local/mysql/datandbclusterndb-connectstring= 192.168.145.138[MYSQL_CLUSTER]NDB-CONNECTSTRING=192.168.145.138[NDB_MGM] connect-string=192.168.145.138[ Mysqld_safe] log-error=/usr/local/mysql/log/mysqld.log pid-file=/usr/local/mysql/mysqld.pid #博客园 [mysqld ] datadir=/var/mysql/data socket=/var/mysql/mysql.sock user=mysql # disabling Symbolic-links is Recommended to prevent assorted security risks symbolic-links=0 #运行NDB存储引擎 ndbcluster #指定管理节点 ndb-connectstring=10.0.0.19 [Mysql_cluster] ndb-connectstring=10.0.0.19 [NDB_MGM] connect-string=10.0.0.19 [Mysqld_safe] log-error=/ Var/mysql/log/mysqld.log Pid-file=/var/run/mysqld/mysqld.pid
Note: The first time you start the data node after installation to add the--initial parameter, other times do not add, unless the backup, recovery or configuration changes after the restart of the SQL node
cd/usr/local/mysql/ cp support-files/mysql.server/etc/rc.d/init.d/mysqld chmod +x/etc/rc.d/init.d/mysqld chkconfig--add mysqld
VIM/ETC/MY.CNF (Add the following content)
#lizhenghua [Mysqld]ndbclusterndb-connectstring=192.168.145.138explicit_defaults_for_timestamp=truelower_case_ Table_names=1pid-file =/usr/local/mysql/data/mysql3306.pidlog-error =/usr/local/mysql/data/mysql3306.err ba Sedir =/usr/local/mysqldatadir =/usr/local/mysql/dataskip-host-cacheskip-name-resolvemax_connections = 5 12log-bin=mysql-bin#log =/usr/local/mysql/binlog/binlog.log[mysql_cluster]ndb-connectstring=192.168.145.138# Blog Park [MYSQLD] server-id=4# the ID of each server is different datadir=/var/mysql/data socket=/var/mysql/mysql.sock User=mysql # Disabling symbolic -links is recommended to prevent assorted security risks symbolic-links=0 Log-bin =/var/mysql/log/mysql-bin.log Max_co nnections=1000 #以下为mysql main main mode config file # ignores MySQL database replication Binlog-ignore-db=mysql # 2 auto-increment-increment = 2 # per increment set The offset of the automatically growing field, that is, the initial value is 2 Auto-increment-offset = 1 [mysqld_safe] Log-error=/var/mysql/log/mysqld.log Pid-file=/var/run/mys Qld/mysqld.pid [mysqld] Ndbcluster Ndb-connectstring=10.0.0.19 [Mysql_cluster] ndb-connectstring=10.0.0.19 [NDB_MGM] connect-string=10.0.0.19
Service mysqld Start
Mysql-cluster 7.3.5 Installation Deployment