Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mycat Learning practice-Mycat's zookeeper Cluster Model

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mycat Learning practice-Mycat's zookeeper Cluster Model

Learning mycat mysql

Mycat Learning practice-Mycat's zookeeper Cluster Model

1. Brief introduction to ZooKeeper

2. ZooKeeper roles and ports

3. Introduction to ZooKeeper deployment

4. ZooKeeper deployment Management Mycat

4.3.1 download and decompress

4.3.2 modify the configuration file

4.3.3 add myid Fil

4.3.4 synchronize the zookeeper directory to the other 2 nodes and modify the myid

4.3.5 start zookeeper

4.1 Environment

4.2 Environmental preparation

4.3 install zookeeper

4.4 install Mycat

4.6 execute mycat initialization data

4.7 configure mycat to support zookeeper

4.8Configuring mycat with zookeeper

1. Brief introduction to ZooKeeper

ZooKeeper is a building block for distributed systems. When designing a distributed system, you generally need to design and develop some coordination services:

Name service-A name service is a service that maps a name to some information associated with that name. A phone directory is a name service that maps a person's name to his or her phone number. Similarly, the DNS service is a name service that maps a domain name to an IP address. In a distributed system, you may want to track which servers or services are running and view their status by name. ZooKeeper exposes a simple interface to do this. You can also extend the name service to the group member service so that you can get information about the group associated with the entity whose name you are looking for.

Locking-to allow orderly access to shared resources in a distributed system, distributed mutex (distributed mutexes) may be required. ZooKeeper provides an easy way to implement them.

Synchronization-accompanied by mutexes is the need for synchronous access to shared resources. Whether it's implementing a producer-consumer queue or an obstacle, ZooKeeper provides a simple interface to implement this operation.

Configuration Management-you can use ZooKeeper to centrally store and manage the configuration of distributed systems. This means that all new nodes will be able to use the latest centralized configuration from ZooKeeper as soon as they join the system. This also allows you to change the centralized configuration through one of the ZooKeeper clients, centrally changing the state of the distributed system.

Leader election-distributed systems may have to deal with node downtime, and you may want to implement an automatic failover strategy. ZooKeeper provides ready-made support for this through leadership elections.

2. ZooKeeper roles and ports

3. Introduction to ZooKeeper deployment

4. ZooKeeper deployment Management Mycat

4.1 Environment

System: CentOS7.3

Jdk version: 1.7

Zookeeper version: 3.4.10

Mycat version: 1.6

HostnameIPmyidtestA192.168.33.111testB192.168.33.122testC192.168.33.1334.2 environment preparation

For testing convenience, the system firewall is turned off and selinux is disabled, while the production environment firewall needs to open zookeeper-related ports, 2181, 2888, 3888.

# turn off the firewall systemctl stop firewalld.servicesystemctl disable firewalld.service#, close the SELINUXsed-I Universe installation for zookeeper, install the zookeeper

Install it on the testA node and then synchronize to the other 2 nodes.

4.3.1 download and extract mkdir-p / data/packages/cd / data/packages/wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gzcd / usr/local/tar-zxvf / data/packages/zookeeper-3.4.10.tar.gzln-s zookeeper-3.4.10 zookeepercd zookeepermkdir data logcd conf/cp zoo_sample.cfg zoo.cfg4.3.2 modify configuration file

Vim zoo.cfg

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use / tmp for storage / tmp here is just # example sakes.dataDir=/usr/local/zookeeper/datadataLogDir=/usr/local/zookeeper/log# the port at which the clients will connectclientPort=2181server.1=192.168.33.11:2888:3888server.2=192.168.33.12:2888:3888server.3=192.168.33.13:2888:3888# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60## Be sure to read the maintenance section of the # administrator guide before turning on autopurge.## http://zookeeper.apache . org / doc/current/zookeeperAdmin.html#sc_maintenance## The number of snapshots to retain in dataDir#autopurge.snapRetainCount=3# Purge task interval in hours# Set to "0" to disable autopurge feature#autopurge.purgeInterval=14.3.3 add myid file

Vim / usr/local/zookeeper/data/myid write 1

4.3.4 synchronize the zookeeper directory to the other 2 nodes and modify myidrsync-avzP / usr/local/zookeeper/ root@192.168.33.12:/usr/local/zookeeper/rsync-avzP / usr/local/zookeeper/ root@192.168.33.13:/usr/local/zookeeper/

And modify the corresponding myid on the two nodes

4.3.5 launch zookeepercd / usr/local/zookeeper/bin/./zkServer.sh start

4.4 install Mycat

Again, mycat needs to be installed on all three nodes.

Cd / data/packages/wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gzcd / usr/local/tar-zxvf / data/packages/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz4.6 executes mycat initialization data

All three nodes of the Mycat execute the following script

Sh / usr/local/mycat/bin/init_zk_data.sh4.7 configure mycat to support zookeeper

Vim / usr/local/mycat/conf/myid.properties

Multiple loadZk=true# zk cluster addresses are used to separate the ID of this instance in the Mycat cluster IDclusterId=mycat-cluster-1# Mycat cluster in the zkURL=127.0.0.1:2181# zk cluster. It is forbidden to repeat the number of nodes in the myid=mycat_fz_01# Mycat cluster clusterSize=3clusterNodes=mycat_fz_01,mycat_fz_02,mycat_fz_03#server booster. Booster install on db same server,will reset all minCon to 1type=serverboosterDataHosts=dataHost14.8 uses zookeeper to configure mycat.

Use the ZooInspector tool to manage ZooKeeper. The following is the method of connecting zookeeper.

After the connection is successful, you can see the configuration of the mycat cluster

Modify the appropriate configuration

When you start mycat, the mycat configuration file is updated automatically.

Note:

LoadZk must be changed to true to take effect

The address of zkURL is separated by multiple intermediate ","

ClusterId, the cluster ID in the same zk must be unique

Myid: the id of this instance is unique within the current mycat cluster ID

After you configure zk and start mycat, the relevant configuration files under the local conf are updated.

Reference:

[1] http://mycat.io/

[2] "distributed database architecture and enterprise practice-- based on Mycat middleware"

[3] long GE official course Courseware

[4] http://zookeeper.apache.org/

[5] https://www.ibm.com/developerworks/cn/data/library/bd-zookeeper/

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report