The registry

1. You are advised to use the ZooKeeper registry client of dubo-2.3.3 or later

2. Zookeeper is a subproject of Apache Hadoop. It is recommended to use this registry in production environments.

3. Dubbo does not make any intrusive modifications to the Zookeeper server, and only needs to install the native Zookeeper server. All registry logical adaptation is completed when the Zookeeper client is called.

Install the Dubbo registry as follows:

1. Add the following information to the /etc/hosts file of the OS:

zookeeper servers

127.0.0.1 ant – the provider – 01

2, under the apache.fayea.com/zookeeper/… Zookeeper – 3.4.6:

$wget apache.fayea.com/zookeeper/z…

Decompress the ZooKeeper installation package.

$tar – ZXVF zookeeper – 3.4.6. Tar. Gz

4. Create the following directories under /home/ant/zookeeper-3.4.6:

$ cd /home/ant/zookeeper-3.4.6

$ mkdir data

$ mkdir logs

5. Copy the zoo_sample. CFG file from the zookeeper-3.4.6/conf directory to zoo.cfg

$ cp zoo_sample.cfg zoo.cfg

6, modify zoo. CFG configuration file:

$ vi zoo.cfg

The number of milliseconds of each tick

tickTime=2000

The number of ticks that the initial

synchronization phase can take

initLimit=10

The number of ticks that can pass between

sending a request and getting an acknowledgement

syncLimit=5

the directory where the snapshot is stored.

do not use /tmp for storage, /tmp here is just

example sakes.

DataDir = / home/ant/zookeeper – 3.4.6 / data

DataLogDir = / home/ant/zookeeper – 3.4.6 / logs

the port at which the clients will connect

clientPort=2181

8 are # 2888388 election port

server.1=ant-provider-01:2888:3888

Among them,

2888 Port number Is used for communication between ZooKeeper services.

3888 is the port used by ZooKeeper to communicate with other applications.

Ant-provider-01 is the name of the host whose IP address is mapped to the hosts.

InitLimit: This configuration item is used to configure Zookeeper to accept clients. (The client is not the client that the user connects to the Zookeeper server, but is connected to in the Zookeeper server cluster

The maximum number of heartbeat intervals that the Leader’s Follower server can tolerate when initializing the connection. If the Zookeeper server does not receive any message from the client after the tickTime period exceeds 10 heartbeats, the connection to the client fails. The total length of time is 5 times 2000 is 10 seconds.

SyncLimit: This configuration item identifies the maximum number of Ticktimes between the Leader and Follower to send messages, request and reply. The total time is 2 x 2000=4 seconds.

Server. A=B:C:D: where A is A number indicating the number of the server. B is the IP address of the server or the host name mapped to the IP in the /etc/hosts file. C represents the port through which the server exchanges information with the Leader server in the cluster. D indicates that in case of the failure of the Leader server in the cluster, a port is needed to re-elect a new Leader, and this port is used to communicate with each other during the election. In the pseudo-cluster configuration mode, different Zookeeper instances cannot communicate with the same port number because B is the same. Therefore, they need to be assigned different port numbers

Create myID file under dataDir=/home/ant/zookeeper-3.4.6/data

Edit the myID file and enter the corresponding number on the machine with the corresponding IP. On ZooKeeper, the myID file is 1. If the installation configuration is done on a single point, there is only one Server.1.

$ vi myid

Run the following command to modify the zooKeeper configuration file: vi /home/ant/.bash_profile

zookeeper env

Export ZOOKEEPER_HOME = / home/ant/zookeeper – 3.4.6

export PATH=PATH

$source /home/ant/.bash_profile

9. Open ports 2181, 2888, and 3888 on the firewall to switch to user root and run the following command:

chkconfig iptables on

service iptables start

Edit/etc/sysconfig/iptables

vi /etc/sysconfig/iptables

Add the following three lines:

-A INPUT -m state –state NEW -m tcp -p tcp –dport 2181 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 2888 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 3888 -j ACCEPT

# service iptables restart

Check the firewall port status:

service iptables status

Table: filter

Chain INPUT (policy ACCEPT)

num target prot opt source destination

1 ACCEPT all — 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

2 ACCEPT icmp — 0.0.0.0/0 0.0.0.0/0

ACCEPT all — 0.0.0.0/0 0.0.0.0/0

4 ACCEPT TCP — 0.0.0.0/0 0.0.0.0/0 state NEW TCP DPT :22

5 ACCEPT TCP — 0.0.0.0/0 0.0.0.0/0 state NEW TCP DPT :2181

6 ACCEPT TCP — 0.0.0.0/0 0.0.0.0/0 state NEW TCP DPT :2888

7 ACCEPT TCP — 0.0.0.0/0 0.0.0.0/0 state NEW TCP DPT :3888

REJECT all — 0.0.0.0/0 0.0.0.0/0 REJECT -with ICMP-host-prohibited

Chain FORWARD (policy ACCEPT)

num target prot opt source destination

REJECT all — 0.0.0.0/0 0.0.0.0/0 REJECT -with ICMP-host-prohibited

Chain OUTPUT (policy ACCEPT)

num target prot opt source destination

Start and test ZooKeeper (use ant, not root) :

Go to the /home/ant/zookeeper-3.4.6/bin directory as the ant user and run the following command:

$ zkServer.sh start

(2) Enter the JPS command to view the process:

$ jps

1456 QuorumPeerMain

1475 Jps

QuorumPeerMain is the ZooKeeper process and is running properly

(3) Check the status:

$ zkServer.sh status

(4) View the output of the ZooKeeper service.

The service information output file is in /home/ant/zookeeper-3.4.6/bin/zookeeper.out

$ tail -500f zookeeper.out

11. Stop the ZooKeeper process:

$ zkServer.sh stop

12. Configure zooKeeper to start as ant user:

Edit the /etc/rc.local file and add:

Su – ant-c ‘/home/ant/zookeeper-3.4.6/bin/ zkserver. sh start’