Build Springmvc+mybatis+dubbo Distributed Platform-zookeeper Registry installation

Source: Internet
Author: User
Tags zookeeper zookeeper client

Tag: res indicates host digital Roo led back to NTP root

On an introduction to "Building Dubbo distributed Platform-dubbo", combined with Dubbo Basic introduction, today we will learn the installation based on zookeeper registry.

Registration Center

1. We recommend using the Zookeeper Registration Center client with dubbo-2.3.3 or above version

2, Zookeeper is Apache Hadoop sub-project, the strength is relatively good, it is recommended that the production environment to use the registration center.

3, Dubbo does not make any intrusion modification to the zookeeper server, just install the native zookeeper server, all the registration center logical adaptation is done when the zookeeper client is called.

Install the Dubbo registry as follows:

1, modify the operating system of the/etc/hosts file to add:

Zookeeper servers

127.0.0.1 ant-provider-01

2, to http://apache.fayea.com/zookeeper/download zookeeper-3.4.6:

$ wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

3, Decompression zookeeper installation package:

$ TAR-ZXVF zookeeper-3.4.6.tar.gz

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

$ cd/home/ant/zookeeper-3.4.6

$ mkdir Data

$ mkdir Logs

5, copy the Zoo_sample.cfg file under the zookeeper-3.4.6/conf directory, named as Zoo.cfg

$ CP zoo_sample.cfg Zoo.cfg

6. Modify the Zoo.cfg configuration file:

$ VI zoo.cfg

The number of milliseconds of each tick

ticktime=2000

The number of ticks that 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.

Don't use/tmp for storage,/tmp here's 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 would connect

clientport=2181

#2888, 3888 is election port

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

which

The 2888 port number is the port of communication between the zookeeper services.

3888 is the port that zookeeper communicates with other applications.

ANT-PROVIDER-01 is the host name of the IP that was mapped in the hosts.

Initlimit: This configuration item is used to configure the Zookeeper accept client (the client here is not the client connecting the Zookeeper server, but the Zookeeper server cluster is connected to the

Leader Follower Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. The client connection failed when the Zookeeper server has not received the return information of the client after 10 heartbeats (that is, ticktime) length. The total length of time is 5*2000=10 seconds.

Synclimit: This configuration item identifies the length of time that a message, request and response is sent between Leader and Follower, the maximum number of ticktime, and the total length of time is 2*2000=4 seconds.

Server. A=b:c:d: Where A is a number, indicating this is the name of the server, B is the IP address of the server or the/etc/hosts file mapped the IP hostname, C is the server and the Leader server in the cluster to exchange information on the port; D indicates that in the event of a cluster The Leader server hangs up and requires a port to re-elect a new Leader, which is the port that the server communicates with each other when the election is performed. If it is a pseudo-cluster configuration, because B is the same, so different Zookeeper instance communication port number can not be the same, so they should be assigned a different port number

7. Create the myID file under Datadir=/home/ant/zookeeper-3.4.6/data

Edit the myID file and enter the corresponding number on the corresponding IP machine. As on zookeeper, the contents of the myID file are 1. If the installation is configured only on a single point, then there is only one server.1.

$ VI myID

8, the ant user modifies the vi/home/ant/.bash_profile, increases the zookeeper configuration:

Zookeeper Env

Export zookeeper_home=/home/ant/zookeeper-3.4.6

Export path= $ZOOKEEPER _home/bin: $PATH

Make the configuration file effective $ source/home/ant/.bash_profile

9, open the firewall to use the port 2181, 2888, 3888 switch to root user rights, execute the following command:

Chkconfig iptables on

Service Iptables Start

Edit/etc/sysconfig/iptables

Vi/etc/sysconfig/iptables

Add the following 3 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

Restart Firewall: # service iptables restart

To view 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

3 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

8 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

1 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

10. Start and Test zookeeper (to start with ant user, do not use root):

(1) Use Ant user to execute in/home/ant/zookeeper-3.4.6/bin directory:

$ zkserver.sh Start

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

$ JPS

1456 Quorumpeermain

1475 Jps

Wherein, Quorumpeermain is the zookeeper process, starts the normal

(3) View status:

$ zkserver.sh Status

(4) View Zookeeper service output information:

Because 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 boot using ant User:

Edit/etc/rc.local file, add:

Su-ant-c '/home/ant/zookeeper-3.4.6/bin/zkserver.sh start '

Welcome to join me in learning "build Dubbo Distributed platform", I hope you continue to pay attention to the following articles!

Build Springmvc+mybatis+dubbo Distributed Platform-zookeeper Registry installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.