mysql configuration maxscale separate read and write

Installation maxscale

wget https://downloads.mariadb.com/MaxScale/2.2.15/centos/6server/x86_64/maxscale-2.2.15-1.centos.6.x86_64.rpm
rpm -ivh maxscale-2.2.15-1.centos.6.x86_64.rpm

 

Maxscale user to create, execute the main library
Note: This user is used to monitor and implement internal maxscale get user calls and other operations

create user maxscale@'%' identified by "WWW.tsb.c0m";
GRANT SELECT ON mysql.user TO maxscale@'%';
GRANT SELECT ON mysql.db TO maxscale@'%';
GRANT SELECT ON mysql.tables_priv TO maxscale@'%';
GRANT SHOW DATABASES ON *.* TO maxscale@'%';
GRANT ALL ON maxscale_schema.* TO maxscale@'%';
GRANT replication slave, replication client ON *.* TO maxscale@'%';


Create a directory-related services maxscale

mkdir -pv /data/logs/maxscale
mkdir -pv /data/appData/maxscale
mkdir -pv /data/tmp/maxscale/cache
# Authorization
chown -R maxscale.maxscale /data/logs/maxscale
chown -R maxscale.maxscale /data/appData/maxscale
chown -R maxscale.maxscale /data/tmp/maxscale

 

Maxscale modify configuration files /etc/maxscale.cnf

vim /etc/maxscale.cnf

[maxscale]
# Enable the number of threads, the default is 1. Set to auto jointly with the same number of cpu core
threads=auto

# Enable high-precision time stamps in the log file. Enable this option to add a millisecond accuracy of all log file timestamps.
ms_timestamp=1
# Log messages to syslog 1 0 Kai ban
syslog=1
# Log messages to a log file MariaDB MaxScale 1 0 Kai ban
MaxLog = . 1
# Does not write files to the shared memory maxscale.log 1 0 Kai ban
log_to_shm=0
# Record alarm logs
log_warning=1
# Notice the log record
log_notice=1
# INFO log record
log_info=1
# Debug log does not record
log_debug=0
# Disable expand the message. If this option is enabled, the name of the function appends a message recorded messages for each record. This is mainly for development purposes, therefore disabled by default.
log_augmentation=0

# Log directory
logdir=/data/logs/maxscale/
# Data Directory
datadir=/data/appData/maxscale/
# Cache directory
cachedir=/data/tmp/maxscale/cache/

# Define the back-end database server
[server1]
type=server
address=10.0.1.100
port=3306
protocol=MySQLBackend

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

# Monitor
[MySQL-Monitor]
type=monitor
module=mysqlmon
servers=server1,server2
user=maxscale
passwd=mysqlPassword
# Monitor the heartbeat of 10s
monitor_interval=10000
# When a slave all broken, maxscale still available, all of the access points to master node
detect_stale_master=true

# Separate read and write
[Read-Write-Service]
type=service
router=readwritesplit
servers=server1,server2
user=maxscale
passwd=mysqlPassword
# Maximum connection from the library
max_slave_connections=100%
# From the master allows the maximum spacing (s)
max_slave_replication_lag = 5
# Sql statement can be executed in the presence of all the variables in the library
use_sql_variables_in = all

[MaxAdmin-Service]
type=service
router=cli

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

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

 

Start maxscale Service

/etc/init.d/maxscale start
chkconfig maxscale on

 

Guess you like

Origin www.cnblogs.com/Liudarren/p/12408525.html