MySQL NDB Cluster - 윈디하나의 솔라나라
|
root@wl ~/src # wget http://www.mysql.com/get/Downloads/MySQL-Cluster-7.2/mysql-cluster-gpl-7.2.8.tar.gz/from/http://cdn.mysql.com/ root@wl ~/src # tar xvfz mysql-cluster-gpl-7.2.8.tar.gz root@wl ~/src # cd mysql-cluster-gpl-7.2.8 root@wl ~/src/mysql-cluster-gpl-7.2.8 # CC=/usr/sfw/bin/gcc CXX=/usr/sfw/bin/g++ cmake . \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysqlc \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_READLINE=1 \ -DWITH_ZLIB=system 1) root@wl ~/src/mysql-cluster-gpl-7.2.8 # make root@wl ~/src/mysql-cluster-gpl-7.2.8 # cd /root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/unit && /usr/sfw/bin/gcc \ -DHAVE_RWLOCK_T -DHAVE_CONFIG_H -DHAVE_NDB_CONFIG_H -DDEBUG_OUTPUT -Wall -Wredundant-decls -O2 -g -DDBUG_OFF \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/extra/memcached/engines/default_engine -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/include \ -I/root/src/mysql-cluster-gpl-7.2.8/include -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include -I/root/src/mysql-cluster-gpl-7.2.8/sql -I/root/src/mysql-cluster-gpl-7.2.8/regex \ -I/usr/local/include -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/util -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/portlib \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/debugger -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/transporter \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/kernel -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/mgmapi \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/mgmcommon -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/ndbapi \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/include/logger -I/root/src/mysql-cluster-gpl-7.2.8/cmd-line-utils -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/src/ndbjtie/mysql \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/src/ndbapi -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/extra/memcached/include \ -I/root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/extra/memcached -o CMakeFiles/test_workqueue.dir/test_workqueue.c.o \ -c /root/src/mysql-cluster-gpl-7.2.8/storage/ndb/memcache/unit/test_workqueue.c 2) root@wl ~/src/mysql-cluster-gpl-7.2.8 # make root@wl ~/src/mysql-cluster-gpl-7.2.8 # make install root@wl ~/src/mysql-cluster-gpl-7.2.8 # mkdir /usr/local/mysqlc/support-files 3) root@wl ~/src/mysql-cluster-gpl-7.2.8 # cp -R support-files/* /usr/local/mysqlc/support-files1) CFLAGS, CXXFLAGS 를 사용해 컴파일 옵션을 최적화 시킨다. cc의 경우 [CFLAGS="-fast" CXXFLAGS="-fast"] 처럼 주면 최적의 코드를 얻을 수 있다. 더 자세한 내용은 윈디하나의 솔라나라: 솔라리스 C, C++ 컴파일러 (작성중)를 참고하자. gcc를 사용한다면 [-fast] 대신 [-O3 -mtune=native -mfpmath=sse2]와 같은 식으로 변경해야 한다. 자세한 사항은 GCC - 3.17 Hardware Models and Configurations를 참조하자.
root@wl ~/src # wget "http://cdn.mysql.com/Downloads/MySQL-Cluster-7.2/mysql-cluster-gpl-7.2.8-solaris10-i386.tar.gz" root@wl ~/src # cd /usr/local root@wl /usr/local # tar xvfz ~/mysql-cluster-gpl-7.2.8-solaris10-i386.tar.gz root@wl /usr/local # ln -s mysql-cluster-gpl-7.2.8-solaris10-i386 mysqlc소스 설치와 패키지 설치의 디렉토리 구조가 다르고 바이너리나 스크립트의 위치가 다르다. 예를 들어 mysqld 는 소스 설치에서는 mysqlc/libexec 에 있지만 패키지 설치에서는 mysqlc/bin 에 있는 식이다. 위치만 다를 뿐 사용 방법은 같다. 패키지로 설치하는 경우 MySQL Cluster Quick Start Guide를 참고하자. 이 문서는 소스 설치를 기준으로 했다.
root@wl ~ # cd /usr/local/mysqlc root@wl /usr/local/mysqlc # ./bin/mysql_install_db --user=mysql root@wl /usr/local/mysqlc # mkdir ndb_data root@wl /usr/local/mysqlc # mkdir mysql-cluster root@wl /usr/local/mysqlc # mkdir etc root@wl /usr/local/mysqlc # cp support-files/my-medium.cnf etc/my.cnf root@wl /usr/local/mysqlc # vi etc/my.cnf 1) [mysqld] ndbcluster root@wl /usr/local/mysqlc # vi etc/config.ini 2) [NDBD DEFAULT] NoOfReplicas: 2 DataDir: /usr/local/mysqlc/ndb_data [MGM DEFAULT] PortNumber: 1186 DataDir: /usr/local/mysqlc/ndb_data [NDB_MGMD] Id: 1 HostName: localhost [NDBD] Id: 10 HostName: localhost [NDBD] Id: 11 HostName: localhost [API] Id: 20 HostName: localhost1) mysqld 절(clause)에, ndbcluster 를 추가한다. 다른 설정은 그대로 둔다.
root@wl /usr/local/mysqlc # libexec/ndb_mgmd --initial -f etc/config.ini root@wl /usr/local/mysqlc # libexec/ndbd -c localhost:1186 1) root@wl /usr/local/mysqlc # libexec/ndbd -c localhost:1186 root@wl /usr/local/mysqlc # share/mysql/mysql.server start 2) root@wl /usr/local/mysqlc # bin/ndb_mgm -e show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=10 @127.0.0.1 (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master) id=11 @127.0.0.1 (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @127.0.0.1 (mysql-5.1.44 ndb-7.1.4) [mysqld(API)] 1 node(s) id=20 @127.0.0.1 (mysql-5.1.44 ndb-7.1.4) root@wl /usr/local/mysqlc #1) [-c] 뒤에는 ndb_mgmd 의 접속 주소를 적어준다. localhost:1186 은 생략 가능하다.
root@wl /usr/local/mysqlc # bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.44-ndb-7.1.4b-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> status; -------------- bin/mysql Ver 14.14 Distrib 5.1.44-ndb-7.1.4b, for pc-solaris2.10 (x86_64) using EditLine wrapper Connection id: 2 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.1.44-ndb-7.1.4b-log Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql.sock Uptime: 3 min 8 sec Threads: 1 Questions: 4 Slow queries: 0 Opens: 15 Flush tables: 2 Open tables: 0 Queries per second avg: 0.21 -------------- mysql> show status like 'ndb%'; +--------------------------------+-----------+ | Variable_name | Value | +--------------------------------+-----------+ | Ndb_cluster_node_id | 20 | | Ndb_config_from_host | localhost | | Ndb_config_from_port | 1186 | | Ndb_number_of_data_nodes | 2 | | Ndb_number_of_ready_data_nodes | 2 | | Ndb_connect_count | 0 | | Ndb_execute_count | 0 | | Ndb_scan_count | 0 | | Ndb_pruned_scan_count | 0 | | Ndb_cluster_connection_pool | 1 | | Ndb_conflict_fn_max | 0 | | Ndb_conflict_fn_old | 0 | +--------------------------------+-----------+ 12 rows in set (0.01 sec) mysql> create database clusterdb; use clusterdb; Query OK, 1 row affected (0.08 sec) Database changed mysql> create table test1 (id int not null primary key); mysql> alter table test1 ENGINE=NDBCLUSTER; mysql> create table test2 (id int not null primary key) ENGINE=NDBCLUSTER; Query OK, 0 rows affected (0.50 sec) mysql> insert into test2 values (1),(2),(3),(4); Query OK, 4 rows affected (0.08 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql> select * from test2; +----+ | id | +----+ | 1 | | 2 | | 4 | | 3 | +----+ 4 rows in set (0.00 sec) mysql> exit Bye
root@wl /usr/local/mysqlc # share/mysql/mysql.server stop 1)
root@wl /usr/local/mysqlc # bin/ndb_mgm -e shutdown
Connected to Management Server at: localhost:1186
2 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
root@wl /usr/local/mysqlc #
1) 위에서 mysqld 를 직접 실행시켰다면 [bin/mysqladmin -u root -h localhost shutdown] 와 같이 해도 된다.
root@wl ~ # mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.1.44-ndb-7.1.4b-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show plugins; +------------+--------+----------------+---------+---------+ | Name | Status | Type | Library | License | +------------+--------+----------------+---------+---------+ | binlog | ACTIVE | STORAGE ENGINE | NULL | GPL | | partition | ACTIVE | STORAGE ENGINE | NULL | GPL | | CSV | ACTIVE | STORAGE ENGINE | NULL | GPL | | MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL | | MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | ndbcluster | ACTIVE | STORAGE ENGINE | NULL | GPL | | ndbinfo | ACTIVE | STORAGE ENGINE | NULL | GPL | +------------+--------+----------------+---------+---------+ 8 rows in set (0.01 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | clusterdb | | mysql | | ndbinfo | | test | +--------------------+ 5 rows in set (0.00 sec) mysql> use ndbinfo; Database changed mysql> show tables; +-------------------+ | Tables_in_ndbinfo | +-------------------+ | blocks | | config_params | | counters | | logbuffers | | logspaces | | memoryusage | | nodes | | resources | | transporters | +-------------------+ 9 rows in set (0.00 sec) mysql> select * from memoryusage; +---------+--------------+--------+------------+----------+-------------+ | node_id | memory_type | used | used_pages | total | total_pages | +---------+--------------+--------+------------+----------+-------------+ | 10 | Data memory | 458752 | 14 | 83886080 | 2560 | | 10 | Index memory | 180224 | 22 | 19136512 | 2336 | +---------+--------------+--------+------------+----------+-------------+ 2 rows in set (0.13 sec) mysql> select * from nodes; +---------+--------+---------+-------------+ | node_id | uptime | status | start_phase | +---------+--------+---------+-------------+ | 10 | 61 | STARTED | 0 | +---------+--------+---------+-------------+ 1 row in set (0.01 sec) mysql>exit root@wl ~ #
RSS ATOM XHTML 5 CSS3 |
Copyright © 2004-2023 Jo HoSeok. All rights reserved. |