MySQL-Cluster7.3.6-2 rpm安裝

Michael_DD發表於2014-10-16
管理 (MGM)節點 : 這類節點的作用是管理 MySQL 叢集內的其他節點,如提供配置資料、啟動並停止節點、執行備份等。由於這類節點負責管理其他節點的配置,應在啟動其             他          節點之前首先啟動這類節點。
資料節點:   這類節點用於儲存叢集的資料。資料節點的數目與副本的數目相關,是片段的倍數。例如,對於兩個副本,每個副本有兩個片段,那麼就有 4 個資料節點。
SQL  節點:  這是用來訪問叢集資料的節點。對於 MySQL 叢集,客戶端節點是使用 NDB 叢集儲存引擎的傳統 MySQL 伺服器。

#所有節點:
#mysql的叢集安裝可以有三種方式,一是直接下載二進位制使用,二是使用rpm安裝,三是原始碼編譯。
#這裡使用rpm安裝,每種安裝方式略有不同。
#rpm包安裝注意安裝後的命令目錄

管理節點:
192.168.9.142
儲存節點:
192.168.9.143
192.168.9.144
sql節點:
192.168.9.145
192.168.9.146


#下載:
MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar

#清除原理機器上的mysql:
rpm -e --nodeps mysql-server-5.1.66-2.el6_3.x86_64
rpm -e --nodeps mysql-devel-5.1.66-2.el6_3.x86_64
rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64
rpm -e --nodeps mysql-5.1.66-2.el6_3.x86_64
rpm -qa mysql*


#解壓包:
cd /tmp
tar -xvf MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar

#增加使用者:
userdel mysql
groupadd mysql
useradd mysql -g mysql

#libaio包安裝
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm



管理節點:
cd /tmp
[root@nagiosmysql1 tmp]# rpm -ivh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-Cluster-server-gp########################################### [100%]


#建立管理節點日誌目錄
mkdir /var/lib/mysql-cluster
chmod -R 1777 /var/lib/mysql-cluster



vi /var/lib/mysql-cluster/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]
portnumber=3306

[NDB_MGMD]
#設定管理節點伺服器
                                      
nodeid=1                              # Management process option                            
HostName=192.168.9.142                # Hostname or IP address of MGM node  
DataDir=/var/lib/mysql-cluster        # Directory for MGM node log files

[NDBD]
id=2                                 # Options for data node "A"  (one [ndbd] section per data node)
HostName=192.168.9.143               # Hostname or IP address
DataDir=/var/mysql/data          # Directory for this data node's data files                    

[NDBD]
id=3                                # Options for data node "B"  (one [ndbd] section per data node)
HostName=192.168.9.144              # Hostname or IP address
DataDir=/var/mysql/data         # Directory for this data node's data files    

[MYSQLD]                                  
id=4                               # SQL node options:
HostName=192.168.9.145             # Hostname or IP address  
                                   # (additional mysqld connections can be  
                                   # specified for this node for various  
                                   # purposes such as running ndb_restore)  
                        
[MYSQLD]                                   
id=5                               # SQL node options:
HostName=192.168.9.146             # Hostname or IP address  
                                   # (additional mysqld connections can be  
                                   # specified for this node for various  
                                   # purposes such as running ndb_restore)  

#必須有空的mysqld節點,不然資料節點斷開後啟動有報錯
[MYSQLD]
id=6
[mysqld]
id=7


#啟動管理節點
[root@nagiosmysql1 tmp]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.6.19 ndb-7.3.6
[root@nagiosmysql1 tmp]# 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.9.143  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=3    @192.168.9.144  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.9.142  (mysql-5.6.19 ndb-7.3.6)

[mysqld(API)]   4 node(s)
id=4 (not connected, accepting connect from 192.168.9.145)
id=5 (not connected, accepting connect from 192.168.9.146)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)





#儲存節點:
#安裝MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm包
cd /tmp
rpm -ivh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
rpm -qa| grep MySQL-Cluster-server

#建立儲存目錄
mkdir -p /var/mysql/data
chmod -R 1777 /var/mysql/data

#建立資料字典
[root@nagiosmysql2 tmp]# cd /usr/bin
[root@nagiosmysql2 bin]# ll | grep mysql
-rwxr-xr-x  1 root root      11608 7月   2 17:43 mysqlbug
-rwxr-xr-x  1 root root       4334 7月   2 17:43 mysql_convert_table_format
-rwxr-xr-x  1 root root      26356 7月   2 17:43 mysqld_multi
-rwxr-xr-x  1 root root      24691 7月   2 17:43 mysqld_safe
-rwxr-xr-x  1 root root       7424 7月   2 17:43 mysqldumpslow
-rwxr-xr-x  1 root root       1366 7月   2 17:43 mysql_fix_extensions
-rwxr-xr-x  1 root root      34852 7月   2 17:43 mysqlhotcopy
-rwxr-xr-x  1 root root      33889 7月   2 17:43 mysql_install_db
-rwxr-xr-x  1 root root    4971663 7月   2 17:44 mysql_plugin
-rwxr-xr-x  1 root root      10106 7月   2 17:43 mysql_secure_installation
-rwxr-xr-x  1 root root      17572 7月   2 17:43 mysql_setpermission
-rwxr-xr-x  1 root root    9546860 7月   2 17:45 mysqltest
-rwxr-xr-x  1 root root    4513946 7月   2 17:43 mysql_tzinfo_to_sql
-rwxr-xr-x  1 root root    5147706 7月   2 17:44 mysql_upgrade
-rwxr-xr-x  1 root root       3976 7月   2 17:43 mysql_zap

[root@nagiosmysql2 bin]# mysql_install_db --user=mysql --datadir=/var/mysql/data
WARNING: The host 'nagiosmysql2' could not be looked up with /usr/bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !

Installing MySQL system tables...2014-10-16 10:49:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-10-16 10:49:50 1065 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-10-16 10:49:50 1065 [Note] InnoDB: The InnoDB memory heap is disabled
2014-10-16 10:49:50 1065 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-10-16 10:49:50 1065 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-10-16 10:49:50 1065 [Note] InnoDB: Using Linux native AIO
2014-10-16 10:49:50 1065 [Note] InnoDB: Using CPU crc32 instructions
2014-10-16 10:49:50 1065 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-10-16 10:49:50 1065 [Note] InnoDB: Completed initialization of buffer pool
2014-10-16 10:49:50 1065 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-10-16 10:49:50 1065 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-10-16 10:49:50 1065 [Note] InnoDB: Database physically writes the file full: wait...
2014-10-16 10:49:51 1065 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-10-16 10:49:56 1065 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-10-16 10:50:02 1065 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-10-16 10:50:02 1065 [Warning] InnoDB: New log files created, LSN=45781
2014-10-16 10:50:02 1065 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-10-16 10:50:02 1065 [Note] InnoDB: Doublewrite buffer created
2014-10-16 10:50:02 1065 [Note] InnoDB: 128 rollback segment(s) are active.
2014-10-16 10:50:03 1065 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-10-16 10:50:03 1065 [Note] InnoDB: Foreign key constraint system tables created
2014-10-16 10:50:03 1065 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-10-16 10:50:03 1065 [Note] InnoDB: Tablespace and datafile system tables created.
2014-10-16 10:50:03 1065 [Note] InnoDB: Waiting for purge to start
2014-10-16 10:50:03 1065 [Note] InnoDB: 5.6.19 started; log sequence number 0
2014-10-16 10:50:17 1065 [Note] Binlog end
2014-10-16 10:50:17 1065 [Note] InnoDB: FTS optimize thread exiting.
2014-10-16 10:50:17 1065 [Note] InnoDB: Starting shutdown...
2014-10-16 10:50:18 1065 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-10-16 10:50:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-10-16 10:50:18 1120 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-10-16 10:50:18 1120 [Note] InnoDB: The InnoDB memory heap is disabled
2014-10-16 10:50:18 1120 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-10-16 10:50:18 1120 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-10-16 10:50:18 1120 [Note] InnoDB: Using Linux native AIO
2014-10-16 10:50:18 1120 [Note] InnoDB: Using CPU crc32 instructions
2014-10-16 10:50:18 1120 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-10-16 10:50:18 1120 [Note] InnoDB: Completed initialization of buffer pool
2014-10-16 10:50:18 1120 [Note] InnoDB: Highest supported file format is Barracuda.
2014-10-16 10:50:18 1120 [Note] InnoDB: 128 rollback segment(s) are active.
2014-10-16 10:50:18 1120 [Note] InnoDB: Waiting for purge to start
2014-10-16 10:50:18 1120 [Note] InnoDB: 5.6.19 started; log sequence number 1625977
2014-10-16 10:50:19 1120 [Note] Binlog end
2014-10-16 10:50:19 1120 [Note] InnoDB: FTS optimize thread exiting.
2014-10-16 10:50:19 1120 [Note] InnoDB: Starting shutdown...
2014-10-16 10:50:20 1120 [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:

  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h nagiosmysql2 password 'new-password'

Alternatively you can run:

  /usr/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 /usr ; /usr/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

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

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




#建立my.cnf配置檔案
vi /etc/my.cnf
[CLIENT]
socket=/var/mysql/mysql.sock

[MYSQLD]
datadir=/var/mysql/data
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin = /var/mysql/log/mysql-bin.log
max_connections=1000

#執行NDB儲存引擎
#指定管理節點
ndbcluster
ndb-connectstring=192.168.9.142

[MYSQL_CLUSTER]
ndb-connectstring=192.168.9.142
[NDB_MGM]
connect-string=192.168.9.142

[MYSQLD_SAFE]
log-error=/var/mysql/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



啟動ndbd服務
ndbd服務第一次啟動時需要加上--initial選項,以後不需要
ndbd --initial






sql節點:
#安裝server包和client包
cd /tmp
rpm -ivh MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm
rpm -ivh MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm

mkdir -p /var/run/mysqld/

chmod -R 777 /var/run/mysqld/


#安裝資料庫
cd /usr/bin
mysql_install_db --user=mysql --datadir=/var/mysql/data
啟動SQL節點

mysqld_safe --user=mysql &

注意順序。

1. 啟動管理節點:ndb_mgmd -f /var/lib/mysql-cluster/config.ini

2. 啟動儲存節點:ndbd --initial

   初次啟動時需要加--initial引數,以後只需要執行ndbd即可;

3. 啟動SQL節點:nohup mysqld_safe --explicit_defaults_for_timestamp &

 

最後結果:失敗。
在管理節點上show資訊:偶爾出現45連線,偶爾出現46連線,並且45,46上開啟資料庫時間非常長。
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.9.143  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=3    @192.168.9.144  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.9.142  (mysql-5.6.19 ndb-7.3.6)

[mysqld(API)]   4 node(s)
id=4    @192.168.9.145  (mysql-5.6.19 ndb-7.3.6)
id=5 (not connected, accepting connect from 192.168.9.146)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)

ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @192.168.9.143  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=3    @192.168.9.144  (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.9.142  (mysql-5.6.19 ndb-7.3.6)

[mysqld(API)]   4 node(s)
id=4 (not connected, accepting connect from 192.168.9.145)
id=5    @192.168.9.146  (mysql-5.6.19 ndb-7.3.6)
id=6 (not connected, accepting connect from any host)
id=7 (not connected, accepting connect from any host)

徹底無語的結果。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1300700/,如需轉載,請註明出處,否則將追究法律責任。

相關文章