首页 / MYSQL / MySQL集群技术(四台机器)
MySQL集群技术(四台机器)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL集群技术(四台机器),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3616字,纯文字阅读大概需要6分钟。
内容图文
id=4 @192.168.0.100 (Version: 4.1.12)6.2 模拟写入一个数据库表,各MysqlServer节点是否能够同步1) 在一个MysqlServer节点上创
1、环境描述
Mysql manager 节点:192.168.0.1
MysqlServer节点:192.168.0.100
Mysql 节点:192.168.0.160
Mysql 节点:192.168.0.161
说明:至少需要四台服务器才可以做mysql的集群。建议5台,再增加一台MysqlServer。
2安装mysql二进制包
2.1 安装之前的准备工作
下载mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz包
(注意:可以做集群的mysql都是mysql-max的,下载地点)
#groupadd mysql
#useradd -g mysql mysql
#cd /usr/local
#tar xfz mysql-max-4.1.13-pc-linux-gnu-i686.tar.gz
#ln -s /usr/local/mysql-max-4.1.13-pc-linux-gnu-i686 /opt/mysql4.1.13
2.2 分别在manager,server,,node节点上安装二进制的mysql包
#cd mysql4.1.13
#scripts/mysql_install_db --user=mysql (必须带目录执行,否则出错)
#chown -R root /opt/mysql4.1.13
#chgrp -R mysql /opt/mysql4.1.13
#chown -R mysql.mysql /opt/mysql4.1.13/data
#cp support-files/mysql.server /etc/rc.d/init.d/ 配置mysql启动设置
#chmod +x /etc/rc.d/init.d/mysql.server
#chkconfig --add mysql.server
3配置server,note节点
在192.168.0.160和192.168.0.161机器上
# ./mysql –help 该命令可以查看mysql启动时是怎么寻找my.cnf文件的顺序。
Default options are read from the following files in the given order:
/etc/my.cnf /usr/local/mysql-max-4.1.13/data/my.cnf ~/.my.cnf
# cp support-files/my-medium.cnf data/my.cnf 将mysql的配置文件考到data下
Vi /usr/local/mysql-max-4.1.13-pc-linux-gnu-i686/data/my.cnf
[MYSQLD]
ndbcluster
ndb-connectstring=192.168.0.1
[MYSQL_CLUSTER]
ndb-connectstring=192.168.0.1
4配置Management管理节点
在192.168.0.1机器上
#mkdir /var/lib/mysql-cluster
#cd /var/lib/mysql-cluster
#vi config.ini
[NDBD DEFAULT] # Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=52M # 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 DEFAULT] # TCP/IP options:
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=192.168.0.1 # 管理节点Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node logfiles
# Options for data node "A"(定义群集数据节点.)
# (one [NDBD] section per data node)
[NDBD]
hostname=192.168.0.160 # 节点Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's datafiles
# Options for data node "B"(定义群集数据节点.)
[NDBD]
hostname=192.168.0.161 # 节点Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's datafiles
# SQL node options(定义Sql server节点.)
[MYSQLD]
hostname=192.168.0.100 # SQL节点Hostname or IP address
#datadir=/usr/local/mysql/data # Directory for SQL node's datafiles
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
[NDB_MGMD]:后面不能有任何注释信息,否则提示:
Error line 17: [TCP] Unknown parameter: [NDB_MGMD] # Management process options
Error line 17: Could not parse name-value pair in config file.
[SHM]: Defines shared-memory connections between nodes. 在MySQL 4.1.9之前,这个功能必须使用--with-ndb-shm option编译进去, 从MySQL 4.1.9-max版本开始, it is enabled by default
内容总结
以上是互联网集市为您收集整理的MySQL集群技术(四台机器)全部内容,希望文章能够帮你解决MySQL集群技术(四台机器)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。