Dubbo environment and Zookeeper installation

  The previous blog talked about some introductory theories about distributed ( portal ). Let’s build a distributed system today.

Dubbo environment construction

Dubbo official documents recommend that we use the Zookeeper registry, so first install Zookeeper and
forget to introduce what Zookeeper is.
ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google's Chubby, and an important component of Hadoop and Hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc. To put it bluntly, it is to play the Registry, all service registration and discovery are managed through it, and it is also officially recommended.
  
  Now install Zookeeper ( download address ), you need to pay attention to download the first one, starting from 3.5 +The naming has changed in the future. If it is named like apache-zookeeper-3.5.5.tar.gz, it is uncompiled, while it is named like apache-zookeeper-3.5.5-bin.tar.gz, It is the compiled package. Otherwise, even if you change the configuration file, it will still fail to start. Remember not to download the wrong one.
Insert picture description here
  It is worth noting that its source file can be run under Windows or Linux. The two systems run in the same way. Unzip file
Insert picture description here

  After decompressing the file, configure Zookeeper, copy the "zoo_sample.cfg" file under the conf file, and rename the copied file to "zoo.cfg", or rename it directly. This is its configuration file. You need to rely on it, otherwise the
Insert picture description here
  Zookeeper startup file that cannot be started is in the bin directory. According to the system to start different scripts, Windows directly double-click to run.
Insert picture description here
  If there is no flashback error, the Zookeeper service will start successfully. Do not close this interface after startup, otherwise The service is then closed.
Insert picture description here
  Now the server is started. You can connect and test through the client. Double-click to run the client.
Insert picture description here
  In order to better manage and monitor the dubbo service, the official provides a visual monitoring program dubbo-admin, this monitoring tool can be installed It is not installed. It is installed only for the convenience of viewing our services. Our future services are all in Linux, so the next services are installed in Linux

Dubbo-admin download address: https://github.com/apache/dubbo-admin , we need to package it into a jar package to run
it. It is recommended to download the master branch, which is relatively stable. It is also relatively simple to run, just package it and run it. The default port of the registry is 2181, the default port of the visualization tool is 7001, and the account password is root.

  And I downloaded the develop branch. It is said that the interface is better than the master branch, but it is not stable. Regardless of it, use it first. The same download source code is used. The front-end interface is written in Vue.

# 打包命令
mvn clean package -Dmaven.test.skip=true

  After the packaging is complete, the jar is in the dubbo-admin-distribution/target directory. You can try it locally. The zookeeper needs to be turned on before running, otherwise it will fail. This is the running interface, which is not necessarily so beautiful. . .
Insert picture description here
  In addition to this method, the official also provided us with a yml file, using docker to deploy dubbo

version: '3'

services:
  zookeeper:
    image: zookeeper
    ports:
      - 2181:2181
  admin:
    image: apache/dubbo-admin
    depends_on:
      - zookeeper
    ports:
      - 8080
    environment:
      - admin.registry.address=zookeeper://zookeeper:2181
      - admin.config-center=zookeeper://zookeeper:2181
      - admin.metadata-report.address=zookeeper://zookeeper:2181

  Then I deploy in the docker container of linux, I put it in a container, how to run two service commands in a container, please refer to this document

# 编写容器内的启动脚本,通过这个脚本去运行两个服务
# 这个脚本会在容器运行时就执行
#!bin/bash
set -m
/root/dubbo/apache-zookeeper-3.6.2-bin/bin/zkServer.sh start # zookeeper启动脚本
nohup java -jar /root/dubbo/dubbo.jar # dubbo-admin服务jar
fg %1

# 编写Dockerfile文件,通过Dockerfile文件构建镜像
FROM java:8
RUN echo "Asia/shanghai" > /etc/timezone
ADD *.jar /root/dubbo/dubbo.jar # dubbo-admin  jar 包
ADD *.tar.gz /root/dubbo/	# zookeeper 压缩包
ADD start.sh /root/dubbo/ # 启动脚本
RUN cp /root/dubbo/apache-zookeeper-3.6.2-bin/conf/zoo_sample.cfg /root/dubbo/apache-zookeeper-3.6.2-bin/conf/zoo.cfg
EXPOSE 8888 # dubbo-admin 的端口
EXPOSE 2181 # zookeeper 端口
ENTRYPOINT ["sh","./root/dubbo/start.sh"] # 容器启动时运行的命令

# 文件编写完成后,执行创建镜像
docker build -t dubbo .

  After the container is created and running,
  
  
  the construction of zookeeper can be accessed through IP. This is the end, and the resources have been uploaded to CSDN. Download link: https://download.csdn.net/download/weixin_45481406/13109036

Guess you like

Origin blog.csdn.net/weixin_45481406/article/details/109606936