MySQL-Cluster7.2.5安装和配置_MySQL
bitsCN.com
环境:
一台10.32.33.120 做一个数据节点,SQL节点,管理节点
一台 10.32.34.116 做一个数据节点,SQL节点。
操作系统都是 CentOS5.4 64位。
一 下载MySql Cluster7.2.5
http://www.mysql.com/downloads/cluster/
注:如果已经存在MySql,需要先删除,方法:
如果能联网 yum remove mysql
否则手动删除mysql
先看看都安装了什么包:
# rpm -qa|grep MySQL
然后把这些包都卸载掉
rpm -e MySQL-server-5.5.21-1.linux2.6
rpm -e MySQL-client-5.5.20-1.linux2.6
二 下载后解压
先设置10.32.33.120,把MySql Cluster下载到/downfiles下
#cd downfiles
#tar –zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz //解压
三 把解压后的文件拷贝到/usr/local下,名字为mysql
#cp /downfiles/mysql-cluster-gpl-7.2.5-linux2.6-x86_64 /usr/local/mysql
#cd /usr/local/mysql
# chown –R root . //把mysql的目录设置成所有者为root
#chown –R mysql /data //把data目录设置所有者为mysql
#chgrp –R mysql . //改成所属组为mysql
#cd scripts/
#mysql_install_db –user=mysql 这句就是安装了
四 设置mysql服务为开机自启动
#chmod +x /etc/rc.d/init.d/mysqld //给这个文件赋予可修改权限
#chkconfig --add mysqld // chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息,chkconfig --add name:增加一项新的服务
此时还不能开机自启,还需要设置环境变量
#vi /etc/profile
最后面加上两句
PATH=$PATH:/usr/local/mysql/bin
export PATH
以上操作在两台服务器上做同样操作。
五:配置
1、配置管理节点
拷贝/usr/local/mysql/bin/ndb_mgm,ndb_mgmd两个文件到/usr/local/bin
#cp /usr/local/mysql/bin/ndb_mgm* /usr/local/bin
#mkdir /var/lib/mysql-cluster
#vim /var/lib/mysql-cluster/config.ini
输入下面内容:
[ndbd default]
NoOfReplicas=1 #每个数据节点的镜像数量
DataMemory=200M #每个数据节点中给数据分配的内存
IndexMemory=20M #每个数据节点中给索引分配的内存
[ndb_mgmd] #配置管理节点
NodeId=1
hostname=10.32.34.116
datadir=/var/lib/mysql-cluster/ #管理节点数据(日志)目录
[ndbd] #数据节点配置
NodeId=2
hostname=10.32.33.120
datadir=/usr/local/mysql/data/ #数据节点目录
[ndbd]
NodeId=3
hostname=10.32.34.116
datadir=/usr/local/mysql/data/
[mysqld]
hostname=10.32.33.120
[mysqld]
hostname=10.32.34.116
[mysqld] #一定要留一个空的,以备扩展使用,否则会出现Failed to allocate nodeid No free node id found for ndbd(NDB)错误
[mysqld]
注:配置时, []右边的注释不要加上,否则系统不认。
[NDBD DEFAULT]:表示每个数据节点的默认配置在每个节点的[NDBD]中不用再写这些选项,只能有一个。
[NDB_MGMD]:表示管理节点的配置,只有一个。
[NDBD]:表示每个数据节点的配置,可以有多个。
[MYSQLD]:表示SQL节点的配置,可以有多个,分别写上不同SQL节点的IP地址。
2、配置数据节点和SQL节点
mysql服务启动时会默认加载/etc/my.cnf作为其配置文件,修改10.32.33.120上的my.cnf
[mysqld]
ndbcluster #运行NDB存储引擎
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
port=3306
[mysql_cluster]
ndb-connectstring=10.32.34.116 #声明管理节点
拷贝一份到另一台10.32.34.116
#scp /etc/my.cnf 10.32.34.116:/etc/
六 启动
节点的启动顺序为管理节点->数据节点->SQL节点。
1、120上启动管理节点
#cd /usr/local/bin
# ./ndb_mgmd -f /var/lib/mysql-cluster/config.ini // ndb_mgmd是mysqlcluster的管理服务器,后面的-f表示后面的参数是启动的参数配置文件。如果在启动后过了几天又添加了一个数据节点,这时修改了配置文件启动时就必须加上--initial参数,不然添加的节点不会作用在mysql cluster中
2、启动数据节点
安装后第一次启动数据节点时要加上--initial参数,其它时候不要加,除非是在备份、恢复或配置变化后重启时
#cd /var/local/mysql/bin/ndbd –initial
2012-03-28 02:01:38 [ndbd] INFO -- Angel connected to '10.32.33.120:1186'
2012-03-28 02:01:38 [ndbd] INFO -- Angel allocated nodeid: 36
出现这种信息表示启动成功.
3、启动SQL节点
#mysqld_safe --ndb_nodeid=5 --user=mysql &
同样方法,启动另外一个机器,注意nodeid的编号。
4、客户端查看
#cd /usr/local/bin
#.ndb_mgm
ndb_mgm> show
ndb_mgm> show
Cluster Configuration
---------------------
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.32.33.120 (mysql-5.5.20 ndb-7.2.5, Nodegroup: 0, Master)
id=3 @10.32.34.116 (mysql-5.5.20 ndb-7.2.5, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.32.34.116 (mysql-5.5.20 ndb-7.2.5)
[mysqld(API)] 4 node(s)
id=4 @10.32.33.120 (mysql-5.5.20 ndb-7.2.5)
id=5 @10.32.34.116 (mysql-5.5.20 ndb-7.2.5)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)
可以看到各个节点已经连接上了, mysql cluster配置完成.
如果看不到上述信息,可能是防火墙问题,你可以选择把CentOS的防火墙关掉,命令为:/etc/init.d/iptables stop
管理节点关闭,在ndb_mgm>提示符下输入shutdown,再输入exit即可退出。
7 测试。
1、从SQL节点A登录,创建数据库和表,进行简单测试。
mysql> create database zxztest ;
mysql> use zxztest;
Database changed
mysql> create table test1(id int,name varchar(10)) engine=ndb ;
mysql> insert into test1 values(1,'zhaoxuezhi');
mysql> select * from test1 ;
+------+---------+
| id | name |
+------+---------+
| 1 | zhaoxuezhi |
+------+---------+
登陆B节点,查看效果,库,表和数据已经同步。
从B节点插入一条数据,同样登陆A,也能看到数据已经同步。
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Zookeeper performance tuning on CentOS can start from multiple aspects, including hardware configuration, operating system optimization, configuration parameter adjustment, monitoring and maintenance, etc. Here are some specific tuning methods: SSD is recommended for hardware configuration: Since Zookeeper's data is written to disk, it is highly recommended to use SSD to improve I/O performance. Enough memory: Allocate enough memory resources to Zookeeper to avoid frequent disk read and write. Multi-core CPU: Use multi-core CPU to ensure that Zookeeper can process it in parallel.

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

The key to improving the efficiency of data transmission in DebianHadoop cluster lies in the comprehensive application of multiple strategies. This article will elaborate on optimization methods to help you significantly improve cluster performance. 1. The data localization strategy maximizes the allocation of computing tasks to the data storage nodes, effectively reducing data transmission between nodes. Hadoop's data localization mechanism will automatically move data blocks to the node where the computing task is located, thereby avoiding performance bottlenecks caused by network transmission. 2. Data compression technology adopts data compression technology during data transmission to reduce the amount of data transmitted on the network and thereby improve transmission efficiency. Hadoop supports a variety of compression algorithms, such as Snappy, Gzip, LZO, etc. You can choose the optimal algorithm according to the actual situation. three,

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Apache is written in C. The language provides speed, stability, portability, and direct hardware access, making it ideal for web server development.

In VS Code, you can run the program in the terminal through the following steps: Prepare the code and open the integrated terminal to ensure that the code directory is consistent with the terminal working directory. Select the run command according to the programming language (such as Python's python your_file_name.py) to check whether it runs successfully and resolve errors. Use the debugger to improve debugging efficiency.

VS Code extensions pose malicious risks, such as hiding malicious code, exploiting vulnerabilities, and masturbating as legitimate extensions. Methods to identify malicious extensions include: checking publishers, reading comments, checking code, and installing with caution. Security measures also include: security awareness, good habits, regular updates and antivirus software.
