os = centos7
db = mariadb10
# mariadb binary install 기준
# centos(7)에서 기본으로 설치된 mariadb 5.ver rpm 확인 후 삭제
[root@localhost ~]# rpm -qa | grep ariad
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@localhost ~]# rpm -e mariadb-libs --nodeps
# download 받은 rpm 압출 풀고 아래의 5개 파일들 yum으로 설치
MariaDB-10.1.18-centos7-x86_64-client.rpm
MariaDB-10.1.18-centos7-x86_64-common.rpm
MariaDB-10.1.18-centos7-x86_64-compat.rpm
MariaDB-10.1.18-centos7-x86_64-shared.rpm
galera-25.3.18-1.rhel7.el7.centos.x86_64.rpm
(설치할 rpm파일들만 따로 모아서 * 로 전체 설치)
[root@localhost rpms]# mkdir install_rpms
[root@localhost rpms]# cp MariaDB-10.1.18-centos7-x86_64-client.rpm
MariaDB-10.1.18-centos7-x86_64-common.rpm
MariaDB-10.1.18-centos7-x86_64-compat.rpm
MariaDB-10.1.18-centos7-x86_64-shared.rpm
galera-25.3.18-1.rhel7.el7.centos.x86_64.rpm
install_rpms
[root@localhost rpms]# cd install_rpms
[root@localhost install_rpms]# # yum install -y *
dependency rpms
==============================================================================
Dep-Install perl-4:5.16.3-291.el7.x86_64 @base
Dep-Install perl-Carp-1.26-244.el7.noarch @base
Dep-Install perl-Encode-2.51-7.el7.x86_64 @base
Dep-Install perl-Exporter-5.68-3.el7.noarch @base
Dep-Install perl-File-Path-2.09-2.el7.noarch @base
Dep-Install perl-File-Temp-0.23.01-3.el7.noarch @base
Dep-Install perl-Filter-1.49-3.el7.x86_64 @base
Dep-Install perl-Getopt-Long-2.40-2.el7.noarch @base
Dep-Install perl-HTTP-Tiny-0.033-3.el7.noarch @base
Dep-Install perl-PathTools-3.40-5.el7.x86_64 @base
Dep-Install perl-Pod-Escapes-1:1.04-291.el7.noarch @base
Dep-Install perl-Pod-Perldoc-3.20-4.el7.noarch @base
Dep-Install perl-Pod-Simple-1:3.28-4.el7.noarch @base
Dep-Install perl-Pod-Usage-1.63-3.el7.noarch @base
Dep-Install perl-Scalar-List-Utils-1.27-248.el7.x86_64 @base
Dep-Install perl-Socket-2.010-4.el7.x86_64 @base
Dep-Install perl-Storable-2.45-3.el7.x86_64 @base
Dep-Install perl-Text-ParseWords-3.29-4.el7.noarch @base
Dep-Install perl-Time-HiRes-4:1.9725-3.el7.x86_64 @base
Dep-Install perl-Time-Local-1.2300-2.el7.noarch @base
Dep-Install perl-constant-1.27-2.el7.noarch @base
Dep-Install perl-libs-4:5.16.3-291.el7.x86_64 @base
Dep-Install perl-macros-4:5.16.3-291.el7.x86_64 @base
Dep-Install perl-parent-1:0.225-244.el7.noarch @base
Dep-Install perl-podlators-2.5.1-3.el7.noarch @base
Dep-Install perl-threads-1.87-4.el7.x86_64 @base
Dep-Install perl-threads-shared-1.43-6.el7.x86_64 @base
==============================================================================
# 기타 yum에서 설치
[root@localhost ~]# yum install -y rsync
[root@localhost ~]# yum install -y lsof
# my.cnf 파일 클러스터 별 변경내용
[root@galera1 ~]# chown maria.dba /etc/my.cnf
[root@galera1 ~]# vi /etc/my.cnf
# 1. Mandatory settings: these settings are REQUIRED for proper cluster operation
==============================================================================
binlog_format=ROW
innodb_autoinc_lock_mode=2
auto_increment_increment=3
auto_increment_offset=1 # first node
==============================================================================
auto_increment_offset 노드번호별 숫자 입력
# 3. wsrep provider configuration: basic wsrep options
==============================================================================
wsrep_on=on
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=1G; gcs.fc_limit=512"
#wsrep_cluster_address='gcomm://192.168.0.160,192.168.0.161,192.168.0.162'
wsrep_cluster_address='gcomm://'
wsrep_cluster_name='my_cluster'
wsrep_node_address='192.168.0.160'
wsrep_node_name='galera1'
wsrep_sst_method=rsync
#wsrep_sst_method=xtrabackup
#wsrep_sst_auth="backup:backup123!"
wsrep_replicate_myisam=1
==============================================================================
1번노드 wsrep_cluster_address='gcomm://'
기타노드 wsrep_cluster_address='gcomm://192.168.0.160,192.168.0.161,192.168.0.162'
- wsrep_node_address
- wsrep_node_name
해당 노드에 맞게 변경
최초기동시 sync는 rsync로.
# mariadb engine 을 galera 로 심볼릭 링크
[maria@galera1 ~]$ ln -s /MARIA/mariadb-enterprise-10.1.18-linux-x86_64/ /MARIA/galera
[maria@galera1 ~]$ rm /MARIA/mariadb
# mariadb_install_db
[maria@galera1 ~]$ cd /MARIA/galera
[maria@galera1 galera]$ scripts/mysql_install_db --user=maria
# mysql.server 수정
[maria@galera1 galera]$ vi support-files/mysql.server
basedir=/MARIA/galera
datadir=/MARIA_DATA/DATA
# 사용할 hosts 등록
[root@galera1 ~]# vi /etc/hosts
192.168.0.160 galera1
192.168.0.161 galera2
192.168.0.162 galera3
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ssh 작업 시작
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 해당 노드에 맞게 hostname 변경
[root@localhost ~]# vi /etc/hostname
galera1
저장 후 reboot 후 [root@galera1 ~]# 처럼 표시됨
# maria 계정의 공개키 생성 및 배포
[root@galera1 ~]# su - maria
[maria@galera1 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/maria/.ssh/id_rsa):
Created directory '/home/maria/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/maria/.ssh/id_rsa.
Your public key has been saved in /home/maria/.ssh/id_rsa.pub.
The key fingerprint is:
ce:43:13:fe:0e:4a:d2:44:17:2f:0f:42:b2:27:b9:2c maria@galera1
The key's randomart image is:
+--[ RSA 2048]----+
| . . . |
| = o |
| + + = . |
| . = + = |
| E o . S . |
| . o + o |
| . o = . |
| o . + |
| . . |
+-----------------+
[maria@galera1 ~]$ ssh-copy-id galera2
The authenticity of host 'galera2 (192.168.0.161)' can't be established.
ECDSA key fingerprint is d9:ef:c1:84:df:b0:54:47:5c:15:d8:1c:c1:a8:40:8f.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
maria@galera2's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'galera2'"
and check to make sure that only the key(s) you wanted were added.
테스트 :
[maria@galera1 ~]$ ssh galera2
Last failed login: Tue Feb 14 20:02:57 EST 2017 from 192.168.0.160 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Tue Feb 14 19:14:25 2017
[maria@galera2 ~]$
[maria@galera1 ~]$ ssh-copy-id galera2
[maria@galera1 ~]$ ssh-copy-id galera3
[maria@galera2 ~]$ ssh-copy-id galera1
[maria@galera2 ~]$ ssh-copy-id galera3
[maria@galera3 ~]$ ssh-copy-id galera1
[maria@galera3 ~]$ ssh-copy-id galera2
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ssh 작업 끝
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# galera.service 등록
[root@galera1 ~]# cp /download/galera.service /etc/systemd/system/
==========================================================================
[Unit]
Description=MariaDB-10.1
After=syslog.target
[Service]
ExecStart=/MARIA/galera/support-files/mysql.server start
Type=forking
PIDFile=/MARIA_DATA/mysql.pid
[Install]
WantedBy=multi-user.target
==========================================================================
# galera.service start
[root@galera1 ~]# systemctl start galera.service
[root@galera1 ~]# systemctl status galera.service
● galera.service - MariaDB-10.1
Loaded: loaded (/etc/systemd/system/galera.service; disabled; vendor preset: disabled)
Active: active (running) since 화 2017-02-14 20:23:18 EST; 5s ago
Process: 2445 ExecStart=/MARIA/galera/support-files/mysql.server start (code=exited, status=0/SUCCESS)
# start mariadb
[root@galera1 ~]# su - maria
[maria@galera1 ~]$ mysql
MariaDB [(none)]> show status like 'wsrep_%';
- check list
wsrep_cluster_size | 1 --> 2, 3 번 기동시 cluster_size 는 3이됨
wsrep_cluster_status | Primary
wsrep_connected | ON
wsrep_local_state_comment | Synced
wsrep_incoming_addresses | 192.168.0.160:3307
--> 2, 3 번 기동시
wsrep_incoming_addresses | 192.168.0.161:3307,192.168.0.162:3307,192.168.0.160:3307
# 2, 3 번 실행시 /MARIA_DATA/DATA 빈 폴더 존재해야 함
# xtrabackup으로 변경위한 db계정 생성
MariaDB [(none)]> grant all on *.* to 'backup'@'192.168.0.%' identified by 'backup123!';
# /etc/my.cnf 파일 수정
[maria@galera2 ~]$ vi /etc/my.cnf
- 1번노드는 address도 수정
#wsrep_cluster_address='gcomm://'
wsrep_cluster_address='gcomm://192.168.0.160,192.168.0.161,192.168.0.162'
- 전부 method 를 rsync 에서 xtrabackup으로 변경 및 sst_auth에 위에서 생성한 db계정으로 입력
#wsrep_sst_method=rsync
wsrep_sst_method=xtrabackup
wsrep_sst_auth="backup:backup123!"
# 순차별 노드 재기동 후 xtrabackup으로 변경유무 확인
- 기존 rsync
MariaDB [(none)]> show variables like 'wsrep_sst%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| wsrep_sst_auth | |
| wsrep_sst_donor | |
| wsrep_sst_donor_rejects_queries | OFF |
| wsrep_sst_method | rsync |
| wsrep_sst_receive_address | AUTO |
+---------------------------------+-------+
- xtrabkcup
MariaDB [(none)]> show variables like 'wsrep_sst%';
+---------------------------------+------------+
| Variable_name | Value |
+---------------------------------+------------+
| wsrep_sst_auth | ******** |
| wsrep_sst_donor | |
| wsrep_sst_donor_rejects_queries | OFF |
| wsrep_sst_method | xtrabackup |
| wsrep_sst_receive_address | AUTO |
+---------------------------------+------------+
- wsrep_sst_auth
- wsrep_sst_method
확인
wsrep_cluster_state_uuid 는 노드 다 동일해야 한다.
wsrep_cluster_conf_id 또한 동일해야한다.
wsrep_cluster_size 연결된 클러스터 수
wsrep_cluster_status Primary
wsrep_ready on = sql load 준비
wsrep_connected on = 클러스터 연결 유무
wsrep_flow_control_paused 0.0 ~ 1.0 범위 1 이면 정지를 의미. 가능한 0에 가까워야함
'Study' 카테고리의 다른 글
Columnstore multi combined install and addmodule (2017) (0) | 2022.09.19 |
---|---|
Columnstore 1.0.x Binary Install Script (2017) (0) | 2022.09.19 |
MariaDB 10.x Binary Install Script (2016) (0) | 2022.09.19 |
Columnstore CrossEngine 설정 (2016) (0) | 2022.09.19 |
MariaDB 10 binary install (2016) (0) | 2022.09.19 |