1、環境描述 一臺 10.0.0.201 SQL節點、管理節點 一臺 10.0.0.202 做一個數據節點 一臺 10.0.0.203做一個數據節點 2、安裝Mysql_custter 在MGM管理節點、SQL節點、NDB節點執行同一操作 #:groupadd mysql #: useradd mysql -g mysql -s /sbin/nologin #: tar –xvf mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23.tar.gz #:mv mysql-cluster-gpl-7.1.15-linux-x86_64-glibc23 /usr/local/mysql_cluster #:vim /etc/profile MYSQL_CLUSTER=/usr/local/mysql_cluster/bin PATH=$PATH:$HOME/bin:$MYSQL_CLUSTER export PATH #: source /etc/profile 3、安裝MGM管理節點 #:mkdir -p /opt/mgm/logs #:mkdir /opt/conf #:vim /opt/conf/config.ini # Options affecting ndbd processes on all home/data nodes: [ndbd default] NoOfReplicas=2 #每個數據節點的鏡像數量 DataMemory=200M #每個數據節點中給數據分配的內存 IndexMemory=18M #每個數據節點中給索引分配的內存 MaxNoOfAttributes=999999 MaxNoOfConcurrentTransactions=10240 LogLevelStatistic=15 LogLevelCheckpoint=15 LogLevelConnection=15 LogLevelError=15 LogLevelInfo=15 [ndb_mgmd] NodeId=1 Hostname=10.0.0.201 Datadir=/opt/mgm/logs LogDestination=FILE:filename=ndb_1_cluster.log,maxsize=10000000,maxfiles=6 ArbitrationRank=0 [ndbd] NodeId=10 Hostname=10.0.0.202 Datadir=/opt/db2/data #管理節點數據(日誌)目錄 backupdatadir=/opt/db2/databak #管理節點數據(日誌)目錄的備份 [ndbd] NodeId=11 Hostname=10.0.0.203 Datadir=/opt/db3/data #管理節點數據(日誌)目錄 backupdatadir=/opt/db3/databak #管理節點數據(日誌)目錄的備份 [mysqld] NodeId=20 [api] [api] [api] [api] [api] 啓動管理節點:ndb_mgmd -f /opt/conf/config.ini --configdir=/opt/conf/ 4、安裝NDB管理節點 在202上 #:mkdir -p /opt/db2/data && mkdir /opt/db2/databak #:mkdir /opt/conf #:vim /opt/conf/my.cnf [mysqld] ndbcluster ndb-connectstring=10.0.0.201 [mysql_cluster] ndb-connectstring=10.0.0.201 在203上 #:mkdir -p /opt/db3/data && mkdir /opt/db3/databak #:mkdir /opt/conf #:vim /opt/conf/my.cnf [mysqld] ndbcluster ndb-connectstring=10.0.0.201 [mysql_cluster] ndb-connectstring=10.0.0.201 啓動NDB節點 安裝後第一次啓動數據節點時要加上--initial參數,其它時候不要加,除非是在備份、恢復 配置變化後重啓時 #: ndbd --defaults-file=/opt/conf/my.cnf --initial 5、安裝SQL節點 #:groupadd mysql #: useradd mysql –g mysql –s /sbin/nologin #: mkdir -p /dbdata/data && chown mysql:mysql /dbdata/data #:cp /usr/local/mysql_cluster/support-files/mysql.server /etc/init.d/mysql #:vim /etc/init.d/mysql basedir=/usr/local/mysql_cluster datadir=/dbdadta/data #:vim /usr/local/mysql_cluster/my.cnf # Options for mysqld process: [mysqld] max_connections=200000 datadir=/dbdata/data/ log-error=/var/log/mysqld.log port=3307 socket=/tmp/mysql.sock character-set-server=utf8 default-storage-engine=ndbcluster server-id=20 ndbcluster # run NDB storage engine ndb-connectstring=10.0.0.201 ndb-force-send=1 ndb-use-exact-count=0 ndb-extra-logging=1 ndb-autoincrement-prefetch-sz=512 #engine-condition-pushdown=1 ndb-cluster-connection-pool=1 key_buffer_size=16M max_allowed_packet=10M sort_buffer_size=256K read_buffer_size=128K read_rnd_buffer_size=256K #table_lock_wait_timeout=16 memlock sysdate_is_now thread-cache-size=512 table-open_cache=512 max_prepared_stmt_count=24576 lower-case-table-names=0 # Timeout interactive_timeout=43200 wait_timeout=43200 connect_timeout=60 skip-name-resolve [ndbd] connect-string=10.0.0.202 [ndbd_mgm] connect-string=10.0.0.201 [mysql_cluster] ndb-connectstring=10.0.0.201 # location of management server #:初始化 #cd /usr/local/mysql_cluster/scripts/ #./mysql_install_db --user=mysql --basedir=/usr/local/mysql_cluster/ --datadir=/dbdata/data/ 常見報錯: Installing MySQL system tables.../usr/local/mysql_cluster//bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 解決辦法:#: yum -y install libaio 啓動SQL節點 #:/etc/init.d/mysqld start 如果SQL啓動失敗。請保持虛擬機或者真實機的內存至少500M以上 6、測試與常見問題 啓動順序 MGM-->NDB-->SQL 關閉順序 關閉 SQL-->MGM (NDB) 當關閉掉MGM後。NDB也會停掉 關閉MGM ndb_mgm -e shutdown 測試: ndb_mgm -e show
mysql cluster
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.