In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This installation and deployment is based on the case that MHA has been deployed, only MaxScale is deployed, and the rpm package installation is used.
MaxScale is a set of database middleware developed by mariadb company. It supports high availability, read-write separation, load balancing, and has good scalability. It is not only high-performance event-driven, but also has agent and management functions.
1. Download MaxScale software
Download address: https://downloads.mariadb.com/files/MaxScale/
Https://github.com/mariadb-corporation/MaxScale-source code download
Reference manual: https://downloads.mariadb.com/files/MaxScale/docs
Https://mariadb.com/kb/en/mariadb-enterprise/mariadb-maxscale
2. Extract the installation package
(binary installation package)
[root@node3 MaxScale] # tar-xzvf maxscale-1.4.3-1.rhel.6.x86_64.tar.gz
3. Install the dependency package
Configure the local yum source:
[root@node3 MaxScale] # mkdir / media/cdrom
[root@node3 MaxScale] # mount CentOS-6.4-x86_64-bin-DVD1.iso / media/cdrom/-o loop
[root@node3 MaxScale] # rm-rf / etc/yum.repos.d/*.repo
[root@node3 MaxScale] # vi / etc/yum.repos.d/CentOS6.repo
[Base]
Name=CentOS6 ISO Base
Baseurl= file:///media/cdrom
Enabled=1
Gpgcheck=0
Dependent package check installation:
Yum install git gcc gcc-c++ ncurses-devel bison flex glibc-devel cmake libgcc perl make libtool openssl-devel libaio libaio-devel librabbitmq-devel libcurl-devel pcre-devel tcl tcl-devel systemtap-sdt-devel libuuid libuuid-devel
Rpm-Q libaio libaio-devel novacom-server libedit gcc gcc-c++ ncurses-devel bison glibc-devel cmake libgcc perl make libtool openssl-devel libaio libaio-devel librabbitmq-devel libcurl-devel pcre-devel
Upgrade openssl
[root@node3 MaxScale] # rpm-Uvh openssl-1.0.1e-42.el6_7.1.x86_64.rpm-nodeps
[root@node3 MaxScale] # rpm-Uvh openssl-devel-1.0.1e-42.el6_7.1.x86_64.rpm
4. MaxScale installation and deployment
MaxScale installation:
1) rpm package installation
[root@node3 MaxScale] # rpm-ivh maxscale-beta-2.0.0-1.centos.6.x86_64.rpm-nodeps
2) Source code installation
(the following is the source code compilation, in which the compilation failed and the source code installation failed. It is recommended to install the source code in centos/rhel 7 or above)
Source code installation package requirements:
CMake version 2.8or later (Packaging requires version 2.8.12 or later)
GCC version 4.4.7 or later
Libaio
OpenSSL
Bison 2.7 or later
Flex 2.5.35 or later
Libuuid
Rhel 5,6: libedit-devel MariaDB-devel MariaDB-server
Rhel 7: mariadb-devel mariadb-embedded-devel libedit-devel
[root@node3 MaxScale] # cd MaxScale-2.0
[root@node3 MaxScale-2.0] # cmake. /
Or specify the compilation parameters manually, as follows
Cmake. /-DCMAKE_INSTALL_PREFIX=/usr/local/maxscale\
-DMYSQL_DIR=/usr/local/mysql/include/\
-DEMBEDDED_LIB=/usr/local/mysql/lib/libmysqld.a\
-DMYSQL_EMBEDDED_LIBRARIES=/usr/local/mysql/lib/\
-DERRMSG=/usr/local/mysql/share/english/errmsg.sys
[root@node3 MaxScale-2.0] # make-j 8
[root@node3 MaxScale-2.0] # make install
3) binary installation
[root@node3 MaxScale] # mv maxscale-1.4.3-1.rhel.6.x86_64 / usr/local/maxscale
Add the following environment variables to ~ / .bash_profile
Export MAXSCALE_HOME=/usr/local/maxscale
Export LD_LIBRARY_PATH=/usr/local/maxscale/lib
MaxScale configuration:
Create two users for MaxScale in master for the monitoring module and routing module
Create a monitoring account
Mysql > create user maxscalemon@'%' identified by "monitor"
Mysql > grant replication slave, replication client on *. * to maxscalemon@'%'
Create a routed user
Mysql > create user maxscale@'%' identified by "maxscale"
Mysql > grant select on mysql.* to maxscale@'%'
Mysql > grant show databases on *. * to 'maxscale'@'%'
Mysql > flush privileges
Edit the configuration file:
The main modified files are the IP address and port of server1 and copy the corresponding server2,server3 configuration, modify the monitoring and routing configuration, and clear the read-only service configuration.
[root@node3 MaxScale] # cp / etc/maxscale.cnf / etc/maxscale.cnf_20160823
[root@node3 MaxScale] # vi / etc/maxscale.cnf
[maxscale]
Threads=1
[server1]
Type=server
Address=IP1
Port=3306
Protocol=MySQLBackend
[server2]
Type=server
Address=IP2
Port=3306
Protocol=MySQLBackend
[server3]
Type=server
Address=IP3
Port=3306
Protocol=MySQLBackend
[MySQL Monitor]
Type=monitor
Module=mysqlmon
Servers=server1,server2,server3
User=maxscalemon
Passwd=monitor # #-changed to an encrypted password
Monitor_interval=10000
[Read-Only Service]
Type=service
Router=readconnroute
Servers=server1,server2,server3
User=maxscale
Passwd=maxscale # #-changed to an encrypted password
Router_options=slave
[Read-Write Service]
Type=service
Router=readwritesplit
Servers=server1
User=maxscale
Passwd=maxscale # #-changed to an encrypted password
Max_slave_connections=100%
[MaxAdmin Service]
Type=service
Router=cli
[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
# socket=default
Port=6603
Encrypted password
[root@node3 ~] # maxkeys / var/lib/maxscale
Encryption profile password
[root@node3 ~] # maxpasswd / var/lib/maxscale/.secrets monitor
7429FE1AABA353442178F74131697531
[root@node3 ~] # maxpasswd / var/lib/maxscale/.secrets maxscale
26C20853B625AD18686C0D2AC8A11E60
Fill in the encrypted password into the configuration file
Start the maxscale service:
[root@node3 MaxScale] # maxscale-- config=/etc/maxscale.cnf
Or maxscale-f / etc/maxscale.cnf
5. Use of MaxScale
1) shut down, start, restart, check maxscale status, etc., through service service.
[root@node3 MaxScale] # service maxscale
Usage: / etc/init.d/maxscale {start | stop | status | restart | condrestart | reload}
2) start maxscale
Service maxscale start
Maxscale-f / etc/maxscale.conf
3) close maxscale
Service maxscale stop
4) Log in to the maxscale console for management
[root@node3 MaxScale] # maxadmin-uadmin-pmariadb-P6603
6. MaxScale read-write separation and load balancing test
Turn on general log
Mysql > show variables like 'general_log'
Mysql > set global general_log=1
[root@node3 MaxScale] # mysql-udbadmin-pdbadmin-hip3-P4008-e "select * from dbtest.t2"
[root@node2 ~] # tailf / usr/local/mysql/data/node2.log
166 Connect dbadmin@node3 on
166 Query select @ @ version_comment limit 1
166Query select * from dbtest.t1
[root@node3 MaxScale] # mysql-udbadmin-pdbadmin-hip3-P4008-e "select * from dbtest.t2"
[root@node3 ~] # tailf / usr/local/mysql/data/node3.log
160825 14:25:29 208 Connect dbadmin@node3 on
208 Query select @ @ version_comment limit 1
208 Query select * from dbtest.t2
208 Quit
179 Query SELECT @ @ server_id
179 Query SHOW SLAVE STATUS
160825 14:25:30 209 Connect dbadmin@node3 on
209 Query select @ @ version_comment limit 1
209 Query select * from dbtest.t2
209 Quit
160825 14:25:31 204 Query SELECT @ @ server_id
204 Query SHOW SLAVE STATUS
[root@node3 MaxScale] # mysql-udbadmin-pdbadmin-hip3-P4006-e "insert into dbtest.t2 values (1111)"
[root@node1 ~] # tailf / usr/local/mysql/data/node1.log
160825 14:26:53 203 Connect dbadmin@node3 on
203 Query select @ @ version_comment limit 1
203 Query insert into dbtest.t2 values (1111)
203 Quit
7. MaxScale installation error message and solution
Error message 01:
Initialized empty Git repository in / tools/MaxScale/MaxScale-2.0/build/connector-c-prefix/src/connector-c/.git/
Error: Couldn't resolve host 'github.com' while accessing https://github.com/MariaDB/mariadb-connector-c.git/info/refs
Fatal: HTTP request failed
Initialized empty Git repository in / tools/MaxScale/MaxScale-2.0/build/connector-c-prefix/src/connector-c/.git/
Error: Couldn't resolve host 'github.com' while accessing https://github.com/MariaDB/mariadb-connector-c.git/info/refs
Fatal: HTTP request failed
Initialized empty Git repository in / tools/MaxScale/MaxScale-2.0/build/connector-c-prefix/src/connector-c/.git/
Error: Couldn't resolve host 'github.com' while accessing https://github.com/MariaDB/mariadb-connector-c.git/info/refs
Fatal: HTTP request failed
-- Had to git clone more than once:
3 times.
CMake Error at / tools/MaxScale/MaxScale-2.0/build/connector-c-prefix/tmp/connector-c-gitclone.cmake:40 (message):
Failed to clone repository:
'https://github.com/MariaDB/mariadb-connector-c.git'
Make [2]: * * [connector-c-prefix/src/connector-c-stamp/connector-c-download] Error 1
Make [1]: * * [CMakeFiles/connector-c.dir/all] Error 2
Make: * * [all] Error 2
Solution:
The above error is a source code compilation error, and there is no good solution for now. If you can connect to the external network, you can compile and install it through the source code or use a server with a high version of os.
Error message 02:
2016-08-23 18:26:54 notice: Loaded module mysqlmon: V1.4.0 from / usr/lib64/maxscale/libmysqlmon.so
2016-08-23 18:26:54 notice: Encrypted password file / var/lib/maxscale/.secrets can't be accessed (No such file or directory). Password encryption is not used.
2016-08-23 18:26:54 error: 1 errors were encountered while processing the configuration file'/ etc/maxscale.cnf'.
2016-08-23 18:26:54 error: Failed to open, read or process the MaxScale configuration file / etc/maxscale.cnf. Exiting.
2016-08-23 18:26:54 MaxScale is shut down.
Solution:
Create a password file and replace the encrypted password in the configuration file.
Maxkeys / var/lib/maxscale
Maxpasswd / var/lib/maxscale/.secrets monitor
Maxpasswd / var/lib/maxscale/.secrets maxscale
Error message 03:
2016-08-24 11:48:43 notice: Loaded module readconnroute: V1.1.0 from / usr/lib64/maxscale/libreadconnroute.so
2016-08-24 11:48:43 error: The service 'Read-Only Service' is missing a definition of the servers that provide the service.
Solution:
Complete the readonly content in the configuration file, as follows
[Read-Only Service]
Type=service
Router=readconnroute
Servers=
User=maxscale
Passwd=26C20853B625AD18686C0D2AC8A11E60
Router_options=slave
Error message 04:
Rpm-ivh maxscale-1.4.3-1.rhel.6.x86_64.rpm
Warning: maxscale-1.4.3-1.rhel.6.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 8167ee24: NOKEY
Error: Failed dependencies:
Libcrypto.so.10 (libcrypto.so.10) (64bit) is needed by maxscale-1.4.3-1.x86_64
Libssl.so.10 (libssl.so.10) (64bit) is needed by maxscale-1.4.3-1.x86_64
Solution:
Solve the problem by upgrading openssl, rpm-Uvh openssl-1.0.1e-42.el6_7.1.x86_64.rpm-nodeps and rpm-Uvh openssl-devel-1.0.1e-42.el6_7.1.x86_64.rpm.
8. MaxScale Appendix
1) rpm default installation package related path
/ usr/share/maxscale/ share configuration installation path
/ var/lib/maxscale data file directory
/ usr/bin/maxscale execution file directory
/ var/log/maxscale log directory
/ usr/lib64/maxscale library file directory
2) detailed explanation of configuration file
[maxscale]
The number of open threads in threads=auto #. Default is 1. Set to auto with the same number of cores as cpu
Ms_timestamp=1 # timestamp precision
Syslog=1 # writes logs to syslog
Maxlog=1 # writes logs to the log file of maxscale
Log_to_shm=0 # does not write logs to the shared cache, but can be opened faster when debug mode is turned on
Log_warning=1 # record alarm information
Log_notice=1 # record notice
Log_info=1 # record info
Log_debug=0 # does not turn on debug mode
Log_augmentation=1 # log increment
# related directory settings. If you change the log and data file path of rpm, you need to create the corresponding directory and change the corresponding owner to maxscale.
Logdir=/usr/local/maxscale/log/
Datadir=/usr/local/maxscale/data/
Libdir=/usr/lib64/maxscale/
Cachedir=/usr/local/maxscale/cache/
Piddir=/usr/local/maxscale/
Execdir=/usr/bin/
# related monitoring information. The monitored user needs to have access to replication client to the backend database: grant replication client.
[MySQL Monitor]
Type=monitor
Module=mysqlmon
Servers=server1,server2,server3
User=root
Passwd=7AE087FBF864EBB87D108C3AB1603D0D
Monitor_interval=1000 # Monitoring heartbeat is 1 second
Detect_replication_lag=true # monitors the master-slave replication delay. You can specify the max_slave_replication_lag unit of router service in seconds to control the maximum delay of maxscale operation.
Detect_stale_master=true # when the replication slave is all broken, the maxscale is still available, directing all access to the
# slave separation of read-only nodes of read-only
[Read-Only Service]
Type=service
Router=readconnroute
Servers=server1,server2,server3
User=root
Passwd=7AE087FBF864EBB87D108C3AB1603D0D
Router_options=slave
Enable_root_user=1
# Separation of read and write. Users need to have the permission of SELECT ON mysql.db;SELECT ON mysql.tables_priv;SHOW DATABASES ON *. *
[Read-Write Service]
Type=service
Router=readwritesplit
Servers=server1,server2,server3
User=root
Passwd=7AE087FBF864EBB87D108C3AB1603D0D
The existing variable in the use_sql_variables_in=master # sql statement only points to execution in master
Enable_root_user=1 # allows root users to log in to execute
# master_accept_reads=true # master nodes can also forward read requests
Max_slave_replication_lag=5 # replication latency is up to 5 seconds (must be greater than interval of monitor)
3) shortcomings of maxscale
1) Compression protocol is not supported when creating a link
2) forwarding routing can not dynamically identify the migration of master nodes.
3) LONGLOB field is not supported
4) transfer the statement to the master node in the following cases (to ensure transaction consistency):
Explicitly specify the transaction
The statement of prepared
Statement contains stored procedures, custom functions
Contains multiple statement information: INSERT INTO...; SELECT LAST_INSERT_ID ()
5) some statements are sent to all backend server by default, but you can specify use_sql_variables_in= [master | all] (default: all)
6) maxscale does not support authentication mode with hostname matching, but only supports host resolution with IP address. So remember to use the appropriate paradigm when adding user.
7) Cross-database queries are not supported and will be displayed and specified in the first database
8) the behavior of changing session variables through select is not supported
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.