ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google’s Chubby, and a key component of Hadoop and Hbase. It provides consistency services for distributed applications, including configuration and maintenance, name service, distributed synchronization, and group service.
Dubbo is Alibaba’s open source distributed services framework, and its best feature is that it is built in a hierarchical way that allows for decoupling (or maximum loose coupling) between layers. From a service model perspective, Dubbo uses a very simple model where either the Provider provides the service or the Consumer consumes the service, so the roles of Provider and Consumer can be abstracted from this point of view. About registries, protocol support, service monitoring, and more.
Native environment: JDK:1.8
Maven: the apache Maven — 3.2.1
Zookeeper: zookeeper – 3.4.6
Tomcat: apache Tomcat — 7.0.62
Dubbo-admin:dubbo-admin-2.5.4 -snapshot. warDownload. CSDN [the.net] (http://lib.csdn.n…NET knowledge base)/detail/evankaka/9054273)
Install and start ZooKeeper
First, you need to install the JdK, which you download from Oracle’s Java website. The installation is simple and I won’t go into details. A zookeeper download address is www.apache.org/dyn/closer….
Before you execute the startup script, there are a few basic configuration items that need to be configured. The Zookeeper configuration file is in the conf directory. All you need to do is rename zoo_sample. CFG to zoo.cfg, because Zookeeper looks for this file as its default configuration file when it starts. The following details describe the meanings of the configuration items in this configuration file.
# 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=D:\\Java\\Tool\\zookeeper-3.46.\\tmp
# the port at which the clients will connect
clientPort=2181
# 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 auto purge feature
#autopurge.purgeInterval=1
Copy the code
the
dataDir=/tmp/zookeeper
Copy the code
Change to the following:
<pre name="code" class="html">dataDir=D:\\Java\\Tool\\zookeeper-3.46.\\tmp</pre>
Copy the code
I can change it to whatever I like,
TickTime: This is the interval for maintaining heartbeats between Zookeeper servers or between clients and servers, that is, one heartbeat is sent for each tickTime. DataDir: As the name suggests, this is the directory where Zookeeper saves data. By default, this is where Zookeeper keeps the log files that write data. DataLogDir: directory where Zookeeper logs are stored clientPort: This port is the port through which the client connects to the Zookeeper server. Zookeeper listens to this port and receives client access requests. After these configuration items are configured, you can start Zookeeper. To check whether Zookeeper is in service, run the netstat -ano command to check whether the clientPort number you configured is listening to the Zookeeper serviceCopy the code
It is easy to install the Zookeeper package and decompress it to a directory such as: D:\Java\Tool\zookeeper-3.4.6, the zooKeeper startup script is in the bin directory, Windows startup script is in the bin file, for example, D: \ Java \ Tool \ zookeeper – 3.4.6 \ bin \ zkServer CMD.
Start as follows:
Enter JPS. If the following is displayed, the startup is successful
The black box above is not on, which means the registry is always on. Be sure to remember that the registry is always on before the program is run
2. Installation of dubbo-admin management platform
1.1. Dubbo-admin is compiled and packaged locally
Because ZooKeeper is just a black box, we can’t see if there are any providers or consumers, so we need to use the Dubbo-Admin management platform to see in real time, and we can also manage vendors and consumers through this platform.
Dubbo-admin.war can be downloaded from baidu, but I downloaded several WAR packages, and the service startup error was reported when I released it. This time is probably caused by the JDK version of our system and the JDK version of compiling Dubbo-admin.war. So I downloaded the source code of Dubbo-Master directly and compiled a war package by myself, so there would be no startup error. (here strongly suggest oneself compile a, the basic that the net looks for is not good, tried a lot of, still oneself finally do) among them the process that oneself computer compiles is as follows, must install Maven and JDK!
All dubbo source code is available at github.com/alibaba/dub…
After extracting the contents of the file, you do not need to worry about the rest of the file, just dubbo-admin.
< dubbo-admin > < dubbo-admin > < dubbo-admin > < dubbo-admin > < dubbo-admin > < dubbo-admin > < dubbo-admin > < dubbo-admin > If there are any dependencies, Maven will take care of them automatically. The whole process is as follows:
First, go to the directory through CMD and enter the command
And then you type in the command
mvn package -Dmaven.skip.test=true
Copy the code
-dmaven.skip. test means no test package is packaged. Then the following result indicates that the package is successful
Open the project file at E:\ download \dubbo-master\dubbo-master\dubbo-admin\target
Target indicates the local path of the build, open it, and there is a file dubbo-admin-2.5.4 -snapshot. war, which indicates that the package was successfully packaged. This file must be placed in Tomcat to run.
**download. CSDN [. Net](http://lib.csdn.n… “.NET Knowledge base “)/detail/evankaka/9054273
1.2. Install Dubbo-admin
With Dubbo-admin packaged, the next step is much easierCopy the code
Copy dubbo-admin-2.5.4-snapshot. war to Tomcat Webapps 2. Configuration Change the Tomcat port 8088 by entering the server. XML file under conf. Zookeeper will use port 8080, so change the Tomcat port to avoid conflict. Remember to change!!
Then change
3. Start Tomcat and let it decompress war
The process is as follows
Then start
Found an extra folder under WebApp
Disable Tomcat by using the stop button
4. Modify dubbo.properties
D: \ Java \ Tool \ apache tomcat – 7.0.62 \ webapps \ dubbo – admin – 2.5.4 – the SNAPSHOT \ WEB – INF
Whether the following information is displayed:
dubbo.registry.address=zookeeper:/ / 127.0.0.1:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
Copy the code
If yes, you don’t need to change it. 127.0.0.1 is the IP address of your own computer, because zooKeeper is on your own computer. In general, there is no need to change, because the initial is the local IP address. But it’s safer to look
5. Visit:
Zookeeper must be started before Tomcat is started! Be sure to start ZooKeeper before starting Tomcat! Be sure to start ZooKeeper before starting Tomcat! Important things three times!
Start the zookeeper
Start tomcat
accesshttp://localhost:8088/dubbo-admin-2.5.4-SNAPSHOT/Be sure to note that the name must be the same as your webApp project name!!
The following pops up:
Enter the user name and password root
You will see:
If the following page is displayed, the installation is successful and the login password is root/root
Now that you’re done, you can start using ~~~~~~~~
Note:
In practice, an error occurs when dubbo-admin is deployed to Tomcat
Solution:
It turned out that the JDK version I used was too high, jdK8, and dubbo used the spring version by default, which was older, resulting in a conflict. Please make the following modifications
ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uriBrokerService': Cannot create inner bean '(inner bean)' of type [com.alibaba.citrus.service.uribroker.impl.URIBrokerServiceImpl$URIBrokerInfo] while setting bean property 'brokers' with key [0]; nested excepti
on is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#25': Cannot create inner bean 'server' of type [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker] while setting constructor argument; nested exception is org.springframework.beans.fact
ory.BeanCreationException: Error creating bean with name 'server': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker] :Bean property 'URIType'
is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java: 230).at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java: 122).at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java: 287).Copy the code
1. Change the webX dependency to 3.1.6;
<dependency>
<groupId>com.alibaba.citrus</groupId>
<artifactId>citrus-webx-all</artifactId>
<version>3.16.</version>
</dependency>
Copy the code
To add a dependency on Velocity, I used 1.7.
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
Copy the code
3. Add Exclusion to dependency Dubbo to avoid introducing old Spring
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
Copy the code
Webx has more than spring 3 dependencies, so comment out the Spring dependencies in dubbo-admin
<! --<dependency>--> <! --<groupId>org.springframework</groupId>--> <! --<artifactId>spring</artifactId>--> <! --</dependency>-->Copy the code
Recompile dubbo and put Tomcat running, successfully start!