Zookeeper Cluster +dubbo+spring Integration

Source: Internet
Author: User
Tags zookeeper

First, Introduction

Dubbo is the Alibaba Open source distributed service framework, and its biggest feature is the layered approach to architecting, which allows for decoupling (or maximum coupling) between layers. From the point of view of the service model, Dubbo uses a very simple model, either the provider service or consumer consumption services, so it can be abstracted from the service provider (Provider) and the service consumer (Consumer) two roles. About the Registry, protocol support, service monitoring and other content.
Main Core components:

* Remoting: Network communication Framework, the implementation of Sync-over-async and request-response message mechanism.

* RPC: Abstraction of a remote procedure call that supports load balancing, disaster recovery, and cluster functionality

* Registry: Service catalog framework for service registration and service event Publishing and subscriptions

Dubbo Working principle
* Provider
* The disclosing service is referred to as the "service provider".
* Consumer
* Call the remote service to call the "service consumer".
* Registry (using zookeeper)
* Service registration and Discovery Central Directory service is called "Service Registry".
* Monitor
* The log service for call times and call times for statistical services is called the Service Monitoring Center.


II. Provider Installation and Deployment
1.JDK Installation
1.1 Checking and uninstalling your own JDK
[Email protected] ~]# java-version
Java Version "1.6.0_24"
[Email protected] ~]# Rpm-qa | grep java
[Email protected] ~]# rpm-e--nodeps tzdata-java-2013g-1.el6.noarch
[Email protected] ~]# rpm-e--nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[Email protected] ~]# rpm-e--nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

1.2 Installing jdk1.7
Upload JDK
TAR-ZXVF jdk-7u55-linux-x64.tar.gz
Cp-r Jdk1.7.0_55/usr/java
# Vim/etc/profile
Modify/etc/profile last Face join
Export Java_home=/usr/java
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin
Save exit. Run #source/etc/profile
# update-alternatives--install/usr/bin/java Java/usr/java/jdk1.7.0_55/bin/java 60
# update-alternatives--config Java
# java-version

2.TOMCAT Installation
2.1 Download & Install
wget http://mirror.bit.edu.cn/apache/... omcat-7.0.57.tar.gz
TAR-XZVF apache-tomcat-7.0.57.tar.gz
#将解压缩后的文件夹拷贝到/OPT/TOMCAT7:
Cp-r APACHE-TOMCAT-7.0.57/OPT/TOMCAT7
#添加专用OS用户
Useradd-s/sbin/nologin Tomcat
Chown-r TOMCAT:TOMCAT/OPT/TOMCAT7
#进入tomcat目录设置tomcat memory usage and other configurations:
Cd/opt/tomcat7/bin
VI daemon.sh
#在正文开始的地方加入以下内容 (memory, etc. to be combined with hardware tuning) "This script can be uploaded directly"
# chkconfig:2345 20 80
# Description:simple Example to start Tomcat
Java_home=/usr/java
Catalina_home=/opt/tomcat7
Catalina_opts= "-XMS1024M-XMX4096M-XX:PERMSIZE=256M-XX:MAXPERMSIZE=512M-XX:+HEAPDUMPONOUTOFMEMORYERROR-XX: Heapdumppath=/var/log/tomcat "

2.2 Set as self-starting service
wget http://mirror.bit.edu.cn/apache/... n-1.0.15-src.tar.gz
TAR-ZXVF commons-daemon-1.0.15-src.tar.gz
CD Commons-daemon-1.0.15-src/src/native/unix
./configure
Make
#复制jsvc到 the/opt/tomcat7/bin directory below
CP Jsvc/opt/tomcat7/bin
CP Jsvc/etc/bin
Cd/opt/tomcat7/bin
CP Daemon.sh/etc/init.d/tomcat
chmod 755/etc/init.d/tomcat
Chkconfig--add Tomcat
Chkconfig Tomcat on
Chkconfig--list Tomcat
Show:
Tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off← confirm 2~5 is on status OK

2.3 Starting Tomcat
Service Tomcat Start
#增加防火墙配置, allow port 8080 to "temporarily do not turn on the firewall":
Vi/etc/sysconfig/iptables
#在允许ssh的下面增加一条 (Open Permissions!!! for Web servers only) :
Iptables-a input-p tcp-s 192.168.1.1--dport 8080-j ACCEPT
/etc/rc.d/init.d/iptables Save
Service Iptables Restart
Iptables-l-N
2.4 Viewing the Tomcat process
PS aux | grep Tomcat

third, Zk+dubbo installation
Tomcat See above

3.ZOOKEEPER Install "pseudo-cluster"
3.1 Download and install
wget http://mirrors.cnnic.cn/apache/z ... keeper-3.4.6.tar.gz
Tar xzvf zookeeper-3.4.6.tar.gz
Cp-r Zookeeper-3.4.6/zookeeper/server1
Cp-r Zookeeper-3.4.6/zookeeper/server2
Cp-r Zookeeper-3.4.6/zookeeper/server3
#建立data和log目录
Mkdir-p/zookeeper/server1/data
Mkdir-p/zookeeper/server1/logs
Mkdir-p/zookeeper/server2/data
Mkdir-p/zookeeper/server2/logs
Mkdir-p/zookeeper/server3/data
Mkdir-p/zookeeper/server3/logs

3.2 Configuration
#那么首先进入 "Data" directory, create a myID file, write a number, such as my this is server1, then write a 1,server2 corresponding myID file write 2,server3 corresponding myID file write a 3
Echo 1 >myid

Cd/zookeeper/server1/conf

CP Zoo_sample.cfg Zoo.cfg
MV Zoo_sample.cfg Zoo_sample.cfg.bak

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.
# do not use/tmp for storage,/tmp here are just
# example Sakes.

#注意修改
Datadir=/zookeeper/server1/data
Datalogdir=/zookeeper/server1/logs
# The port at which the clients would connect
clientport=2181
#
# Be sure to read the maintenance section of the
# Administrator Guide before turning on Autopurge.
#
# http://zookeeper.apache.org/doc/... html#sc_maintenance
#
# The number of snapshots to retain in DataDir
#autopurge. snapretaincount=3
# Purge task interval in hours
# Set to ' 0 ' to disable Auto Purge feature
#autopurge. purgeinterval=1

#在文件末尾添加如下内容:

server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

#需要注意的是clientPort这个端口如果你是在1台机器上部署多个server, then each machine needs a different clientport,
For example I server1 is 2181,server2 is 2182,server3 is 2183,datadir and Datalogdir also need to distinguish.

#最后几行唯一需要注意的地方就是 server. X this number is the corresponding number in the Data/myid. You have written in the myID file of 3 servers, respectively,
Then the zoo.cfg in each server will be OK with server.1,server.2,server.3. Because on the same machine, the 2 ports attached to the back of the 3 servers are not the same,
Otherwise, the port conflicts, where the first port is used for the information exchange of the cluster members, and the second port is used exclusively for election leader when the leader is hung out.

Server2 and Server3 configuration see Server1

3.3 Start
#分别进入三个服务器的zookeeper The -3.4.3/bin directory, start the service
./zkserver.sh Start
/zookeeper/server1/bin/zkserver.sh start
/zookeeper/server2/bin/zkserver.sh start
/zookeeper/server3/bin/zkserver.sh start

#启动完成后, view server status
./zkserver.sh Status

3.4 Access Client
#进入任意一个服务器的zookeeper The/bin directory, start a client, Access service.
./zkcli.sh–server localhost:3181

4.DUBBOADMIN Configuration
CP Dubbo-admin-2.8.4-snapshot.war/opt/tomcat7/webapps
Service Tomcat Stop
Service Tomcat Start
Cd/opt/tomcat7/webapps
MV Dubbo-admin-2.8.4-snapshot Dubbo
Service Tomcat Stop
Service Tomcat Start

Access Dubbo background: Http://localhost:8080/dubbo default username/password: root/root


Core technologies: Maven,springmvc MyBatis Shiro, Druid, Restful, Dubbo, Zookeeper,redis,fastdfs,activemq,nginx
1. Project Core code Structure

Project Module Dependencies

Special Reminder: Developers can service or Dubbo their business rest when developing

2. Project Dependency Introduction

2.1 Backend Management system, rest service system, Scheculer timing dispatch system depend on such as:

2.2 Dubbo Independent service projects depend on such as:

3. Project function section:


Zookeeper, Dubbo service startup


Dubbo Control Console

Rest Service Platform comment on this one

Zookeeper Cluster +dubbo+spring Integration

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.