root@wl ~ # tar xvfz mysql-cluster-gpl-7.1.4b.tar.gz root@wl ~ # cd mysql-cluster-gpl-7.1.4b root@wl ~/mysql-cluster-gpl-7.1.4b # CPPFLAGS="-I/usr/local/ssl/include" CFLAGS="-fast" CXXFLAGS="-fast" ./configure \ 1) --prefix=/usr/local/mysqlc \ --with-plugins=max \ --with-ssl=/usr/local/ssl \ --with-charset=utf8 \ --with-extra-charsets=ucs2 root@wl ~/mysql-cluster-gpl-7.1.4b # make root@wl ~/mysql-cluster-gpl-7.1.4b # make install root@wl ~/mysql-cluster-gpl-7.1.4b # mkdir /usr/local/mysqlc/support-files 2) root@wl ~/mysql-cluster-gpl-7.1.4b # cp -R support-files/* /usr/local/mysqlc/support-files1) 아래와 같은 설정이 클러스터를 사용하기 위한 최소 설정이다. gcc를 사용한다면 [-fast] 대신 [-O3 -mtune=native -mfpmath=sse2]와 같은 식으로 변경해야 한다. 자세한 사항은 GCC - 3.17 Hardware Models and Configurations를 참조하자.
CFLAGS="-fast" CXXFLAGS="-fast" ./configure \ --prefix=/usr/local/mysqlc \ --with-plugins=ndbcluster \ --with-charset=utf82) support-files 에는 각종 설정 샘플이 포함되어있다. /usr/local/mysqlc/share/mysql 에 일부가 복사되지만 전부 다 있는건 아니다.
root@wl ~ # cd /usr/local root@wl /usr/local # tar xvfz ~/mysql-cluster-gpl-7.1.4b-solaris10-i386.tar.gz root@wl /usr/local # ln -s mysql-cluster-gpl-7.1.4b-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 ~ #
|
|
Copyright © 2004-2010 Jo HoSeok. All rights reserved. |