In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to use mycat to achieve read-write separation in mysql database. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
1 、 Deploy mycat download [root@mycat ~] # wget http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz decompress [root@mycat ~] # tar xf Mycat-server-1.6.5-release-20180122220033-linux.tar.gz-C / usr/local/1.1 important configuration file: server.xml schema.xml# configuration Mycat awareness configuration file MyCAT currently main To define logical libraries and related configurations through configuration files: / usr/local/mycat/conf/server.xml defines users and system-related variables Such as ports and so on. The user information is the user information in which the front-end application connects to the mycat. / usr/local/mycat/conf/schema.xml defines logical libraries, tables, sharding nodes, and so on. 1.2 configure server.xmlvim server.xml / / name= link myacat user 1 / / link mycat user password mycat_db / / virtual library, link the library name seen by mycat! Here are some commented-out configurations that can be configured according to your own needs.
If the virtual library mycat_db is configured above, the logic library must also be configured in the schema.xml file, otherwise an error will be reported and mycat will fail to start =
1.3Configuring schema.xml
As the original file is messy, you can drop the original file bak, create a new schema.xml yourself, and insert the following configuration
/ / numeric node name, start at will, and be consistent with the dataNode name below / / host group The real database name select user () / Health check / / mycat uses the user who connects to the real database and the password / / ditto You need to create and authorize 1.3.1 load balancer types in the database for the official document balance attribute of balance and writeType in the configuration file schema.xml. Currently, there are three values: 1. Balance= "0", the read-write separation mechanism is not enabled, and all read operations are sent to the currently available writeHost. 2. Balance= "1", all readHost and stand by writeHost participate in the load balancing of select statements. To put it simply, when the double master and double slave mode (M1-> S1 less M2-> S2, and M1 and M2 are the master and standby of each other), under normal circumstances, M2Magin S1 S2 participates in the load balancing of select statements. 3. Balance= "2", all read operations are randomly distributed on writeHost and readhost. 4. Balance= "3". All read requests are randomly distributed to the corresponding readhost of wiriterHost for execution. WriterHost does not bear the read pressure. Note that balance=3 is only available in version 1.4 and later. There are three types of load balancer with writeType attribute: 1. WriteType= "0". All write operations are sent to the first writeHost of the configuration, and the first is hung up to the second writeHost that is still alive. After reboot, the switch is recorded in the configuration file: dnindex.properties .2. WriteType= "1", it is not recommended that all write operations are randomly sent to the configured writeHost,1.5. The switchType attribute-1 indicates that it does not switch automatically. -1 default value, automatically switched. -2 decide whether to switch based on the status of MySQL master-slave synchronization.
Document link: http://www.mycat.io/document/mycat-definitive-guide.pdf
2. Starting [root@mycat ~] # / usr/local/mycat/bin/mycat start supports the following parameter start | restart | stop | status2.1 adds the user who connects to the database with mycat
In mysql
Mysql > create user 'hjt'@'%' idenfitied by' 1users; / / create users grant all on mycat_test.* to 'hjt'@'%'; / / authorize flush privileges; / / refresh authorization table 2.2 Test users
Test to test the validity of user rights on a mycat machine
Test whether you can log in to the master and slave server normally
Mysql-uhjt-p1-h292.168.10.129 mysql-uhjt-p1-h292.168.10.1302.3 Test mycat
Use the client to test whether you can log in to mycat
Note that the port number is: 8066
Root@mysqlclient ~] # mysql-umycatdb-p1-h292.168.10.128-P8066MySQL [(none)] > show databases +-+ | DATABASE | +-+ | mycat_db | +-+ 1 row in set (0.00 sec) the above is how to use mycat to achieve read-write separation in the mysql database shared by the editor. If you happen to have similar doubts, please refer to the above analysis for understanding. If you want to know more about it, you are welcome to follow the industry information channel.
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.