2.3.3. 멀티-컴퓨터 구성 (Configuration)
4-노드, 4-호스트 MySQL 클러스터의 경우에는, 각 노드 호스트 별로 하나씩 4개의 구성 파일을 작성해야 한다.
-
각각의 데이터 노드 또는 SQL 노드는 my.cnf 파일이 필요하며, 이 파일은 두 개의 정보를 제공한다: 커넥트스트링 (connectstring)은 MGM 노드가 어디에 있는지를 알려주며, 라인 (line)은 이 호스트 (데이터 노드가 설치된 머신)에서 MySQL 서버가 NDB 모드를 실행하도록 한다.
-
관리 노드는 config.ini 파일을 요구하며, 이것은 관리해야 하는 리플리카 (replica)의 숫자가 몇 개이고, 각 데이터 노드에서 데이터 및 인덱스용으로 얼마나 많은 메모리를 할당해야 하는지, 데이터 노드가 어디에 있는지, 어느 데이터 노드의 디스크에 데이터를 저장해야 하는지, 그리고 SQL 노드를 어디에서 찾아야 하는지를 알려준다.
스토리지 및 SQL 노드 구성하기
데이터 노드용으로 필요한 my.cnf 파일은 매우 간단하다. 구성 파일은 반드시 /etc 디렉토리에 있어야 하고 텍스트 에디터를 사용해서 편집하도록 한다. 예를 들면:
shell> vi /etc/my.cnf
여기에서는 vi 에디터를 사용하여 파일을 편집하였지만, 이외의 다른 에디터를 사용할 수 있을 것이다.
본 예제에 나와 있는 각각의 데이터 노드 및 SQL 노드의 경우, my.cnf 파일은 다음과 같이 보일 것이다:
# Options for mysqld process:
[MYSQLD]
ndbcluster # run NDB storage engine
ndb-connectstring=192.168.0.10 # location of management server
# Options for ndbd process:
[MYSQL_CLUSTER]
ndb-connectstring=192.168.0.10 # location of management server
위의 정보를 입력하고 파일을 저장한 후에 에디터를 빠져 나온다. 위의 단계를 데이터 노드 “A”, 데이터 노드 “B”, 그리고 SQL 노드 호스트에서 각각 실행한다.
Important: 위와 같이 my.cnf 파일의 [MYSQLD] 섹션에 있는 ndbcluster 및 ndb-connectstring 파라미터와 함께 mysqld 프로세스를 시작하게 되면, 클러스터를 실제로 구동하지 않은 상태에서는 어떠한 CREATE TABLE 또는 ALTER TABLE 명령문도 실행할 수 없게 된다. 클러스터를 실행하지 않은 상태에서 이러한 명령문을 실행하면 에러와 함께 실패하게 된다.
관리 노드 구성하기
MGM 노드를 구성하는 첫 단계는, 구성 파일이 저장될 디렉토리를 생성한 후에 구성 파일을 생성하는 것이다. 예를 들면 (root 사용자로 구동):
shell> mkdir /var/lib/mysql-cluster
shell> cd /var/lib/mysql-cluster
shell> vi config.ini
위에서 생성된 config.ini 파일은 다음과 같은 내용을 가지게 된다:
# Options affecting ndbd processes on all data nodes:
[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.
# TCP/IP options:
[TCP DEFAULT]
portnumber=2202 # This the default; however, you can use any
# port that is free for all the hosts in the cluster
# Note: It is recommended that you do not specify the
# portnumber at all and allow the default value to be
# used instead
# Management process options:
[NDB_MGMD]
hostname=192.168.0.10 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
# Options for data node "A":
[NDBD]
# (one [NDBD] section per data node)
hostname=192.168.0.30 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# Options for data node "B":
[NDBD]
hostname=192.168.0.40 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
# SQL node options:
[MYSQLD]
hostname=192.168.0.20 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
(Note: world 데이터베이스는 http://dev.mysql.com/doc/의 “Example”에서 다운로드할 수 있다.)
모든 구성 파일을 생성하고 최소 옵션을 지정하였다면, 클러스터를 시작해서 모든 프로세스를 구동시킬 준비가 된 것이다.