成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

MySQL高可用架構之GaleraCluster

MySQL高可用架構之Galera Cluster

1、實驗準備及拓撲

至少需要三個節(jié)點

為沈陽等地區(qū)用戶提供了全套網頁設計制作服務,及沈陽網站建設行業(yè)解決方案。主營業(yè)務為網站設計、成都做網站、沈陽網站設計,以傳統(tǒng)方式定制建設網站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

node1 192.168.150.137
node2 192.168.150.138
node3 192.168.150.139

mariadb版本為mariadb的支持galera cluster的分支版本

MariaDB-Galera-server-5.5.46

實驗前準備:

1、HA環(huán)境首要條件:時間同步
三個節(jié)點添加對時腳本
[root@localhost ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate 1.cn.pool.ntp.org

2、三個幾點均配置MariaDB-Galera的本地yum倉庫,我嘗試使用mariadb官方提供的yum倉庫,天朝的網會氣死你
[root@localhost ~]# cat /etc/yum.repos.d/galera.repo 
[galera]
name=galera
baseurl=file:///root/galera_cluster
gpgcheck=0
enable=1

3、yum安裝,僅需安裝MariaDB-Galera-server,其余的均會依賴安裝
yum -y install Mariadb-Galera-server

2、配置

1、查看galera所需調用的庫的位置
rpm -ql galera | grep -i smm.so
/usr/lib64/galera/libgalera_smm.so

2、修改配置文件,三節(jié)點同步修改
[root@localhost yum.repos.d]# cat /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider=/usr/lib64/galera/libgalera_smm.so 
wsrep_cluster_address="gcomm://192.168.150.137,192.168.150.138,192.168.150.139"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_cluster_name='mycluster'
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

3、節(jié)點1進行mysql及cluster開啟
[root@localhost ~]# /etc/rc.d/init.d/mysql start --wsrep-new-cluster    
Starting MySQL.... SUCCESS! 

4、其它兩個節(jié)點進行正常的mysql開啟
[root@localhost ~]# service mysql start
Starting MySQL....SST in progress, setting sleep higher. SUCCESS! 

此時已配置完成。。。。。。

3、功能驗證

1、節(jié)點1創(chuàng)建數(shù)據庫,節(jié)點2 3均可正常查看
節(jié)點1:[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.46-MariaDB-wsrep MariaDB Server, wsrep_25.12.r4f81026

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

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

MariaDB [(none)]> CREATE DATABASE mydb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| test               |
+--------------------+

節(jié)點2 3:
[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.46-MariaDB-wsrep MariaDB Server, wsrep_25.12.r4f81026

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

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

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.01 sec)



2、節(jié)點2數(shù)據庫中創(chuàng)建表,節(jié)點1 2均可正常查看
節(jié)點2:
MariaDB [(none)]> use mydb;
Database changed
MariaDB [mydb]> CREATE TABLE tb1 (id int,name char(10));
Query OK, 0 rows affected (0.01 sec)

節(jié)點1 3:
MariaDB [(none)]> use mydb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mydb]> SHOW TABLES
    -> ;
+----------------+
| Tables_in_mydb |
+----------------+
| tb1            |
+----------------+
1 row in set (0.00 sec)

MariaDB [mydb]> DESC tb1;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id    | int(11)  | YES  |     | NULL    |       |
| name  | char(10) | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.02 sec)

3、自增欄位的測試,每個幾點會跳著進行自增,同時插入時例如1節(jié)點1 4 7;2節(jié)點2 5 8;三節(jié)點3 6 9。
節(jié)點1:
MariaDB [mydb]> CREATE TABLE tb2(id int UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,name char(30)
uery OK, 0 rows affected (0.01 sec)

MariaDB [mydb]> INSERT INTO tb2 (name) VALUES ('void'),('yao');
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

節(jié)點2:
MariaDB [mydb]> select * from tb2;
+----+------+
| id | name |
+----+------+
|  1 | void |
|  4 | yao  |
+----+------+
2 rows in set (0.01 sec)

MariaDB [mydb]> INSERT INTO tb2 (name) VALUES ('amy'),('apple');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

MariaDB [mydb]> select * from tb2;
+----+-------+
| id | name  |
+----+-------+
|  1 | void  |
|  4 | yao   |
|  5 | amy   |
|  8 | apple |
+----+-------+
4 rows in set (0.00 sec)

當前文章:MySQL高可用架構之GaleraCluster
地址分享:http://jinyejixie.com/article38/ipegpp.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供ChatGPT、靜態(tài)網站、域名注冊網站建設品牌網站制作、網站設計

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)
大埔区| 赤水市| 武穴市| 汾阳市| 长汀县| 文登市| 乌鲁木齐县| 孝感市| 凤阳县| 上饶县| 永泰县| 桐庐县| 古交市| 白水县| 庆云县| 白山市| 乌兰县| 苍梧县| 神池县| 永仁县| 仙游县| 酉阳| 辰溪县| 湘潭县| 天津市| 从江县| 滦平县| 竹山县| 安多县| 黄大仙区| 巢湖市| 荥阳市| 和平县| 射洪县| 龙里县| 芷江| 仙居县| 桦南县| 泰来县| 环江| 囊谦县|