Mysql ndb-cluster centos6.4 簡單配置
NDB Cluster
Server1 |
192.168.0.30 |
Mysql叢集伺服器1 |
Server2 |
192.168.0.31 |
Mysql叢集伺服器2 |
Server3 |
192.168.0.214 |
管理(MGM)節點 |
--在server1和server2分別安裝mysql,如下
tar zxvf mysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64.tar.gz
[root@ryxr1 mysql]# groupadd mysql
[root@ryxr1 mysql]# useradd -g mysql mysql
[root@ryxr2 mysql]# ./scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2015-04-22 14:26:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-22 14:26:43 0 [Note] ./bin/mysqld (mysqld 5.6.24-ndb-7.4.6-cluster-gpl) starting as process 26442 ...
2015-04-22 14:26:43 26442 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-22 14:26:43 26442 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-22 14:26:43 26442 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-22 14:26:43 26442 [Note] InnoDB: Memory barrier is not used
2015-04-22 14:26:43 26442 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-22 14:26:43 26442 [Note] InnoDB: Using Linux native AIO
2015-04-22 14:26:43 26442 [Note] InnoDB: Using CPU crc32 instructions
2015-04-22 14:26:43 26442 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-22 14:26:43 26442 [Note] InnoDB: Completed initialization of buffer pool
2015-04-22 14:26:43 26442 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-04-22 14:26:43 26442 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-04-22 14:26:43 26442 [Note] InnoDB: Database physically writes the file full: wait...
2015-04-22 14:26:43 26442 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-04-22 14:26:43 26442 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-04-22 14:26:43 26442 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-04-22 14:26:43 26442 [Warning] InnoDB: New log files created, LSN=45781
2015-04-22 14:26:43 26442 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-04-22 14:26:43 26442 [Note] InnoDB: Doublewrite buffer created
2015-04-22 14:26:43 26442 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-22 14:26:43 26442 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-04-22 14:26:43 26442 [Note] InnoDB: Foreign key constraint system tables created
2015-04-22 14:26:43 26442 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-04-22 14:26:43 26442 [Note] InnoDB: Tablespace and datafile system tables created.
2015-04-22 14:26:43 26442 [Note] InnoDB: Waiting for purge to start
2015-04-22 14:26:43 26442 [Note] InnoDB: 5.6.24 started; log sequence number 0
2015-04-22 14:26:43 26442 [Note] Binlog end
2015-04-22 14:26:43 26442 [Note] InnoDB: FTS optimize thread exiting.
2015-04-22 14:26:43 26442 [Note] InnoDB: Starting shutdown...
2015-04-22 14:26:45 26442 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2015-04-22 14:26:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-22 14:26:45 0 [Note] ./bin/mysqld (mysqld 5.6.24-ndb-7.4.6-cluster-gpl) starting as process 26473 ...
2015-04-22 14:26:45 26473 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-22 14:26:45 26473 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-22 14:26:45 26473 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-22 14:26:45 26473 [Note] InnoDB: Memory barrier is not used
2015-04-22 14:26:45 26473 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-22 14:26:45 26473 [Note] InnoDB: Using Linux native AIO
2015-04-22 14:26:45 26473 [Note] InnoDB: Using CPU crc32 instructions
2015-04-22 14:26:45 26473 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-22 14:26:45 26473 [Note] InnoDB: Completed initialization of buffer pool
2015-04-22 14:26:45 26473 [Note] InnoDB: Highest supported file format is Barracuda.
2015-04-22 14:26:45 26473 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-22 14:26:45 26473 [Note] InnoDB: Waiting for purge to start
2015-04-22 14:26:45 26473 [Note] InnoDB: 5.6.24 started; log sequence number 1625977
2015-04-22 14:26:45 26473 [Note] Binlog end
2015-04-22 14:26:45 26473 [Note] InnoDB: FTS optimize thread exiting.
2015-04-22 14:26:45 26473 [Note] InnoDB: Starting shutdown...
2015-04-22 14:26:47 26473 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h ryxr2.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@ryxr2 mysql]# chown -R root .
[root@ryxr2 mysql]# chown -R mysql data
[root@ryxr2 mysql]# chgrp -R mysql .
Server3:
作為管理節點伺服器,Server3需要ndb_mgm和ndb_mgmd兩個檔案,可以從server1或server2從copy過來,scp /usr/local/mysql/bin/ndb_mgm* root@192.168.0.214:/usr/bin/
為管理節點伺服器建立配置檔案
mkdir /var/lib/mysql-cluster
# cd /var/lib/mysql-cluster
# vi config.ini
[NDBD DEFAULT]
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.
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.0.214 #管理節點伺服器Server3的IP地址
Datadir=/var/lib/mysql-cluster #Directory for MGM node logfiles
# Storage Engines
[NDBD]
HostName=192.168.0.30 #MySQL叢集Server1的IP地址
DataDir= /usr/local/mysql/data
[NDBD]
HostName=192.168.0.31 #MySQL叢集Server2的IP地址
DataDir=/usr/local/mysql/data
# 以下2個[MYSQLD]
[MYSQLD]
HostName=192.168.0.30
[MYSQLD]
HostName=192.168.0.31
建立後,啟動管理節點伺服器Server3,
[root@dgryxrdb mysql-cluster]# ndb_mgmd
MySQL Cluster Management Server mysql-5.6.24 ndb-7.4.6
2015-04-22 14:42:18 [MgmtSrvr] INFO -- The default config directory '/usr/local/mysql/mysql-cluster' does not exist. Trying to create it...
2015-04-22 14:42:18 [MgmtSrvr] INFO -- Sucessfully created config directory
2015-04-22 14:42:18 [MgmtSrvr] ERROR -- Could not determine which nodeid to use for this node. Specify it with --ndb-nodeid=
如果以上執行錯誤,則執行
ndb_mgmd -f /var/lib/mysql-cluster/config.ini --用引數“-f”或“--config-file”告訴ndb_mgmd配置檔案所在位置,預設是在ndb_mgmd相同目錄下。
Cluster的管理節點的預設埠是1186,資料節點的預設埠2202,從Mysql5.0.3開始,該限制已被放寬,Cluster能夠根據空閒的埠自動地為資料節點分配埠
啟動管理節點後應該注意,這只是管理節點服務,並不是管理終端。啟動Mysql Cluster合理的順序是,先啟動管理節點伺服器,然後啟動儲存節點伺服器,最後才啟動SQL節點伺服器。
在Server1和Server2做如下改動
# vi /etc/my.cnf
[root@ryxr2 ~]# vi /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/data
basedir = /usr/local/mysql
ndbcluster
ndb-connectstring=192.168.0.214
[MYSQL_CLUSTER]
ndb-connectstring=192.168.0.214
----------------以下為實際
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
datadir=/usr/local/mysql/data
basedir/usr/local/mysql
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
ndbcluster
ndb-connectstring=192.168.0.214
[mysqld_safe]
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid
[MYSQL_CLUSTER]
ndb-connectstring=192.168.0.214
修改完後,儲存,執行
在儲存節點上(server1和server2)
[root@ryxr1 mysql]# ./bin/ndbd --initial
2015-04-22 15:23:37 [ndbd] INFO -- Angel connected to '192.168.0.214:1186'
2015-04-22 15:23:37 [ndbd] INFO -- Angel allocated nodeid: 3
注:只有在第一次啟動ndbd時或者對Server3的config.ini進行改動後或在備份、恢復資料後才需要使用--initial引數,因為該引數會使節點刪除由早期ndbd
啟動sql節點伺服器
[root@ryxr2 mysql]# /etc/rc.d/init.d/mysql start
或/usr/local/mysql/bin/mysqld_safe --user=mysql --explicit_defaults_for_timestamp &
Server1和Server2均啟動後,回到管理節點Server3,啟動管理終端
鍵入:show命令,檢視當前工作狀態
[root@dgryxrdb mysql-cluster]# /usr/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.0.30 (mysql-5.6.24 ndb-7.4.6, Nodegroup: 0)
id=3 @192.168.0.31 (mysql-5.6.24 ndb-7.4.6, Nodegroup: 0, *)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.0.214 (mysql-5.6.24 ndb-7.4.6)
[mysqld(API)] 2 node(s)
id=4 @192.168.0.30 (mysql-5.6.24 ndb-7.4.6)
id=5 @192.168.0.31 (mysql-5.6.24 ndb-7.4.6)
如上,在Server2,建立表(只能是基於ndb儲存引擎的)檢視是否在Server1中也存在。
mysql> create table c_testb(id varchar(10)) engine=ndbcluster default charset utf8;
Query OK, 0 rows affected (0.19 sec)
在Server1中執行insert,Server2資料同步完成
mysql> select * from c_testb;
+------+
| id |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.01 sec)
安全關閉
在MGM節點所在機器上,輸入
# /usr/local/mysql/ndb_mgm -e shutdown
關閉SQL節點的mysqld服務
#/usr/local/mysql/bin/mysqladmin -uroot shutdown
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28258625/viewspace-1651185/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql 主-主簡單配置 --centos6.4MySqlCentOS
- Mysql 主-從簡單配置---centos6.4MySqlCentOS
- mysql cluster 簡單配置MySql
- mysql_to_mysql的gg簡單配置MySql
- mysql goldengate同步 簡單配置MySqlGo
- CentOS6.4系統MySQL主從複製基本配置實踐CentOSMySql
- 簡單配置mysql的主從複製MySql
- keepalived+mysql+centos6.4 簡單配置MySqlCentOS
- Mysql Master-slave複製簡單配置記錄MySqlAST
- Webapck 簡單配置Web
- 簡單配置ASMASM
- VS code 簡單配置
- SELinux簡單配置Linux
- squid 簡單配置UI
- mysql 簡單安裝MySql
- Mysql 簡單入門MySql
- mysql簡單脫敏MySql
- MySQL簡單總結MySql
- Docker簡單使用MySQLDockerMySql
- MySQL的簡單安裝配置(免安裝zip版,版本5.7.21)MySql
- Centos6.4編譯安裝mysql 8.0.0 詳細教程CentOS編譯MySql
- MySQL單機多例項配置MySql
- Web Scraper簡單配置方法Web
- spingMVC框架簡單配置MVC框架
- VsCode簡單配置VSCode
- webpack(簡單安裝配置)Web
- LINUX FTP簡單配置LinuxFTP
- Redhat 簡單本地yum 配置Redhat
- Windows下Subversion簡單配置Windows
- VSFTP的簡單配置FTP
- Linux NTP 簡單配置Linux
- mysql簡單效能測試MySql
- MySQL簡單最佳化MySql
- MySQL基本簡單操作01MySql
- mysql的簡單基本操作MySql
- 簡單的mysql查詢MySql
- 一個簡單多庫配置
- node webpack4.6簡單配置Web