• MySQL매뉴얼
    • MySQL 5.6 매뉴얼
    • MySQL 5.1 매뉴얼
    • MySQL 5.0 매뉴얼
    • MySQL HA 매뉴얼
  • 기술문서
    • Xtrabackup 구성
    • 메모리 사용량 모니터링
  • 서비스
    • MySQL유지보수
    • MySQL라이선스
  • 온라인문의
  • 회사소개
  • → 목 록 (MySQL HA 한글메뉴얼) [close]
  • 1. Chapter 리플리케이션
  • 2. Chapter MySQL ndb Cluster
  • 1. MySQL 클러스터 소개
    2. MySQL 클러스터 5.1 캐리어 그래이드 에디션 (Carrier Grade Edition)
    3. 멀티-컴퓨터 설치 방법
    4. MySQL 클러스터 구성 (Configuration)
    5. MySQL 클러스터 업그레이드 및 다운그레이드
    6. MySQL 클러스터 프로세스 관리
    7. MySQL 클러스터 관리
    8. MySQL 클러스터 온-라인 백업
    1. 클러스터 백업 개념
    2. 관리 클라이언트로 백업 생성하기
    3. ndb_restore — 클러스터 백업 리스토어 (Restore)
    4. 클러스터 백업용 구성 (Configuration)
    5. 백업 문제 해결
    9. 클러스터 유틸리티 프로그램
    10. MySQL 클러스터 리플리케이션
    11. MySQL 클러스터 디스크 데이터 테이블
    12. MySQL 클러스터와 함께 고속 인터커넥션 (Interconnection) 사용하기
    13. MySQL 클러스터의 한계

2.8.3. ndb_restore — 클러스터 백업 리스토어 (Restore)

 

클러스터 복구 프로그램은 별도의 명령어-라인 유틸리티인 ndb_restore로 구현되며, 이 프로그램은 MySQL bin 디렉토리에 저장되어 있다. 이 프로그램은 백업의 결과로 생성된 파일을 읽고 저장된 정보를 데이터베이스에 삽입한다.

ndb_restore는 반드시 백업을 생성하기 위해 사용한 START BACKUP 명령어가 생성한 각각의 백업 파일 별로 한번씩 실행해야 한다. 이것은 백업이 생성된 시점에 클러스터에 연결되어 있는 데이터 노드의 수와 같게 된다.

Note: 병렬로 여러 개의 데이터 노드를 복구하지 않는다면, ndb_restore를 사용하기 전에 우선 클러스터를 싱글 유저 모드로 전환할 것을 권장한다.

이 유틸리티의 전형적인 옵션은 다음과 같다:

 

ndb_restore [-c connectstring] -n node_id [-s] [-m] -b backup_id -r [backup_path=]/path/to/backup/files [-e]

 

-c 옵션은 ndb_restore에게 클러스터 관리 서버의 위치를 알려주는 커넥트스트링을 지정하기 위해 사용한다. 이 옵션을 사용하지 않으면, ndb_restore는 localhost:1186에 존재하는 관리 서버에 연결을 시도한다. 이 유틸리티는 클러스터 API 노드 형태로 동작하기 때문에, 클러스터 관리 서버에 연결하기 위해서는 사용 가능한 연결 ‘슬롯”을 요구하게 된다. 이것은 config.ini 파일 안에는 반드시 이 유틸리티가 사용할 수 있는 [API] 또는 [MYSQLD] 섹션이 최소한 하나 존재해야 한다는 것을 의미한다. 이러한 까닭으로, config.ini 파일 안에는 MySQL 서버 또는 다른 어플리케이션이 사용하지 않는 빈 [API] 또는 [MYSQLD] 섹션을 최소한 한 개 정도는 가지고 있는 것이 좋다.

ndb_mgm 관리 클라이언트에서 SHOW 명령어를 사용하면 ndb_restore가 클러스터에 연결되었는지를 확인할 수 있다. 또한, 시스템 쉘에서 다음과 같이 명령어를 실행해서도 확인이 가능하다:

 

shell> ndb_mgm -e "SHOW"

 

-n은 백업이 일어난 데이터 노드의 ID를 가리키는 것이다.

ndb_restore 복구 프로그램을 처음으로 구동할 때에는 메타데이터도 함께 복구를 해야 한다. 다른 말로 설명하자면, 반드시 데이터베이스 테이블을 다시 생성해야 한다는 것이다 — 프로그램을 -m 옵션으로 구동 시키면 된다. 백업 복구를 시작하기 위해서는 클러스터가 반드시 하나의 빈 데이터베이스를 가지고 있어야 한다는 점을 알아두도록 하자. (즉, 복구를 실행하기 전에 반드시 ndbd를 --initial 옵션으로 구동 시킨다. 또한, 데이터 노드의 DataDir에 존재하는 디스크 데이터 파일을 모두 수동으로 제거하도록 한다.)

테이블 메타데이터를 복구하지 않은 채로 데이터를 복구하는 것은 가능하다. MySQL 5.1.17 이전에는, ndb_restore가 테이블 스키마에 대해서는 어떠한 검사도 실행하지 않았다; 백업이 실행된 시점과 ndb_restore가 구동된 시점 사이에서 테이블이 변경되었다면, ndb_restore는 변경된 테이블에 대해서 데이터를 복구하려는 시도록 계속하게 된다.

MySQL 5.1.17 버전부터는, 테이블 데이터가 테이블 스키마와 일치하지 않으면 디폴트로 ndb_restore가 실패한다; 이것은 --skip-table-check 또는 -s 옵션으로 무시할 수 있다. 이 옵션을 사용하면, ndb_restore는 현재 존재하는 테이블 스키마에 맞게 데이터를 조정한다.

-b 옵션은 ID 또는 백업 시퀀스 번호를 지정하는데 사용하며, 이것은 백업이 완료된 시점에 나오는 Backup backup_id completed 메시지에 들어 있는 번호와 같게 된다.

-e는 클러스터 리플리케이션 상태 테이블에 에포크 (epoch) 정보를 추가한다. 이것은 MySQL 클러스터 리플리케이션 슬레이브에서 리플리케이션을 시작할 때 유용하게 사용할 수 있다. 이 옵션을 사용하면, id 컬럼에서 0값을 가지고 있는 mysql.ndb_apply_status 열은 업데이트가 된다; 이러한 열이 없다면 하나가 삽입된다.

백업 디렉토리 경로 및 복구되어야 하는 백업의 ID에 해당하는 서브 디렉토리도 반드시 제공되어야 한다. 예를 들면, 데이터 노드의 DataDir이 /var/lib/mysql-cluster라면, 백업 디렉토리는 /var/lib/mysql-cluster/BACKUP가 되고, ID 3을 사용하는 백업용 파일은 /var/lib/mysql-cluster/BACKUP/BACKUP-3에 존재한다. 경로는 절대 경로가 되거나 또는 ndb_restore가 존재하는 디렉토리에 관련될 수 있으며, 선택적으로 backup_path=를 사용할 수 있다.

Important

클러스터 백업을 복구하는 경우에는, 반드시 동일 백업 ID를 가지고 있는 백업본에서 모든 데이터 노드를 복구해야 한다.

이 프로그램에서 사용할 수 있는 옵션들은 다음과 같다:

 

Long Form

Short Form

Description

Default Value

--backup-id

-b

Backup sequence ID

0

--backup_path

None

Path to backup files

./

--character-sets-dir

None

Specify the directory where character set information can be found

None

--connect, --connectstring, or --ndb-connectstring

-c or -C

Set the connectstring in [nodeid=node_id;][host=]host[:port] format

localhost:1186

--core-file

None

Write a core file in the event of an error

TRUE

--debug

-#

Output debug log

d:t:O,/tmp/ndb_restore.trace

--dont_ignore_systab_0

-f

Do not ignore system table during restore — EXPERIMENTAL; not for production use

FALSE

--help or –usage

-?

Display help message with available options and current values, then exit

[N/A]

--ndb-mgmd-host

None

Set the host and port in host[:port] format for the management server to connect to; this is the same as --connect, --connectstring, or --ndb-connectstring, but without a way to specify the nodeid

None

--ndb-nodegroup-map

-z

Specifies a nodegroup map — Syntax: list of (source_nodegroup, destination_nodegroup)

None

--ndb-nodeid

None

Specify a node ID for the ndb_restore process

0

--ndb-optimized-node-selection

None

Optimize selection of nodes for transactions

TRUE

--ndb-shm

None

Use shared memory connections when available

FALSE

--no-restore-disk-objects

-d

Do not restore disk data object such as tablespaces and log file groups

FALSE (in other words, restore disk data object unless this option is used)

--nodeid

-n

Use backup files from node with the specified ID

0

--parallelism

-p

Set from 1 to 1024 parallel transactions to be used during the restoration process

128

--print

None

Print metadata and log to stdout

FALSE

--print_data

None

Print data to stdout

FALSE

--print_log

None

Print log to stdout

FALSE

--print_meta

None

Print metadata to stdout

FALSE

--restore_data

-r

Restore data and logs

FALSE

--restore_epoch

-e

Restore epoch data into the status table; the row in the cluster.apply_status having the id 0 is inserted or updated as appropriate — this is convenient when starting up replication on a MySQL cluster replication slave

FALSE

--restore_meta

-m

Restore table metadata

FALSE

--skip-table-check

-s

Do not check table schemas (Added in MySQL 5.1.17; not supported in MySQL cluster 5.1Carrier Grade Edition

FALSE

--version

-V

Output version information and exit

[N/A]

 

MySQL 5.1.18 버전부터는 별도의 옵션들이 추가되었다:

 

Long Form

Short Form

Description

Default Value

--tab

-T

Creates dumpfiles, one per table, each named tbl_name.txt. Takes as its argument the path to the directory where the files should be saved (required; use . for the current directory).

None

--fields-enclosed-by

None

String used to enclose all column values

None

--fields-optionally-enclosed-by

None

String used to enclose column values containing character data (such as CHAR, VARCHAR, BINARY, TEXT, or ENUM)

None

--fields-terminated-by

None

String used to separate column values

\t (tab character)

--hex

None

Use hex format for binary values

[N/A]

--lines-terminated-by

None

String used to terminate each line

\n (linefeed character)

--appends

None

When used with --tab, causes the data to be appended to existing files of the same name

[N/A]

 

Note

테이블에 프라이머리 키가 존재하지 않는다면, --print를 사용할 때 생성된 결과에는 테이블의 히든 (hidden) 프라이머리 키가 포함된다.

MySQL 5.1.18 버전부터는 아래와 같은 신텍스를 사용해서 주어진 데이터베이스로부터 선택한 데이터베이스를 복구하거나, 또는 선택한 테이블을 복구하는 것이 가능해졌다:

 

ndb_restore other_options db_name_1 [db_name_2[, db_name_3][, ...] | tbl_name_1[, tbl_name_2][, ...]]

 

즉, 복구를 할 때 아래의 두 가지 중의 하나를 지정할 수 있다:

  • 하나 또는 그 이상의 데이터베이스로부터 모든 테이블 선택
  • 싱글 데이터베이스로부터 하나 또는 그 이상의 테이블 선택

Note: ndb_restore는 임시 에러 및 영구 에러를 모두 보고한다.

서울시 강남구 영동대로 602 6층  TEL: 02-6061-0006
주식회사 이노클러스터  등록번호 : 727-86-02261
Copyright © innocluster Co. ltd. all rights reserved