How To Set Up A Load-Balanced MySQL Cluster - Part 2

How To Set Up A Load-Balanced MySQL Cluster - Part 2 - 应用软件 - 电脑教程网

How To Set Up A Load-Balanced MySQL Cluster - Part 2

日期:2006-06-18   荐:
3 Set Up The MySQL Cluster Nodes (Storage Nodes)

Now we install mysql-max-5.0.19 on both sql1.example.com and sql2.example.com:

sql1.example.com / sql2.example.com:

groupadd mysqluseradd -g mysql mysqlcd /usr/local/wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.19-linux-i686-\glibc23.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/tar xvfz mysql-max-5.0.19-linux-i686-glibc23.tar.gzln -s mysql-max-5.0.19-linux-i686-glibc23 mysqlcd mysqlscripts/mysql_install_db --user=mysqlchown -R root:mysql .chown -R mysql datacp support-files/mysql.server /etc/init.d/chmod 755 /etc/init.d/mysql.serverupdate-rc.d mysql.server defaultscd /usr/local/mysql/binmv * /usr/bincd ../rm -fr /usr/local/mysql/binln -s /usr/bin /usr/local/mysql/bin

Then we create the MySQL configuration file /etc/my.cnf on both nodes:

sql1.example.com / sql2.example.com:

vi /etc/my.cnf

[mysqld]ndbcluster# IP address of the cluster management nodendb-connectstring=192.168.0.103[mysql_cluster]# IP address of the cluster management nodendb-connectstring=192.168.0.103

Make sure you fill in the correct IP address of the MySQL cluster management server.

Next we create the data directories and start the MySQL server on both cluster nodes:

sql1.example.com / sql2.example.com:

mkdir /var/lib/mysql-clustercd /var/lib/mysql-clusterndbd --initial/etc/init.d/mysql.server start

(Please note: we have to run ndbd --initial only when the start MySQL for the first time, and if /var/lib/mysql-cluster/config.ini on loadb1.example.com changes.)

Now is a good time to set a password for the MySQL root user:

sql1.example.com / sql2.example.com:

mysqladmin -u root password yourrootsqlpassword

We want to start the cluster nodes at boot time, so we create an ndbd init script and the appropriate system startup links:

sql1.example.com / sql2.example.com:

echo 'ndbd' > /etc/init.d/ndbdchmod 755 /etc/init.d/ndbdupdate-rc.d ndbd defaults

标签: