생계/MySQL2017. 11. 25. 11:00


앞서 centos 에서 슈퍼유저인 root 유저로 yum install 방식으로 

MariaDB galera cluster 를 설치했다. 

인터넷의 설치예제는 root 로 설치하는 방법이 많지만, 실제 운영환경에서

root 로 설치하는 것은 보안상 바람직하지 않다.


설정을 내가 원하는대로 바꿔가며 설치하기에는 binary 파일로 설치하는 편이

가장 좋다. 이번 포스팅은 root가 아닌 os 상의 일반유저인 mysql 유저로 

binary install 로 해서 3 node galera cluster 를 설치하는 내용을 다룰것이다.

 


Galera package 는 mariadb 10.1 이상 버전에는 default 로 포함되어있다. 

5.5나 10.0 버전에서는 따로 패키지를 추가로 설치해야하지만, 10.1 과 그 이상 

버전에서는 따로 galera package 를 설치할 필요가 없다는 뜻이다. 

설치 후, 설정파일에 설정만 추가 하는 것으로써 해당 기능이 활성화 된다. 




Step1. MariaDB binary 설치 ( node 1,2,3 동일) 


     각 노드를 설치하는 과정은 galera 나 싱글이나 차이가 없다.

    이전 포스팅에 single node 에 binary install 한 내용이 있다. 

   => http://riorio.tistory.com/7

  ** mariadb 는 이름만 mariadb 라고 부를뿐 내부 소스에서는 여전히 mysql 을 

    사용하는것 같다. single 설치 때, mysql 이 아니고 mariadb 임을 상기하려고

    basedir 을 /usr/local/mariadb 로 링크를 걸어줬는데, 이대로 설치하는 것은

    single instance 때는 문제가 없었는데, galera cluster 를 쓰려면 에러나는 부분이

    많다.  그래서 왠만하면 /usr/local/mysql 로 바꿔줘야 덜 수정하게 되고,

    여러모로 정신건강에 이로울 것이다. 


Step2. configuration , db install

    

 ●   vi /etc/init.d/mysqld 

    basedir=/usr/local/mysql

    datadir=/DATA/mysql


[mysql@node1~]# service mysqld start

[mysql@node1~]# mysql_secure_installation

[mysql@node1~]# service mysqld stop



 ●  vi /etc/my.cnf 


[galera]


wsrep_on=ON

wsrep_provider=/usr/local/mysql/lib/galera/libgalera_smm.so

wsrep_cluster_address = "gcomm://"      node1 에서 최초 bootstrap 시

#wsrep_new_cluster

#wsrep_cluster_address = "gcomm://10.10.10.11,10.10.10.12,10.10.10.13"

  --> node2,3 은 모든 ip 를 적어준다.

binlog_format = row

default_storage_engine = InnoDB

innodb_autoinc_lock_mode = 2


wsrep_cluster_name='galera'

wsrep_node_address = 10.10.10.11

wsrep_node_name = 'node1'

wsrep_sst_method = rsync


bind-address=0.0.0.0


Step3. bootstrap


  - node1 최초 boot 시

   mysqld  --wsrep-new-cluster --datadir=/DATA/mysql 

  

[ERROR] WSREP: wsrep_load(): dlopen(): libssl.so.6: cannot open shared object file: No such file or directory


만약 위의 에러가 난다면.. 


[root@galera1 ~]# cd /usr/lib64

[root@galera1 lib64]# ls -l libcrypt*

-rwxr-xr-x. 1 root root   41080 Aug  2 06:09 libcrypt-2.17.so

lrwxrwxrwx. 1 root root      19 Jun 17 22:53 libcrypto.so.10 -> libcrypto.so.1.0.1e

-rwxr-xr-x. 1 root root 2012880 Jun 29  2015 libcrypto.so.1.0.1e

lrwxrwxrwx. 1 root root      22 Jun 17 22:53 libcryptsetup.so.4 -> libcryptsetup.so.4.7.0

-rwxr-xr-x. 1 root root  166640 Nov 21  2015 libcryptsetup.so.4.7.0

lrwxrwxrwx. 1 root root      25 Nov 21 15:09 libcrypt.so -> ../../lib64/libcrypt.so.1

lrwxrwxrwx. 1 root root      16 Nov 21 15:08 libcrypt.so.1 -> libcrypt-2.17.so

[root@galera1 lib64]# ls -l libssl*

-rwxr-xr-x. 1 root root 272536 Nov 20  2015 libssl3.so

lrwxrwxrwx. 1 root root     16 Jun 17 22:53 libssl.so.10 -> libssl.so.1.0.1e

-rwxr-xr-x. 1 root root 449864 Jun 29  2015 libssl.so.1.0.1e


ln -s libcrypto.so.1.0.1e libcrypto.so.6

ln -s libssl.so.1.0.1e libssl.so.6


링크를 걸어준다. 


 - node2,3 boot 

   mysqld  --datadir=/DATA/mysql



Step4. Service check


[mysql@node1~]$ mysql -u root -proot123

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 12

Server version: 10.2.7-MariaDB-log MariaDB Server


Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


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.714286                                              |

| wsrep_cert_index_size        | 5                                                     |

| wsrep_cert_interval          | 0.000000                                              |

| wsrep_cluster_conf_id        | 5                                                     |

| wsrep_cluster_size           | 3                                                     |

| wsrep_cluster_state_uuid     | e9a1c20a-d01b-11e7-bac6-bb102b575a1a                  |

| wsrep_cluster_status         | Primary                                               |

| wsrep_commit_oooe            | 0.000000                                              |

| wsrep_commit_oool            | 0.000000                                              |

| wsrep_commit_window          | 1.000000                                              |

| wsrep_connected              | ON                                








반응형
Posted by 돌고래트레이너