phys-schost-1:/ # groupadd -g 200 dba phys-schost-2:/ # groupadd -g 200 dba phys-schost-1:/ # useradd -u 1000 -g dba -d /export/mysql -s /usr/bin/bash mysql phys-schost-2:/ # useradd -u 1000 -g dba -d /export/mysql -s /usr/bin/bash mysql
phys-schost-1:/ # mkdir /usr/local phys-schost-2:/ # mkdir /usr/local phys-schost-1:/ # cd /usr/local phys-schost-2:/ # cd /usr/local phys-schost-1:/usr/local # /usr/sfw/bin/gtar xzf /temp/mysql-7.0.7-solaris10-sparc.tar.gz phys-schost-2:/usr/local # /usr/sfw/bin/gtar xzf /temp/mysql-7.0.7-solaris10-sparc.tar.gz phys-schost-1:/usr/local # ln -s ./mysql-7.0.7-solaris10-sparc ./mysql phys-schost-2:/usr/local # ln -s ./mysql-7.0.7-solaris10-sparc ./mysql
phys-schost-1:/usr/local # chown -RL mysql:dba ./mysql phys-schost-2:/usr/local # chown -RL mysql:dba ./mysql
This section contains the following example procedures:
phys-schost-1:/ # mkdir /mgm-data phys-schost-2:/ # mkdir /mgm-data
phys-schost-1:/ # cp /temp/cluconfig/config.ini /mgm-data phys-schost-2:/ # cp /temp/cluconfig/config.ini /mgm-data
Alternatively, copy the content from config.ini File for Both Nodes to Store in /mgm-data and overwrite the copied file.
The configuration in the config.ini file for this example is shown in the following table:
|
Create aliases in the /etc/hosts table for the clprivnet addresses and use them in the config.ini file as the host names.
phys-schost-1:/ # cluster set -p heartbeat_quantum=500 -p heartbeat_timeout=5000
phys-schost-1:/ # cd /mgm-data phys-schost-2:/ # cd /mgm-data phys-schost-1:/mgm-data # /usr/local/mysql/bin/ndb_mgmd \ --configdir=/mgm-data -f /mgm-data/config.ini \ --ndb-nodeid=1 phys-schost-2:/mgm-data # /usr/local/mysql/bin/ndb_mgmd \ --configdir=/mgm-data -f /mgm-data/config.ini \ --ndb-nodeid=2
Run the ndb_mgm show command on both nodes until the data nodes are connected to the management server.
phys-schost-1:/mgm-data # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e show phys-schost-2:/mgm-data # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-2-p,phys-schost-1-p -e show
phys-schost-1:/ # mkdir /ndbd-data phys-schost-2:/ # mkdir /ndbd-data
phys-schost-1:/ # cp /temp/cluconfig/my.cnf_ndbd /ndbd-data/my.cnf phys-schost-2:/ # cp /temp/cluconfig/my.cnf_ndbd /ndbd-data/my.cnf
Alternatively, copy the content from my.cnf File for the Data Nodes to Store in /ndbd-data and overwrite the copied file.
phys-schost-1:/ # cd /ndbd-data phys-schost-2:/ # cd /ndbd-data phys-schost-1:/ndbd-data # /usr/local/mysql/bin/ndbd \ --defaults-file=/ndbd-data/my.cnf \ --ndb-connectstring=phys-schost-1-p:1186,phys-schost-2-p:1186 --ndb-nodeid=3 phys-schost-2:/ndbd-data # /usr/local/mysql/bin/ndbd \ --defaults-file=/ndbd-data/my.cnf \ --ndb-connectstring=phys-schost-1-p:1186,phys-schost-2-p:1186 --ndb-nodeid=4
phys-schost-1:/ndbd-data # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e show
Example output:
phys-schost-1:/ # /usr/local/mysql/bin/ndb_mgm --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e show Connected to Management Server at: phys-schost-1-p:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=3 @172.16.4.2 (mysql-5.1.35 ndb-7.0.7, Nodegroup: 0, Master) id=4 @172.16.4.1 (mysql-5.1.35 ndb-7.0.7, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s) id=1 @172.16.4.2 (mysql-5.1.35 ndb-7.0.7) id=2 @172.16.4.1 (mysql-5.1.35 ndb-7.0.7) [mysqld(API)] 2 node(s) id=7 (not connected, accepting connect from phys-schost-1) id=8 (not connected, accepting connect from phys-schost-2)
Create the directory structure and configuration by performing the following steps on both nodes
phys-schost-1:/ # mkdir -p /mysql-data/logs /mysql-data/innodb phys-schost-2:/ # mkdir -p /mysql-data/logs /mysql-data/innodb
phys-schost-1: # cd /usr/local/mysql phys-schost-1:/usr/local/mysql # ./scripts/* --datadir=/mysql-data phys-schost-2: # cd /usr/local/mysql phys-schost-2:/usr/local/mysql # ./scripts/* --datadir=/mysql-data
Use the example values in the my.cnf File for the First SQL Node phys-schost-1 to Store in /mysql-data for phys-schost-1, and my.cnf File for the Second SQL Node phys-schost-2 to Store in /mysql-data for phys-schost-2.
phys-schost-1:/ # cp /temp/cluconfig/my.cnf-serv /mysql-data/my.cnf phys-schost-1:/ # chmod 644 /mysql-data/my.cnf phys-schost-2:/ # cp /temp/cluconfig/my.cnf-serv /mysql-data/my.cnf phys-schost-2:/ # chmod 644 /mysql-data/my.cnf
phys-schost-1:/ # chown -R mysql:dba /mysql-data phys-schost-2:/ # chown -R mysql:dba /mysql-data
phys-schost-1:/ # cat >/temp/cluconfig/first <<EOF /usr/local/mysql/bin/mysqld --defaults-file=/mysql-data/my.cnf \ --basedir=/usr/local/mysql --datadir=/mysql-data \ --pid-file=/mysql-data/mysqld.pid \ --user=mysql >> /mysql-data/logs/phys-schost-1.log 2>&1 & EOF phys-schost-2:/ # cat >/temp/cluconfig/first <<EOF /usr/local/mysql/bin/mysqld --defaults-file=/mysql-data/my.cnf \ --basedir=/usr/local/mysql --datadir=/mysql-data \ --pid-file=/mysql-data/mysqld.pid \ --user=mysql >> /mysql-data/logs/phys-schost-2.log 2>&1 & EOF
phys-schost-1:/ # . /temp/cluconfig/first phys-schost-2:/ # . /temp/cluconfig/first
phys-schost-2:/ # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1,phys-schost-2 -e show
phys-schost-1:/ # /usr/local/mysql/bin/mysqladmin -S /tmp/phys-schost-1.sock \ -uroot password 'root' phys-schost-2:/ # /usr/local/mysql/bin/mysqladmin -S /tmp/phys-schost-2.sock \ -uroot password 'root'
phys-schost-1:/ # /usr/local/mysql/bin/mysql -S /tmp/phys-schost-1.sock -uroot -proot mysql> use mysql; mysql> grant all on *.* to 'root'@'phys-schost-1' identified by 'root'; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='phys-schost-1'; mysql> exit phys-schost-2:/ # /usr/local/mysql/bin/mysql -S /tmp/phys-schost-2.sock -uroot -proot mysql> use mysql; mysql> grant all on *.* to 'root'@'phys-schost-2' identified by 'root'; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='phys-schost-2'; mysql> exit
Use the content from mysql_config File for the First SQL Node phys-schost-1 to Store in /temp/cluconfig on phys-schost-1, and the content from mysql_config File for the Second SQL Node phys-schost-2 to Store in /temp/cluconfig on phys-schost-2.
On phys-schost-1
MYSQL_NIC_HOSTNAME=" phys-schost-1 "
On phys-schost-2
MYSQL_NIC_HOSTNAME=" phys-schost-2 "
phys-schost-1:/ # ksh /opt/SUNWscmys/util/mysql_register \ -f /temp/cluconfig/mysql_config phys-schost-2:/ # ksh /opt/SUNWscmys/util/mysql_register \ -f /temp/cluconfig/mysql_config
phys-schost-1:/ # pkill -f mysqld phys-schost-2:/ # pkill -f mysqld
phys-schost-1:/ # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e shutdown
phys-schost-1:/ # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e show phys-schost-2:/ # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-2-p,phys-schost-1-p -e show
phys-schost-1:/ # /usr/local/mysql/bin/ndb_mgm \ --ndb-connectstring=phys-schost-1-p,phys-schost-2-p -e "id stop"