91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

maxscale讀寫分離

發布時間:2020-08-17 13:31:04 來源:ITPUB博客 閱讀:252 作者:守望567 欄目:MySQL數據庫
maxscale安裝
官網配置文件詳解地址:
https://mariadb.com/kb/en/mariadb-enterprise/mariadb-maxscale/maxscale-configuration-usage-scenarios/#authentication

安裝包  maxscale-1.4.3-1.centos.6.x86_64.rpm 

# rpm -ivh maxscale-1.4.3-1.centos.6.x86_64.rpm
# mkdir /data/maxscale3306
# cd /data/maxcale3306
# make {cache,data,lang,log}

# cat/etc/maxscale.cnf

[maxscale]
threads=auto       ##開啟線程個數,默認為1.設置為auto會同cpu核數相同
# Server definitions     
maxlog=1 #將日志寫入到maxscale的日志文件中
log_to_shm=0 #不將日志寫入到共享緩存中,開啟debug模式時可打開加快速度
log_warning=1 #記錄告警信息
log_notice=1 #記錄notice
log_info=1 #記錄info
log_debug=0 #不打開debug模式

#auth_connect_timeout=60 #默認3秒
#auth_read_timeout=60 #默認1秒
#auth_write_timeout=60 #默認2秒
#localhost_match_wildcard_host=1

logdir=/data/maxscale3306/log/ #日志位置
datadir=/data/maxscale3306/data/ #數據位置
cachedir=/data/maxscale3306/cache/ #緩存位置
piddir=/data/maxscale3306/ #pid文件位置
connection_timeout=300 #連接超時
max_connections=1000 #最大連接數
#language=/data/maxscale3306/lang/
# Set the address of the server to the network
# address of a MySQL server.
#
#[server1],和[server2]是主從,223是主  224是從,可以有多個在加[server3....]

[server1]
type=server
address=192.168.144.223
port=3312
protocol=MySQLBackend
#serversize=10 #權重設置

[server2]
type=server
address=192.168.144.224
port=3310
protocol=MySQLBackend
#serversize=10 #權重設置

# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Monitors/MySQL-Monitor.md

[MySQL Monitor]  #監控信息,監控的用戶需要對后端數據庫有訪問replication client的權限   grant replication slave, replication client on *.* to scalemon@'%' identified by '123456';
type=monitor
module=mysqlmon
servers=server1,server2
user=scalemon
passwd=B7A14BD5A08414AF147BD35CE0F761FC #加密的123456,后面有加密的方法,也可不加密
monitor_interval=10000 #監控心跳為1秒
detect_stale_master=true #slave節點全部斷掉時,將所有的讀寫都指向master節點
#max_slave_replication_lag=5 #超過延遲5秒,把請求轉發給其他slave,這里就兩個節點就沒開

# Service definitions
#
# Service Definition for a read-only service and
# a read/write splitting service.
#

# ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadConnRoute.md

#Read-Only的選項全都注釋掉了
#[Read-Only Service]
#type=service
#router=readconnroute
#servers=server1,server2
#user=maxscale
#passwd=123456
#router_options=slave
#filters=Hint

#[Hint]
#type=filter
#module=hintfilter

# ReadWriteSplit documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadWriteSplit.md

#讀寫分離,用戶需要有SELECT ON mysql.db;SELECT ON mysql.tables_priv;SHOW DATABASES ON *.*的權限    grant select,show databases on mysql.* to maxscale@'%' identified by '123456';
[Read-Write Service]
type=service
router=readwritesplit
servers=server2,server1
router_options=master_accept_reads=false,master_failure_mode=fail_on_write
user=maxscale
passwd=B7A14BD5A08414AF147BD35CE0F761FC     #123456的加密后的
max_slave_connections=100% #所有的slave提供select查詢服務
use_sql_variables_in=all ###動態參數可以走全部的數據庫  [all|master]  如果設置為master的話前臺看到的中文是亂碼,一般建議設置為all
#weightby=serversize #權重設置
#enable_root_user=1 #允許root用戶登錄執行
auth_all_servers=true #
log_auth_warnings=true #身份驗證失敗和警告的日志記錄,記錄那些試圖連接到MaxScale和來自哪里

filters=Hint #強制select走master的選項,參考:https://mariadb.com/kb/en/mariadb-enterprise/mariadb-maxscale/maxscale-hint-syntax/      不知道為什么不好用,強制了也不走master

[Hint]
type=filter
module=hintfilter
# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Reference/MaxAdmin.md

[MaxAdmin Service]
type=service
router=cli

# Listener definitions for the services
#
# These listeners represent the ports the
# services will listen on.
#

#Read-Only的全部注釋掉了,上面說過了
#[Read-Only Listener]
#type=listener
#service=Read-Only Service
#protocol=MySQLClient
#port=4008

[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006 #連接端口,程序連接端口

[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
port=6603 #管理端口

加密:
# maxkeys /data/maxscale3306/data/.secrets       ---創建加密文件
# maxpasswd /data/maxscale3306/data/.secrets  123456     ---生成加密后的密碼
B7A14BD5A08414AF147BD35CE0F761FC     這就是配置文件中的password
注:創建加密文件的.secrets文件要在datadir定義的目錄中

啟動:
# /etc/init.d/maxscale  start|stop|restart
或者  maxscale -f /etc/maxscale.cnf 

# netstat -ntelp | grep max*    

測試:
測試就不演示了

管理:
默認密碼:mariadb
# maxadmin list servers -pmariadb           查看當前服務器狀態
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status              
-------------------+-----------------+-------+-------------+--------------------
server1            | 192.168.144.223 |  3312 |           0 | Master, Running
server2            | 192.168.144.224 |  3310 |           0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------

# maxadmin list services -pmariadb    查看當前服務連接
Services.
--------------------------+----------------------+--------+---------------
Service Name              | Router Module        | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Read-Write Service        | readwritesplit       |      1 |   788
MaxAdmin Service          | cli                  |      2 |     5
--------------------------+----------------------+--------+---------------


# maxadmin list listeners -pmariadb      查看當前運行端口
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name         | Protocol Module    | Address         | Port  | State
---------------------+--------------------+-----------------+-------+--------
Read-Write Service   | MySQLClient        | *               |  4006 | Running
MaxAdmin Service     | maxscaled          | *               |  6603 | Running
---------------------+--------------------+-----------------+-------+--------
如果想改管理密碼要在配置文件里加上
[MaxAdmin]
type=service
router=cli
user=maxscale
passwd=Mhu87p2D
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

建昌县| 乐山市| 开原市| 奉节县| 平原县| 牡丹江市| 收藏| 醴陵市| 庆元县| 伽师县| 忻州市| 稻城县| 清原| 塔河县| 兴海县| 泰来县| 珲春市| 康乐县| 景东| 淳化县| 塔城市| 沁源县| 临清市| 翁源县| 阜康市| 阿克陶县| 长兴县| 肃南| 永清县| 商洛市| 庆云县| 葵青区| 溆浦县| 龙口市| 锦屏县| 弋阳县| 阜城县| 板桥市| 长兴县| 仁布县| 吴桥县|