maxscale + mariadb5.5如何实现读写分离
1.安装
[root@localhost ~]# yum -y localinstall maxscale-2.3.5-1.centos.7.x86_64.rpm
2.添加访问用户
mysql>创建由'111111'标识的用户兴振翔;
查询正常,0行受影响(0.04秒)
mysql>授予 .致行振祥;
3.设置密码格式。不这样配置密码的时候,好像连接有问题
maxkeys /var/lib/maxscale/
maxpasswd /var/lib/maxscale/ 111111
获取到的格式字符串不同机器不同
44F2F27B48309A316C0B02046796B505 a机器
28C52C82EA2328A7853B450734B5CEB3 b编辑器
chown maxscale.maxscale /var/lib/ maxscale/.secrets
systemctl 重新启动 maxscale
4。编辑配置文件
[root@localhost maxscale]# cat /etc/maxscale.cnf
[maxscale]
threads=auto
log_info=1
log_warning =1
[服务器1]
类型=服务器
地址=192.168.204.130
端口=3306
协议=MariaDBBackend
[服务器2]
type=server
address=192.168.204.129
port=3306
protocol=MariaDBBackend
[MariaDB-Monitor]
type=monitor
module=mariadbmon< br/>servers=server1,server2
user=xingzhenshan
passwd=28C52C82EA2328A7853B450734B5CEB3
monitor_interval=2000
Detect_replication_lag=true
Detect_stale_master=true
[阅读- Write-Service]
type=service
router=readwritesplit
servers= Server1, Server2
User = xingzhenshan
Passwd = 28C52C82EA232853B450734b5ceb3
Max_slave_Connections = 100%< br/> max_slave_re_re Plication_lag = 5
Use_sql_variables_in = 全部
ENABLE_Root_user = 1
log_auth_warnings=1
[MaxAdmin-Service]
type=service
router=cli
[读写监听器]
type=listener
service=读写服务
#address=192.168.204.129
protocol=MariaDBClient
port=4006
[MaxAdmin-Listener]
type=listener
service =MaxAdmin-Service
protocol=maxscaled
socket=default
[root@本地主机 maxscale]#
5.安装 sysbench
curl -s https://packagecloud。 io/install/repositories/akopytov/sysbench/script.rpm.sh | io/install/repositories/akopytov/sysbench/script.rpm.sh |须藤bash
6。压力测试
[root@localhost ~]# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql -host=192.168.204.129 --mysql-port=4006 - -mysql-user=杏真香 --mysql-password=111111 --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table -size=100000 --threads=10 --time=120 --report-interval=10 次运行
7.我的压力测试
[root@localhost ~]# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-host=192.168.204.129 --mysql-port=4006 --mysql -user=杏真香 --mysql-password=111111 --oltp-test-mode =complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 运行
sysbench 1.0.17(使用捆绑的 LuaJIT 2.1.0-beta2)
使用以下选项运行测试:
线程数:10
每 10 秒报告一次中间结果
从当前时间初始化随机数生成器
正在初始化工作线程...
线程已启动!
[ 10s ] thds: 10 tps: 163.15 qps: 3281.87 (r/w/o: 2298.15/656.41/ 327.31) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 10 tps: 139.10 qps: 2780.82 (r/w/o: 1947.42/555.20/278.20) lat (ms,95%): 193.38 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 10 tps: 141.09 qps: 2813.63 (r/w/o: 1969.68/561.77/282.18) lat ( ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 10 tps: 115.85 qps: 2326.65 (r/w /o: 1627.53/467.41/231.71) lat (ms, 95%): 325.98 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 10 tps: 113.95 qps: 2268.95 (r/w/o : 1589.37/451.79/227.80) lat (ms,95%) ):337.94 错误/秒:0.00侦察/秒:0.00
[60秒] thds:10 tps:115.60 qps:2317.01(r/w/o:1621.81/463.90/231.30)纬度(ms,95%):235.74错误/秒:0.00侦察/ s: 0.00
[ 70s ] thds: 10 tps: 113.60 qps: 2270.16 (r/w/o: 1589.84/453.11 /227.21) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 10 tps: 117.40 qps: 2349.56 (r/w/o: 1644.67/470.09/234.80) lat (ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00< br/>[ 90s ] thds: 10 tps: 119.30 qps: 2385.28 (r/w/o: 1669.66/477.02/238.61) lat (ms,95%): 262.64 err/s: 0.00 reconn/s: 0.00
[ 100s ] thds: 10 tps: 115.29 qps: 2305.23 (r/w/o: 1613.78/460.87/230.58) lat (ms,95%): 193.38 err/s: 0.00 reconn/s: 0.00
[ 110s] thds: 10 tps: 109.61 qps: 2190.48 (r/w/o: 1533.02/438.24/219.22) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
[ 120s ] thds: 10 tps: 111.70 qps: 2242.33 (r/w /o: 1568.15/450.79/223.39) lat (ms,95%): 272.27 err/s: 0.00 reconn/s: 0.00
SQL 统计信息:
/>执行的查询:
阅读:br/> 写入:59068
其他:29534
总计:295340
交易: 14767(每秒 122.93)
查询:295340(每秒 2458.60)
忽略错误:0(每秒 0.00)
重新连接:(每秒 0.00) P>
一般统计数据:
总时间:120.1241s
事件总数:14767
延迟 (MS):
分钟:14.39
平均: 81.34
最大值: 1064.40
95%: 227.40
总和: 1201151.18
线程公平性:
事件(avg/stddev): 1476.7000/7.23
执行时间(平均/标准差):120.1151/0.00
8。主从状态,内部机制自动识别主从,不将server1为主
MaxScale>列出服务器
服务器。
--------------------------------+----------------+---- -- -+-------------+--------------------
服务器 | br/>-----------------+------------------+-----+ - ------------+--------------------
服务器1 | 192.168.204.130 | 3306| 0 |主控,正在运行
server2 192.168.204.129 | 3306|奴隶,奔跑
-------------------------------- -+--------- --------+--------+-------------+-------- ----------- -
MaxScale>
MaxScale> 列出服务器
服务器。
------------ --------+-- ---------------+--------+-------------+- -------------- --------
服务器 |地址 | |端口 |连接 |状态
---------------- -----+-----------------+------- +------------+---------------- ----------------
服务器1------------------------, 跑步
--------------------+----- ------------+--------+- ------------+---------------- ------
MaxScale>
以上就是maxscale + mariadb5.5如何实现读写分离的。小编相信有些知识点在我们日常工作中可能会看到或者用到。希望您能从本文中了解更多信息。更多详情请关注行业资讯频道。
2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
4. 编程技术 > maxscale + mariadb5.5如何实现读写分离