Maria DB Galera Cluster 구성
OS : Ubuntu 16.04 (실 서비스 테스트를 위해 공인 IP 로 진행)
노드 1 : 45.114.128.225
노드 2 : 45.114.128.226
1. 노드 1/2 패키지 설치(공통)
root@mysql2:/# apt install mariadb-server
2. 환경 설정 : 노드 1 설정
root@mysql1:/etc/mysql/conf.d# vi /etc/mysql/my.cnf
[galera]
wsrep_on=ON binlog_format=row default_storage_engine=InnoDB innodb_flush_log_at_trx_commit=0 innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 wsrep_provider_options="gcache.size=512M" innodb_buffer_pool_size=122M
##libgalera_smm.so의 위치 wsrep_provider=/usr/lib/galera/libgalera_smm.so
##클러스터에 참여할 서버 ip list
#cluster 구성 후 수정 #wsrep_cluster_address="gcomm://45.114.128.225,45.114.128.226"
#cluster 최초 구성시
wsrep_cluster_address="gcomm://" ##Galera Culster 이름, 모두 동일 wsrep_cluster_name=cluster
##node의 자신의 ip wsrep_node_address=45.114.128.225
##node의 이름 wsrep_node_name=mysql1
##data 복제 방법 여기서는 rsync wsrep_sst_method=rsync
##rsync 복제시 사용할 user/password wsrep_sst_auth=root:패스워드
#디버깅 로그 wsrep_debug=ON
#충돌 로그 설정 wsrep_log_conflicts=ON
3. 환경 설정 : 노드 2
노드 1과 동일한 설정에서 wsrep_cluster_address , node_address, node_name 수정
[galera]
wsrep_on=ON binlog_format=row default_storage_engine=InnoDB innodb_flush_log_at_trx_commit=0 innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 wsrep_provider_options="gcache.size=512M" innodb_buffer_pool_size=122M
##libgalera_smm.so의 위치 wsrep_provider=/usr/lib/galera/libgalera_smm.so
##클러스터에 참여할 서버 ip list
#cluster 구성 wsrep_cluster_address="gcomm://45.114.128.225,45.114.128.226"
##Galera Culster 이름, 모두 동일 wsrep_cluster_name=cluster
##node의 자신의 ip wsrep_node_address=45.114.128.226
##node의 이름 wsrep_node_name=mysql2
##data 복제 방법 여기서는 rsync wsrep_sst_method=rsync
##rsync 복제시 사용할 user/password wsrep_sst_auth=root:패스워드
#디버깅 로그 wsrep_debug=ON
#충돌 로그 설정 wsrep_log_conflicts=ON
4. 신규 cluster 구성 시작
a. 노드 1
root@mysql1:/etc/mysql/conf.d# service mysql start --wsrep-new_cluster
b. 노드 2 (노드 1 구동 완료 후)
root@mysql2:/etc/mysql/conf.d# service mysql start
5. cluster 확인
a. 노드 1 :
MariaDB [(none)]> show status like 'wsrep%'; +------------------------------+-----------------------------------------+ | Variable_name | Value | +------------------------------+-----------------------------------------+ | wsrep_apply_oooe | 0.000000 | | wsrep_apply_oool | 0.000000 | | wsrep_apply_window | 1.000000 | | wsrep_causal_reads | 0 | | wsrep_cert_deps_distance | 1.000000 | | wsrep_cert_index_size | 32 | | wsrep_cert_interval | 0.000000 | | wsrep_cluster_conf_id | 2 | | wsrep_cluster_size | 2 | | wsrep_cluster_state_uuid | 9508b17c-93c1-11e8-b35c-770911e90bd1 | | wsrep_cluster_status | Primary | | wsrep_commit_oooe | 0.000000 | | wsrep_commit_oool | 0.000000 | | wsrep_commit_window | 1.000000 | | wsrep_connected | ON | | wsrep_desync_count | 0 | | wsrep_evs_delayed | | | wsrep_evs_evict_list | | | wsrep_evs_repl_latency | 0/0/0/0/0 | | wsrep_evs_state | OPERATIONAL | | wsrep_flow_control_paused | 0.000000 | | wsrep_flow_control_paused_ns | 18413226 | | wsrep_flow_control_recv | 6 | | wsrep_flow_control_sent | 0 | | wsrep_gcomm_uuid | 9507e5a3-93c1-11e8-a8a1-133da93ca3a5 | | wsrep_incoming_addresses | 45.114.128.225:3306,45.114.128.226:3306 | | wsrep_last_committed | 632 | | wsrep_local_bf_aborts | 0 | | wsrep_local_cached_downto | 1 | | wsrep_local_cert_failures | 0 | | wsrep_local_commits | 3 | | wsrep_local_index | 0 | | wsrep_local_recv_queue | 0 | | wsrep_local_recv_queue_avg | 0.005051 | | wsrep_local_recv_queue_max | 2 | | wsrep_local_recv_queue_min | 0 | | wsrep_local_replays | 0 | | wsrep_local_send_queue | 0 | | wsrep_local_send_queue_avg | 0.002222 | | wsrep_local_send_queue_max | 2 | | wsrep_local_send_queue_min | 0 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_local_state_uuid | 9508b17c-93c1-11e8-b35c-770911e90bd1 | | wsrep_protocol_version | 8 | | wsrep_provider_name | Galera | | wsrep_provider_vendor | Codership Oy <info@codership.com> | | wsrep_provider_version | 25.3.23(r3789) | | wsrep_ready | ON | | wsrep_received | 198 | | wsrep_received_bytes | 122338 | | wsrep_repl_data_bytes | 250017 | | wsrep_repl_keys | 914 | | wsrep_repl_keys_bytes | 17968 | | wsrep_repl_other_bytes | 0 | | wsrep_replicated | 444 | | wsrep_replicated_bytes | 298032 | | wsrep_thread_count | 2 | +------------------------------+-----------------------------------------+

b. 노드 2
MariaDB [(none)]> show status like 'wsrep_%'; +------------------------------+-----------------------------------------+ | Variable_name | Value | +------------------------------+-----------------------------------------+ | wsrep_apply_oooe | 0.000000 | | wsrep_apply_oool | 0.000000 | | wsrep_apply_window | 1.000000 | | wsrep_causal_reads | 0 | | wsrep_cert_deps_distance | 1.000000 | | wsrep_cert_index_size | 32 | | wsrep_cert_interval | 0.000000 | | wsrep_cluster_conf_id | 2 | | wsrep_cluster_size | 2 | | wsrep_cluster_state_uuid | 9508b17c-93c1-11e8-b35c-770911e90bd1 | | wsrep_cluster_status | Primary | | wsrep_commit_oooe | 0.000000 | | wsrep_commit_oool | 0.000000 | | wsrep_commit_window | 1.000000 | | wsrep_connected | ON | | wsrep_desync_count | 0 | | wsrep_evs_delayed | | | wsrep_evs_evict_list | | | wsrep_evs_repl_latency | 0/0/0/0/0 | | wsrep_evs_state | OPERATIONAL | | wsrep_flow_control_paused | 0.000000 | | wsrep_flow_control_paused_ns | 18638401 | | wsrep_flow_control_recv | 6 | | wsrep_flow_control_sent | 6 | | wsrep_gcomm_uuid | a328229e-93c1-11e8-9df1-ef269fdc71fa | | wsrep_incoming_addresses | 45.114.128.225:3306,45.114.128.226:3306 | | wsrep_last_committed | 632 | | wsrep_local_bf_aborts | 0 | | wsrep_local_cached_downto | 1 | | wsrep_local_cert_failures | 0 | | wsrep_local_commits | 11 | | wsrep_local_index | 1 | | wsrep_local_recv_queue | 0 | | wsrep_local_recv_queue_avg | 1.791574 | | wsrep_local_recv_queue_max | 24 | | wsrep_local_recv_queue_min | 0 | | wsrep_local_replays | 0 | | wsrep_local_send_queue | 0 | | wsrep_local_send_queue_avg | 0.005128 | | wsrep_local_send_queue_max | 2 | | wsrep_local_send_queue_min | 0 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_local_state_uuid | 9508b17c-93c1-11e8-b35c-770911e90bd1 | | wsrep_protocol_version | 8 | | wsrep_provider_name | Galera | | wsrep_provider_vendor | Codership Oy <info@codership.com> | | wsrep_provider_version | 25.3.23(r3789) | | wsrep_ready | ON | | wsrep_received | 451 | | wsrep_received_bytes | 298288 | | wsrep_repl_data_bytes | 100911 | | wsrep_repl_keys | 474 | | wsrep_repl_keys_bytes | 8304 | | wsrep_repl_other_bytes | 0 | | wsrep_replicated | 188 | | wsrep_replicated_bytes | 121888 | | wsrep_thread_count | 2 | +------------------------------+-----------------------------------------+

6. 노드 1 환경 설정 수정
root@mysql1:/etc/mysql/conf.d# vi /etc/mysql/my.cnf
#wsrep_cluster_address="gcomm://"
wsrep_cluster_address="gcomm://45.114.128.225,45.114.128.226"
서버스 재시작 필요없음
정상 동작 테스트는 노드 1/2 에 테스트 db import 및 삭제 테스트를 통해 진행
|