Configure database read-write detach server

Source: Internet
Author: User

Configure a master-slave synchronization structure and test the configuration on the client
Master51> Grant all on webdb.* to [e-mail protected] "%" identified by "123456";

Loading package
RPM-IVH maxscale-2.1.2-1.rhel.7.x86_64.rpm

[Email protected] ~]# Rpm-qa | grep Maxscale
Maxscale-2.1.2-1.x86_64

[Email protected] ~]# RPM-QC Maxscale
/etc/maxscale.cnf.template

[Email protected] ~]#
Modifying a configuration file
[Email protected] ~]# LS/ETC/MAXSCALE.CNF
/etc/maxscale.cnf

[Email protected] ~]# Cp/etc/maxscale.cnf/etc/maxscale.cnf.bak

[Email protected] ~]# VIM/ETC/MAXSCALE.CNF
[Maxscale]
Threads=1 is auto, too.
[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

Make the appropriate settings based on the configuration file (add users on 2 database servers)
When you monitor the database server, users who connect to the database server
mysql> grant replication Slave, replication client on star. Star to [email protected] ' percent ' identified by "123456";

When verifying access to data, connect users to the database server using the user, whether they exist on the database server,
Mysql> Grant Select on mysql.* to [e-mail protected] '% ' identified by ' 123456 ';

View authorized Users
Mysql> Select User,host from Mysql.user where user in ("Scalemon", "Maxscale");
+----------+------+
| user | Host |
+----------+------+
| Maxscale | % |
| Scalemon | % |
+----------+------+

Start the service
[Email protected] ~]# maxscale-f/etc/maxscale.cnf

Viewing service processes and ports

View ports
[Email protected] ~]# NETSTAT-UTNLP | grep:4006
[Email protected] ~]# NETSTAT-UTNLP | grep:4018
[Email protected] ~]# ps-c Maxscale

Stop Service
[Email protected] ~]# ps-c Maxscale
PID TTY Time CMD
29688? 00:00:00 Maxscale
[Email protected] ~]# kill-9 29688
[Email protected] ~]#
[Email protected] ~]#
[Email protected] ~]# kill-9 29688
-bash:kill: (29688)-process does not exist

2.2.3 Test Configuration
A view monitoring status on the native access management tube port

[Email protected] ~]# 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
[Email protected] ~]#

b Client Access data read/write Detach server
] #which MySQL
]# mysql-h192.168.4.56-p4006-uwebuser-p123456
Mysql> SELECT @ @hostname;
Mysql> performing an INSERT or query (in 51 and 52 native view records)

Configure database read-write detach server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.