真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

配置數(shù)據(jù)庫(kù)讀寫(xiě)分離服務(wù)器

配置一主一從 主從同步結(jié)構(gòu),并在客戶(hù)端測(cè)試配置
master51> grant all on webdb.* to webuser@"%" identified by " 123456";

網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)服務(wù)團(tuán)隊(duì)是一支充滿(mǎn)著熱情的團(tuán)隊(duì),執(zhí)著、敏銳、追求更好,是創(chuàng)新互聯(lián)的標(biāo)準(zhǔn)與要求,同時(shí)竭誠(chéng)為客戶(hù)提供服務(wù)是我們的理念。成都創(chuàng)新互聯(lián)把每個(gè)網(wǎng)站當(dāng)做一個(gè)產(chǎn)品來(lái)開(kāi)發(fā),精雕細(xì)琢,追求一名工匠心中的細(xì)致,我們更用心!

裝包
rpm -ivh maxscale-2.1.2-1.rhel.7.x86_64.rpm

[root@host56 ~]# rpm -qa | grep maxscale
maxscale-2.1.2-1.x86_64

[root@host56 ~]# rpm -qc maxscale
/etc/maxscale.cnf.template

[root@host56 ~]#
修改配置文件
[root@host56 ~]# ls /etc/maxscale.cnf
/etc/maxscale.cnf

[root@host56 ~]# cp /etc/maxscale.cnf /etc/maxscale.cnf.bak

[root@host56 ~]# vim /etc/maxscale.cnf
[maxscale]
threads=1  也可是是auto
[server1]
type=server
address=192.168.4.51
port=3306
protocol=MySQLBackend

[server2]
type=server
address=192.168.4.52
port=3306
protocol=MySQLBackend

[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1, server2
user=scalemon
passwd=123456
monitor_interval=10000

[Read-Write Service]
type=service
router=readwritesplit
servers=server1, server2
user=maxscale
passwd=123456
max_slave_connections=100%

[MaxAdmin Service]
type=service
router=cli

[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006

[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
socket=default
port=4018

根據(jù)配置文件做相應(yīng)的設(shè)置(在2臺(tái)數(shù)據(jù)庫(kù)服務(wù)器上添加用戶(hù))
監(jiān)控?cái)?shù)據(jù)庫(kù)服務(wù)器時(shí),連接數(shù)據(jù)庫(kù)服務(wù)器的用戶(hù)
mysql> grant replication slave, replication client on 星.星 to scalemon@'%' identified by "123456";

驗(yàn)證 訪(fǎng)問(wèn)數(shù)據(jù)時(shí),連接數(shù)據(jù)庫(kù)服務(wù)器使用的用戶(hù),是否在數(shù)據(jù)庫(kù)服務(wù)器上存在的,連接用戶(hù)
mysql> grant select on mysql.* to maxscale@'%' identified by "123456";

查看授權(quán)用戶(hù)
mysql> select user,host from mysql.user where user in ("scalemon","maxscale");
+----------+------+
| user | host |
+----------+------+
| maxscale | % |
| scalemon | % |
+----------+------+

啟動(dòng)服務(wù)
[root@host56 ~]# maxscale -f /etc/maxscale.cnf

查看服務(wù)進(jìn)程和端口

查看端口
[root@host56 ~]# netstat -utnlp | grep :4006
[root@host56 ~]# netstat -utnlp | grep :4018
[root@host56 ~]# ps -C maxscale

停止服務(wù)
[root@host56 ~]# ps -C maxscale
PID TTY TIME CMD
29688 ? 00:00:00 maxscale
[root@host56 ~]# kill -9 29688
[root@host56 ~]#
[root@host56 ~]#
[root@host56 ~]# kill -9 29688
-bash: kill: (29688) - 進(jìn)程不存在

2.2.3 測(cè)試配置
A 在本機(jī)訪(fǎng)問(wèn)管理管端口查看監(jiān)控狀態(tài)

[root@host56 ~]# maxadmin -P4018 -uadmin -pmariadb
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
server1 | 192.168.4.51 | 3306 | 0 | Master, Running
server2 | 192.168.4.52 | 3306 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
MaxScale> exit
[root@host56 ~]#

b 客戶(hù)端訪(fǎng)問(wèn)數(shù)據(jù)讀寫(xiě)分離服務(wù)器
]#which mysql
]# mysql -h292.168.4.56 -P4006 -uwebuser -p123456
mysql> select @@hostname;
mysql> 執(zhí)行插入或查詢(xún) ( 在51 和 52 本機(jī)查看記錄)


網(wǎng)站欄目:配置數(shù)據(jù)庫(kù)讀寫(xiě)分離服務(wù)器
網(wǎng)址分享:http://weahome.cn/article/iegoei.html

其他資訊

在線(xiàn)咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部