CentOS 7 YUM 安裝 MariaDB Galera Server

Loading

作業環境 CentOS 7.2 ,MariaDB & Galera 5.5

CentOS 7 預設的下載 MariaDB 點是不包含 Galera ,所以我們需要新增加 MariaDB 的 YUM 網址.目前版本有分 5.5 以及 10.1 (MariaDB server 含 Galera 功能).我用的是 5.5 版本 (請先上 MariaDB 官方網站查詢版本與 baseurl, gpgkey),並新增 yum repos 設定.

[root@localhost ~]# vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5.51/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

除了 MariaDB-Galera-server 套件需要安裝外,系統會自動幫我們安裝其他需要的套件 (MariaDB-client , MariaDB-shared , MariaDB-common , galera , lsof , rsync)

如果一開始有安裝 MariDB-server 套件,建議先移除.

[root@localhost ~]# yum remove mariadb-server
[root@localhost ~]# yum update
[root@localhost ~]# yum install MariaDB-Galera-server
......
Dependencies Resolved

================================================================================
 Package                   Arch       Version                 Repository   Size
================================================================================
Installing:
 MariaDB-Galera-server     x86_64     5.5.51-1.el7.centos     mariadb      23 M
 MariaDB-client            x86_64     5.5.51-1.el7.centos     mariadb     8.6 M
     replacing  mariadb.x86_64 1:5.5.50-1.el7_2
 MariaDB-shared            x86_64     5.5.51-1.el7.centos     mariadb     1.0 M
     replacing  mariadb-libs.x86_64 1:5.5.50-1.el7_2
Installing for dependencies:
 MariaDB-common            x86_64     5.5.51-1.el7.centos     mariadb      23 k
 lsof                      x86_64     4.87-4.el7              base        331 k
 rsync                     x86_64     3.0.9-17.el7            base        360 k
.....
Installed:
  MariaDB-Galera-server.x86_64 0:5.5.51-1.el7.centos                            
  MariaDB-client.x86_64 0:5.5.51-1.el7.centos                                   
  MariaDB-shared.x86_64 0:5.5.51-1.el7.centos                                   

Dependency Installed:
  MariaDB-common.x86_64 0:5.5.51-1.el7.centos                                   
  galera.x86_64 0:25.3.17-1.rhel7.el7.centos                                    
  lsof.x86_64 0:4.87-4.el7                                                      
  rsync.x86_64 0:3.0.9-17.el7                                                   

Replaced:
  mariadb.x86_64 1:5.5.50-1.el7_2         mariadb-libs.x86_64 1:5.5.50-1.el7_2 
  mariadb-server.x86_64 1:5.5.50-1.el7_2 

不過換成 MariDB-Galera-server 之後服務名稱居然又變成 MySQL,而且變成 systemV 的方式啟動.

[root@localhost ~]# systemctl status mariadb
● mariadb.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

我們可以透過 service 或是 systemctl 的啟動方式.

[root@localhost ~]# service mysql start
Starting MySQL.... SUCCESS! 
[root@localhost ~]# systemctl restart mysql
[root@localhost ~]# systemctl status mysql
mysql.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysql)
   Active: active (running) since 一 2016-08-29 13:01:15 EDT; 14s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1105 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mysql.service
           ├─1116 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql...
           └─2370 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib6...

透過 #systemctl status mysql 會看到三個服務在裡面 mysql , mysqld , mysqld_safe , 他們所代表的是.

  • mysql
    mysql (MySQL command-line tool), mysql is a simple SQL shell
  • mysqld
    mysqld (MySQL server), also known as MySQL Server,
  • mysqld_safe
    mysqld_safe (MySQL server startup script) ,mysqld_safe is the recommended way to start a mysqld server on Unix and NetWare. mysqld_safe adds some safety features such as restarting the server when an error occursand logging runtime information to an error log file.

檢查一下 MariaDB 是否正常.

[root@localhost ~]# netstat -anlp | grep -e 4567 -e 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      2457/mysqld           
  • 3306 – MySQL port
  • 4567 – Galera Cluster

雖然我們安裝的版本是含有 Galera cluster 的 MariaDB,不過目前只會看到 MariaDB 有啟動,還需要進一步設定 MariaDB Galera Server 以及 Galera Cluster Server – https://benjr.tw/95381

沒有解決問題,試試搜尋本站其他內容

3 thoughts on “CentOS 7 YUM 安裝 MariaDB Galera Server

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料