mysql cluster-NDB7.5 install

Centos Install Mysql Cluster

 

 

Cluster nodes and host computers. 

Node

IP Address

Management node (mgmd)

10.1.10.50

SQL node (mysqld)

10.1.10.51

Data node "A" (ndbd)

10.1.10.52

Data node "B" (ndbd)

10.1.10.53

MySQL Cluster Multi-Computer Setup

 

本节描述的基于web的图形化配置安装程序包括MySQL集群分布的一部分。讨论的主题包括安装程序的概述及其部件,运行安装程序,软件和其他要求在GUI,并使用安装程序设置和启动或停止MySQL集群在一个或多个主机电脑。

Auto-Installer:

Supported platforms.  The MySQL Cluster Auto-Installer is available with most MySQL Cluster NDB 7.5.2 and later MySQL Cluster distributions for recent versions of Linux, Windows, Solaris, and MacOS X.

The MySQL Cluster Auto-Installer is not supported with MySQL Cluster NDB 7.5.0 or 7.5.1

Supported Web browsers.  The Web-based installer is supported with recent versions of Firefox and Microsoft Internet Explorer. It should also work with recent versions of Opera, Safari, and Chrome, although we have not thoroughly tested for compability with these browsers.

Required software—setup host.  The following software must be installed on the host where the Auto-Installer is run:

Python 2.6 or higher. //centos6默认已经安装好了Python 2.6.6

Paramiko 1.7.7.1 or higher.// Paramiko may also be available from your system's package manager. paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接。

Required software—remote hosts. //The only software required for remote hosts where you wish to deploy MySQL Cluster nodes is the SSH server, which is usually installed by default on Linux and Solaris systems. Several alternatives are available for Windows; for an overview of these, see http://en.wikipedia.org/wiki/Comparison_of_SSH_servers.

Authentication and security.

SSH.  A secure shell connection is used to enable the back end to perform actions on remote hosts. For this reason, an SSH server must be running on the remote host. In addition, the system user running the installer must have access to the remote server, either with a user name and password, or by using public and private keys.

Important You should never use the system root account for remote access, as this is extremely insecure. In addition, mysqld cannot normally be started by system root. For these and other reasons, you should provide SSH credentials for a regular user account on the target system, and not for system root. For more information about this issue, see:

On Unix, the MySQL server mysqld can be started and run by any user. However, you should avoid running the server as the Unix root user for security reasons. To change mysqld to run as a normal unprivileged Unix user user_name, you must do the following:

  1. Stop the server if it is running (use mysqladmin shutdown).
  2. Change the database directories and files so that user_name has privileges to read and write files in them (you might need to do this as the Unix root user):
  1. shell> chown -R user_name /path/to/mysql/datadir

If you do not do this, the server will not be able to access databases or tables when it runs as user_name.

If directories or files within the MySQL data directory are symbolic links, chown -R might not follow symbolic links for you. If it does not, you will also need to follow those links and change the directories and files they point to.

  1. Start the server as user user_name. Another alternative is to start mysqld as the Unix root user and use the --user=user_name option. mysqld starts up, then switches to run as the Unix user user_name before accepting any connections.
  2. To start the server as the given user automatically at system startup time, specify the user name by adding a user option to the [mysqld] group of the /etc/my.cnf option file or the my.cnf option file in the server's data directory. For example:
  1. [mysqld]
  2. user=user_name

If your Unix machine itself is not secured, you should assign passwords to the MySQL root account in the grant tables. Otherwise, any user with a login account on that machine can run the mysql client with a --user=root option and perform any operation. (It is a good idea to assign passwords to MySQL accounts in any case, but especially so when other login accounts exist on the server host.) See Section 2.10.4, “Securing the Initial MySQL Accounts”.

HTTPS.  Remote communication between the Web browser front end and the back end is not encrypted by default, which means that information such as the user's SSH password is transmitted in clear text that is readable to anyone. For communication from a remote client to be encrypted, the back end must have a certificate, and the front end must communicate with the back end using HTTPS rather than HTTP. Enabling HTTPS is accomplished most easily through issuing a self-signed certificate. Once the certificate is issued, you must make sure that it is used. You can do this by starting ndb_setup.py from the command line with the --use-https and --cert-file options..

Certificate-based authentication.  The back end ndb_setup.py process can execute commands on the local host as well as remote hosts. This means that anyone connecting to the back end can take charge of how commands are executed. To reject unwanted connections to the back end, a certificate may be required for authentication of the client. In this case, a certificate must be issued by the user, installed in the browser, and made available to the back end for authentication purposes. You can enact this requirement (together with or in place of password or key authentication) by starting ndb_setup.py with the --ca-certs-file option.

There is no need or requirement for secure authentication when the client browser is running on the same host as the Auto-Installer back end.

See also Section 19.5.12, “MySQL Cluster Security Issues”, which discusses security considerations to take into account when deploying MySQL Cluster, as well as Chapter 7, Security, for more general MySQL security information.

MySQL Cluster Auto-Installer Overview

The MySQL Cluster Auto-Installer是运行在两个组件之上,前面是一个WEB界面,后端是Python的一个程序:ndb_setup.py

 

 Using the MySQL Cluster Auto-Installer

http://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-install-auto-using.html

 

 Installation of MySQL Cluster on Linux

Installing a MySQL Cluster Binary Release on Linux

SQL nodes. 

首先使用如下命令来清理之前操作系统自带的mysql安装:
# yum -y remove mysql
然后使用如下命令:
# rpm -qa | grep mysql*
对于找到的2个剩余mysql包,请按照如下的命令格式予以删除:
# rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

# groupadd mysql

# useradd -g mysql -s /bin/false mysql

# cd /var/tmp/

# tar -C /usr/local/ -xzvf mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64.tar.gz

# ln -s /usr/local/mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64 /usr/local/mysql

# cd /usr/local/mysql

# bin/mysql_install_db --user=mysql

# chown -R root .
# chown -R mysql /usr/local/data/mysqldata
# chgrp -R mysql .
# cp support-files/mysql.server /etc/rc.d/init.d/
# chmod +x /etc/rc.d/init.d/mysql.server
# chkconfig --add mysql.server
 

Data nodes.

Installation of the data nodes does not require the mysqld binary. Only the MySQL Cluster data node executable ndbd (single-threaded) or ndbmtd (multi-threaded) is required. These binaries can also be found in the .tar.gz archive. Again, we assume that you have placed this archive in /var/tmp.
# cd /var/tmp/
# tar -xzvf mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64.tar.gz
# cd mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64
# cp bin/ndbd /usr/local/bin/ndbd
# cp bin/ndbmtd /usr/local/bin/ndbmtd
# cd /usr/local/bin/
# chmod +x ndb*
The preceding steps should be repeated on each data node host.

Management nodes.

Installation of the management node does not require the mysqld binary. Only the MySQL Cluster management server (ndb_mgmd) is required; you most likely want to install the management client (ndb_mgm) as well. Both of these binaries also be found in the .tar.gz archive. Again, we assume that you have placed this archive in /var/tmp.
# cd /var/tmp/
# tar -xzvf mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64.tar.gz
# cd mysql-cluster-gpl-7.5.1-linux-glibc2.5-x86_64
# cp bin/ndb_mgm* /usr/local/bin/
# chmod +x ndb_mgm*

Initial Configuration of MySQL Cluster

 

Configuring the management node.

 

shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> 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=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 default]

# TCP/IP options:

portnumber=2202   #启动时候一直报错,可以注释这行,默认启动的端口是1186

# This the default; however, you can use any

                  # port that is free for all the hosts in the cluster

                  # Note: It is recommended that you do not specify the port

                  # number at all and simply allow the default value to be used

                  # instead

 

[ndb_mgmd]

# Management process options:

hostname=10.1.10.50             # Hostname or IP address of MGM node

datadir=/var/lib/mysql-cluster  # Directory for MGM node log files

 

[ndbd]

# Options for data node "A":

                                # (one [ndbd] section per data node)

hostname=10.1.10.52             # Hostname or IP address

datadir=/usr/local/mysql/data   # Directory for this data node's data files

 

[ndbd]

# Options for data node "B":

hostname=10.1.10.53             # Hostname or IP address

datadir=/usr/local/mysql/data   # Directory for this data node's data files

 

[mysqld]

# SQL node options:

hostname=10.1.10.51             # Hostname or IP address

                                # (additional mysqld connections can be

                                # specified for this node for various

                                # purposes such as running ndb_restore)

 

 

Configuring the data nodes and SQL nodes.

For each data node and SQL node in our example setup, my.cnf should look like this:

# vi /etc/my.cnf

[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=192.168.0.10  # location of management server

 

Initial Startup of MySQL Cluster

management node:

# ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial   #初次启动加上 –initial

Data node:

# ndbd

SQL(API) node:

# /etc/init.d/mysql.server start

 

You can test this by invoking the ndb_mgm management node client.

# ndb_mgm

 

MySQL Cluster Example with Tables and Data

Create table:

CREATE TABLE tbl_name (col_name column_definitions) ENGINE=NDBCLUSTER;

Alter table:

ALTER TABLE tbl_name ENGINE=NDBCLUSTER;

 

  • 每一个 NDBCLUSTER 表有一个 主键。 如果没有主键时由用户定义 创建表, NDBCLUSTER 存储引擎自动生成一个隐藏的。 这样一个 关键占用空间和其他表索引。 (这是 经常遇到问题由于内存不足 为适应这些自动创建索引)。

importing tables from an existing database

If you are importing tables from an existing database using the output of mysqldump, you can open the SQL script in a text editor and add the ENGINE option to any table creation statements, or replace any existing ENGINE options. Suppose that you have the world sample database on another MySQL server that does not support MySQL Cluster, and you want to export the City table:

open the SQL script in a text editor and add the ENGINE option to any table creation statements

mysqldump --add-drop-table world City > city_table.sql

 

 

shell> mysql world < city_table.sql

If you did not modify the SQL script, you should run the following statements at this point:

shell> mysql -u root –p

mysql> USE world;

mysql> ALTER TABLE City ENGINE=NDBCLUSTER;

mysql> ALTER TABLE Country ENGINE=NDBCLUSTER;

mysql> ALTER TABLE CountryLanguage ENGINE=NDBCLUSTER;

使用MySQL的应用程序可以使用标准的api来访问 NDB 表。 是很重要的 请记住,您的应用程序必须访问SQL节点,而不是 管理或数据节点。

select concat('alter table ',table_schema,'.',table_name,' ENGINE=NDBCLUSTER;') from information_schema.TABLES where table_schema = 'db_name' AND (ENGINE='InnoDB' or ENGINE='MyISAM');

Safe Shutdown and Restart of MySQL Cluster

To shut down the cluster, enter the following command in a shell on the machine hosting the management node:

shell> ndb_mgm -e shutdown

To restart the cluster on Unix platforms, run these commands:

  • On the management host

shell> ndb_mgmd -f /var/lib/mysql-cluster/config.ini

  • On each of the data node hosts

shell> ndbd

Use the ndb_mgm client to verify that both data nodes have started successfully.

  • · On the SQL host

shell> mysqld_safe &

 

 

posted @ 2016-06-07 17:16  nbuntu牛班图  阅读(849)  评论(0编辑  收藏  举报