测试环境
管理节点:10.50.44.88
数据节点: 10.50.56.252
数据节点: 10.50.56.253
SQL节点: 172.19.148.202
数据节点的配置是
CPU: 3.20GHz 2个双核
硬盘: 144G
内存: 2G
操作系统:Red Hat Enterprise Linux AS release 4 (Nahant)
管理节点安装
1. 检查是系统是否安装过mysql, 如果有安装,需要删除安装目录的文件.通过ps afx |grep mysql 查看到mysql的配置文件,数据库目录,pid,port,socket 等信息,要将这些信息全部清除.一般而言,删除 /usr/local/mysql* /var/lib/mysql*就可以
- # service mysql.server stop
- #rm -rf /usr/local/mysql* /var/lib/mysql*
2. 检查mysql组和用户,如果没有用进行下述添加
- # groupadd mysql
- #useradd -g mysql mysql
3. 下载安装文件
- #mkdir -p /home/meil/soft
- #cd /home/meil/soft
- #scp -r 10.50.44.89:/mnt/sda1/software/linux/mysql-max-5.0.27-linux-i686-glibc23.tar.gz ./
4. 解压安装
- # tar zxvf mysql-max-5.0.27-linux-i686-glibc23.tar.gz
- # cd mysql-max-5.0.27-linux-i686-glibc23/bin
- # cp -rf ./ndb* /usr/local/bin
- # cd /usr/local/bin
- #chmod +x ndb*
5. 配置启动
- # mkdir -p /var/lib/mysql-cluster
- # cd /var/lib/mysql-cluster
- # vi config.ini
- # Example Ndbcluster storage engine config file.
- #
- [NDBD DEFAULT]
- # 2 replicas (min. for redundancy; requires 2 storage nodes min.)
- NoOfReplicas=2
- # Standard data directory
- DataDir=/var/lib/mysql-cluster
- # 512mb storage for data, 64mb for primary keys.
- DataMemory= 1600M
- IndexMemory=300M
- # Define MaxNoOfConcurrentOperations; leave
- # MaxNoOfLocalOperations as default (1.1*
- # MaxNoOfConcurrentOperations)
- MaxNoOfConcurrentOperations=10000
- # Slightly increase the number of ordered indexes, unique hash
- # indexes, tables and attributes allowed from defaults
- # When importing tables, set this as high as you can
- # Then reduce based on output from ALL DUMP 1000 command
- MaxNoOfOrderedIndexes=512
- MaxNoOfUniqueHashIndexes=256
- MaxNoOfTables=256
- MaxNoOfAttributes=1500
- TimeBetweenWatchDogCheck= 30000
- MaxNoOfOpenFiles=200
- [NDB_MGMD DEFAULT]
- # Listen on default port, 1186
- PortNumber=1186
- # Log to console, syslog and also to a file
- # cluster-log in /var/log/.
- # Store files in /var/lib/mysql-cluster
- DataDir=/var/lib/mysql-cluster
- #All management nodes should be high priority for arbitration.
- ArbitrationRank=1
- [ndb_mgmd]
- Id=1
- HostName= 10.50.44.88
- [ndb_mgmd]
- Id=2
- HostName= 10.50.44.89
- [ndbd]
- Id=11
- HostName= 10.50.56.252
- datadir=/var/lib/mysql-cluster
- [ndbd]
- Id= 12
- HostName= 10.50.56.253
- datadir=/var/lib/mysql-cluster
- [mysqld]
- HostName=172.19.148.202
- Id= 21
- [mysqld]
- HostName=10.50.50.18
- Id= 22
- # choose an unused port number
- # in this configuration 63132, 63133, and 63134
- # will be used
- [tcp default]
- PortNumber= 63132
Nodeid是指本机的id, 在不同的机器需要不同的配置.由于需要多管理节点, 所有节点必须在/etc/my.cnf中制定nodeid, 包含管理节点。
- [root@Meil_88 mysql-cluster]# vi /etc/my.cnf
- [mysqld]
- ndbcluster
- ndb-connectstring= 10.50.44.88,10.50.44.89
- [mysql_cluster]
- ndb-connectstring= nodeid=1,10.50.44.88,10.50.44.89
- # vi /etc/rc.local
- Add following:
- ndb_mgmd -f /var/lib/mysql-cluster/config.ini
- # ndb_mgmd -f /var/lib/mysql-cluster/config.ini
存储节点安装
1. 检查是系统是否安装过mysql, 如果有安装,需要删除安装目录的文件.通过ps afx |grep mysql 查看到mysql的配置文件,数据库目录,pid,port,socket 等信息,要将这些信息全部清除.一般而言,删除 /usr/local/mysql* /var/lib/mysql*就可以
- # service mysql.server stop
- #rm -rf /usr/local/mysql* /var/lib/mysql*
2. 检查mysql组和用户,如果没有用进行下述添加
- # groupadd mysql
- #useradd -g mysql mysql
3. 下载安装文件
- #mkdir -p /home/meil/soft
- #cd /home/meil/soft
- #scp -r 10.50.44.89:/mnt/sda1/software/linux/mysql-max-5.0.27-linux-i686-glibc23.tar.gz ./
4. 解压安装和配置
- # tar zxvf mysql-max-5.0.27-linux-i686-glibc23.tar.gz
- # mv -f mysql-max-5.0.27-linux-i686-glibc23 /usr/local/
- # cd /usr/local
- # ln -s mysql-max-5.0.27-linux-i686-glibc23 mysql
- # cd mysql/support-files/
- # cp my-large.cnf /etc/my.cnf
- # vi /etc/my.cnf
确认添加修改了如下部分
- [mysqld]
- max_connections = 2000
- thread_concurrency = 2
- log_slow_queries = /var/log/mysql/slow_query.log
- log = /var/log/mysql/query.log
- long_query_time = 1
- datadir = /var/lib/mysql_data
- ndbcluster
- ndb-connectstring= 10.50.44.88,10.50.44.89
- bind-address = 127.0.0.1
- [mysql_cluster]
- ndb-connectstring= nodeid=11,10.50.44.88,10.50.44.89
- # mkdir -p /var/log/mysql
- # mkdir -p /var/lib/mysql-cluster
- # mkdir -p /var/lib/mysql_data
- # chmod +x /var/log/mysql /var/lib/mysql-cluster /var/lib/mysql_data
- # chown -R mysql.mysql /var/log/mysql /var/lib/mysql-cluster /var/lib/mysql_data
- # cd /usr/local/mysql
- # scripts/mysql_install_db --user=mysql
- # chown -R root . && chown -R mysql data && chgrp -R mysql .
5. 设置自动启动和环境变量
- #cp support-files/mysql.server /etc/rc.d/init.d/
- #chmod +x /etc/rc.d/init.d/mysql.server
- # chkconfig --add mysql.server
- # cd
- # vi .bash_profile
Modify following:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
6. 初始化启动
- /usr/local/mysql/bin/ndbd --initial
SQL节点安装
请参考数据节点的安装, 最后一步改为:
service mysql.server start
需要在[mysqld]下面配置nodeid
比如:
- ndbcluster
- ndb-connectstring= nodeid=22,10.50.44.88,10.50.44.89
说明:
1, 建议安装linux的时候不要选择任何防火墙
2, 安装mysql确保网络工作正常,尤其是有域名解析的机器,务必能正常解析,否则建议去掉域名解析.
3, 参考了现在3003,875板子对mysql的部分要求:
• 只允许本机mysql客户端连接mysql.
• Mysql 安装目录,数据目录,cluster目录,日志目录分开.
4, 增加了一些数据节点的配置值,但是需要在实际使用中修改.
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。