tar版mysql集群安装
来源:互联网 发布:网络蜘蛛工具下载 编辑:程序博客网 时间:2024/06/14 23:35
1. 下载:http://dev.mysql.com/downloads/mysql/5.0.html#linux 可以从这里下载 mysql-5.0.45-linux-i686.tar.gz
此包里已经包含了mysql-max包(mysql集群需要安装mysql-max包)。
2. 解压:
- tar -zxvf apache-tomcat-5.5.25.tar.gz
下载的这个.tar.gz是编译后的文件,只需要解压即可。
3. 配置
比如解压后的文件都放在:/home/mahaibo/mysql-5.0.45-linux-i686目录下。
数据节点(ndbd),管理节点(mgmd),服务节点(mysqld) 三个启动顺序是
mgmd ---> ndbd ---> mysqld
可以在同一台电脑上做个简单的配置和测试。以在同一台电脑上不同端口为例。实际中肯定是需要分布在不同的服务器上的。
A: 配置mgmd,并启动
在/home/mahaibo/mysql-5.0.45-linux-i686建立一个mgmd.cnf和mgmd的数据目录mgmddata ,编辑mgmd.cnf文件:
# Options affecting ndbd processes on all data nodes:
[NDBD DEFAULT]
NoOfReplicas=1 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
# TCP/IP options:
[TCP DEFAULT]
#portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in cluster
# Note: It is recommended beginning with MySQL 5.0 that
# you do not specify the portnumber at all and simply allow
# the default value to be used instead
# Management process options:
[NDB_MGMD]
hostname=127.0.0.1 # Hostname or IP address of MGM node ,mgmd's hostname
datadir=/home/mahaibo/mysql-5.0.45-linux-i686/mgmddata # Directory for MGM node logfiles
PortNumber=2203 #default value: 1186
# Options for data node "A":
[NDBD]
# (one [NDBD] section per data node)
hostname=127.0.0.1 # Hostname or IP address ,allow to access
datadir=/home/mahaibo/mysql-5.0.45-linux-i686/mgmddata # Directory for this data node's datafiles
# Options for data node "B":
[NDBD]
hostname=127.0.0.1 # Hostname or IP address
datadir=/home/mahaibo/mysql-5.0.45-linux-i686/mgmddata # Directory for this data node's datafiles
[MYSQLD]
hostname=127.0.0.1 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
可以看到配置了2个数据节点ndbd,也就是说改管理节点可以管理小于或等于2个数据节点。管理节点mgmd的端口为2203。
启动mgmd服务:
- bin/ndb_mgmd -f mgmd.cnf
启动后,登录mgmd的客户端mgm可以查看具体信息:
- bin/ndb_mgm 127.0.0.1 2203 //因为mgmd服务用的端口是2203,所以要通过该端口链接
[mahaibo@client mysql-5.0.45-linux-i686]$ bin/ndb_mgm 127.0.0.1 2203
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 127.0.0.1:2203
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 127.0.0.1)
id=3 (not connected, accepting connect from 127.0.0.1)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @127.0.0.1 (Version: 5.0.45)
[mysqld(API)] 1 node(s)
id=4 (not connected, accepting connect from 127.0.0.1)
ndb_mgm>
可以看到ndbd和mysqld都是not connected状态,因为这2个服务都还没有启动。
B: 启动数据节点(ndbd)
以启动2个数据节点为例。
分别建立ndbd1.cnf ,ndbd1data数据目录
编辑ndbd1.cnf:
[mysqld]
DataDir=/home/mahaibo/mysql-5.0.45-linux-i686/ndbd1data//数据目录
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
ndbcluster
ndb-connectstring=127.0.0.1:2203
[mysql_cluster]
ndb-connectstring=127.0.0.1:2203 // 连接mgmd服务的ip与端口
启动第一个ndbd数据节点
- bin/ndbd --defaults-file=ndbd1.cnf --initial
第一次启动需要加--initial参数。
第2个数据节点(ndbd)也需要做同样的配置和启动操作。分别建立ndbd2.cnf ,ndbd2data数据目录
ndbd2.cnf的配置和ndbd1.cnf的配置几乎是一样的,只是数据目录不一样。
启动第2个数据节点ndbd:
bin/ndbd --defaults-file=ndbd2.cnf --initial
这时,如果登录到mgmd管理节点的客户端mgm,
[mahaibo@client mysql-5.0.45-linux-i686]$ bin/ndb_mgm 127.0.0.1 2203
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 127.0.0.1:2203
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @127.0.0.1 (Version: 5.0.45, Nodegroup: 0, Master)
id=3 @127.0.0.1 (Version: 5.0.45, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @127.0.0.1 (Version: 5.0.45)
[mysqld(API)] 1 node(s)
id=4 (not connected, accepting connect from 127.0.0.1)
ndb_mgm>
可以看到ndbd的2个节点都是连接状态了,而不是not connected状态了,但是mysqld还是not connected状态。
C: 启动mysqld服务。
打开mysql-5.0.45-linux-i686下的configure文件,可以看到其内容为:
- #!/bin/sh
- if test ! -x ./scripts/mysql_install_db
- then
- echo "I didn't find the script './scripts/mysql_install_db'."
- echo "Please execute this script in the mysql distribution directory!"
- exit 1;
- fi
- echo "NOTE: This is a MySQL binary distribution. It's ready to run, you don't"
- echo "need to configure it!"
- echo ""
- echo "To help you a bit, I am now going to create the needed MySQL databases"
- echo "and start the MySQL server for you. If you run into any trouble, please"
- echo "consult the MySQL manual, that you can find in the Docs directory."
- echo ""
- ./scripts/mysql_install_db --no-defaults
- if [ $? = 0 ]
- then
- echo "Starting the mysqld server. You can test that it is up and running"
- echo "with the command:"
- echo "./bin/mysqladmin version"
- ./bin/mysqld_safe --no-defaults & #默认会去根据/etc/my.cnf这个配置文件进行启动,并且生成的sock端口会放在/tmp/mysql.sock
- fi
可以看到:它实际是上先执行./scripts/mysql_install_db,然后在去通过./bin/mysqld_safe去启动mysql服务的,用的参数是--no-defaults,也就是默认会去根据/etc/my.cnf这个配置文件进行启动,并且生成的sock端口会放在/tmp/mysql.sock.
如果想让mysql启动时调用自己指定的my.cnf的位置。可以把configure文件内容里的./bin/mysqld_safe --no-defaults &修改为:
- ./bin/mysqld_safe --defaults-file=my3.cnf & #当前目录下的my.cnf,也可以自己指定绝对路径
建立my3.cnf和数据目录data3
编辑my3.cnf:
- [mysqld]
- port = 3306
- socket = /home/mahaibo/mysql-5.0.45-linux-i686/mysql3.sock
- datadir = /home/mahaibo/mysql-5.0.45-linux-i686/data3
- ndbcluster # run NDB engine
- ndb-connectstring=127.0.0.1:2203 # location of MGM node
- skip-locking
- key_buffer = 16M
- max_allowed_packet = 1M
- table_cache = 64
- sort_buffer_size = 512K
- net_buffer_length = 8K
- read_buffer_size = 256K
- read_rnd_buffer_size = 512K
- myisam_sort_buffer_size = 8M
启动mysqld服务:
- ./configure3
如果这时在登录到mgmd管理节点的客户端mgm,
- [mahaibo@client mysql-5.0.45-linux-i686]$ bin/ndb_mgm 127.0.0.1 2203
- -- NDB Cluster -- Management Client --
- ndb_mgm> show
- Connected to Management Server at: 127.0.0.1:2203
- Cluster Configuration
- ---------------------
- [ndbd(NDB)] 2 node(s)
- id=2 @127.0.0.1 (Version: 5.0.45, Nodegroup: 0, Master)
- id=3 @127.0.0.1 (Version: 5.0.45, Nodegroup: 1)
- [ndb_mgmd(MGM)] 1 node(s)
- id=1 @127.0.0.1 (Version: 5.0.45)
- [mysqld(API)] 1 node(s)
- id=4 @127.0.0.1 (Version: 5.0.45)
可以看到mysqld也是连接状态了
登录到mysqld的客户端,然后
- show variables like 'have%';
可以看到
have_ndbcluster 为 YES,说明ndbcluster引擎已经打开。
可以建立一个ndbcluster引擎的表测试下看是否成功
- create table table1 (aa int) engine=ndbcluster;
- insert into table1 values(11);
- insert into table1 values(22);
都没有问题。
show create table table1;
可以看到:
- mysql> show create table table1;
- +--------+------------------------------------------------------------------------------------------------+
- | Table | Create Table |
- +--------+------------------------------------------------------------------------------------------------+
- | table1 | CREATE TABLE `table1` (
- `aa` int(11) default NULL
- ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 |
- +--------+------------------------------------------------------------------------------------------------+
- 1 row in set (0.00 sec)
关闭mysql
bin/mysqladmin -uroot -p shutdown.
要给目录赋值权限
chmod -R 1777 /var/lib/mysql ,否则会报tmp.sock找不到的问题
- tar版mysql集群安装
- tar版mysql集群安装
- tar版mysql集群安装
- tar版mysql集群安装
- linux下tar版mysql安装步骤
- Mysql Tar 安装
- 安装mysql tar.gz
- mac 安装 mysql.tar.gz
- linux mysql安装(tar.gz)
- Mac mysql tar格式 安装
- MySQL 5.6 Bundle Tar安装
- mysql for mac tar安装
- tar包方式安装Mysql
- 三、tar包安装mysql
- ubuntu 下mysql.tar.gz解压缩版安装
- mysql集群安装、配置
- mysql集群安装配置
- Mysql集群安装配置
- 关于 SAP OLE MS WORD
- 删除.o文件
- SQL*PLUS命令的使用大全
- cxRichEdit RichEdit line insertion error 个例解决方法
- JSTL简介
- tar版mysql集群安装
- tar版mysql集群安装
- VC++工程的文件类型
- tar版mysql集群安装
- 快速排序改进
- 移动加权平均法
- tar版mysql集群安装
- Oracle Savepoint
- struts2 中生成excel