【Dubbo03】消息队列与微服务之dubbo-admin 二进制与编译安装

时间:2024-12-04 08:43:04

实战案例:二进制安装 dubbo-admin

新版用Golang重构,提供了二进制包,可以直接部署

#下载二进制包
[root@ubuntu2204 ~]#wget https://github.com/apache/dubbo-admin/releases/download/0.5.0/apache-dubbo-admin-0.5.0-bin-release.tar.gz
[root@ubuntu2204 ~]#tar xf apache-dubbo-admin-0.5.0-bin-release.tar.gz -C /usr/local/
[root@ubuntu2204 ~]#ln -s /usr/local/apache-dubbo-admin-0.5.0-bin-release/ /usr/local/apache-dubbo-admin
[root@ubuntu2204 ~]#vim /usr/local/apache-dubbo-admin/bin/config/application.properties

admin.registry.address=zookeeper://zk1.wang.org:2181,zk2.wang.org:2181,zk3.wang.org:2181
admin.config-center=zookeeper://zk1.wang.org:2181,zk2.wang.org:2181,zk3.wang.org:2181
admin.metadata-report.address=zookeeper://zk1.wang.org:2181,zk2.wang.org:2181,zk3.wang.org:2181

[root@nacos ~]#/usr/local/apache-dubbo-admin/bin/startup.sh
dubbo-admin is starting,you can check the /usr/local/apache-dubbo-admin/logs/catlog.out
#观察日志
[root@nacos ~]#tail -f /usr/local/apache-dubbo-admin/logs/catlog.out

#登入账户密码
root
root

 

实战案例:编译安装 Dubbo的 Web 管理 Dubbo Admin

官方说明

https://github.com/apache/dubbo-adminhttps://github.com/apache/dubbo-admin

注意:  内存建议4G以上,且编译时间可能会花10分钟以上的时间
注意: 本项目支持Ubuntu22.04和JDK8和JDK11以下版本
当前项目已经用golang重构,需要下载指定branch为develop,再用downlaod zip 形式下载JAVA的源代码

编译 dubbo admin

[root@ubuntu2204 ~]#apt update && apt -y install maven
[root@ubuntu2204 ~]#mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.17, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-58-generic", arch: "amd64", family: "unix"
#镜像加速
[root@ubuntu2004 ~]#vim /etc/maven/settings.xml
 <mirrors>
   <!--阿里云镜像-->
   <mirror>
       <id>nexus-aliyun</id>
       <mirrorOf>*</mirrorOf>
       <name>Nexus aliyun</name>
       <url>http://maven.aliyun.com/nexus/content/groups/public</url>
   </mirror>                                                                             
 </mirrors>
[root@ubuntu1804 ~]#cd /usr/local/src/


#当前项目已经用golang重构,需要下载指定branch为develop
#方法1
[root@ubuntu1804 src]#git clone -b develop https://github.com/apache/dubbo-admin.git
#方法2
[root@ubuntu1804 src]#git clone  https://github.com/apache/dubbo-admin.git
[root@ubuntu1804 src]#cd dubbo-admin/
[root@ubuntu1804 dubbo-admin]#ls
cmd  conf  deploy  Dockerfile  docs  dubbo-admin-ui  go.mod  go.sum  hack  LICENSE  Makefile  NOTICE  pkg  README.md  README_ZH.md
[root@ubuntu1804 dubbo-admin]#git branch
* refactor-with-go
[root@ubuntu1804 dubbo-admin]#git checkout develop
分支 'develop' 设置为跟踪来自 'origin' 的远程分支 'develop'。
切换到一个新分支 'develop'
[root@ubuntu1804 dubbo-admin]#git branch
* develop
  refactor-with-go
[root@ubuntu1804 dubbo-admin]#ls
charts     DISCLAIMER  docker                    dubbo-admin-server  dubbo-admin-ui  LICENSE  mvnw.cmd  
pom.xml    README_ZH.md
codestyle  doc         dubbo-admin-distribution  dubbo-admin-test    kubernetes      mvnw     NOTICE    
README.md
#方法3:直接下载zip文件,再解压缩
[root@ubuntu1804 src]#ll dubbo-admin-develop.zip  
-h-rw-r--r-- 1 root root 1.2M Feb 18 16:08 dubbo-admin-develop.zip
[root@ubuntu1804 src]#unzip dubbo-admin-develop.zip 
#进入到源码目录
[root@ubuntu1804 src]#cd dubbo-admin-develop/
[root@ubuntu1804 dubbo-admin-develop]#pwd
/usr/local/src/dubbo-admin-develop
[root@ubuntu1804 dubbo-admin-develop]#ls
codestyle   doc     dubbo-admin-distribution  dubbo-admin-test  LICENSE  mvnw.cmd  pom.xml    README_ZH.md DISCLAIMER  docker  dubbo-admin-server        dubbo-admin-ui   

#修改zookeeper 地址为实际IP
[root@ubuntu1804 dubbo-admin-develop]#vim dubbo-admin-server/src/main/resources/application.properties
admin.registry.address=zookeeper://10.0.0.101:2181,10.0.0.102:2181,10.0.0.103:2181
admin.config-center=zookeeper://10.0.0.101:2181,10.0.0.102:2181,10.0.0.103:2181
admin.metadata-report.address=zookeeper://10.0.0.101:2181,10.0.0.102:2181,10.0.0.103:2181
#优化maven配置
[root@ubuntu1804 dubbo-admin-develop]#echo 'export MAVEN_OPTS="-Xmx2g -Xms2g"' >> /etc/profile.d/maven.sh
[root@ubuntu1804 dubbo-admin-develop]#source /etc/profile.d/maven.sh


#因为此项目中使用了nodejs,建议用下面方式加速
[root@ubuntu1804 dubbo-admin-develop]#apt -y install npm
[root@ubuntu1804 dubbo-admin-develop]#npm config get registry  
https://registry.npmjs.org/
[root@ubuntu1804 dubbo-admin-develop]#npm config set registry  https://registry.npm.taobao.org 
[root@ubuntu1804 dubbo-admin-develop]#npm config get registry
https://registry.npm.taobao.org/
 
 #编译方法1:执行java编译
[root@ubuntu1804 dubbo-admin-develop]#mvn clean package 
 mvnw     NOTICE    README.md
 #编译方法2:执行java源码编译并跳过测试单元,推荐此方式
[root@ubuntu1804 dubbo-admin-develop]#mvn clean install package -Dmaven.test.skip=true 

如果报错:

[ERROR] Killed
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 137
[ERROR] npm ERR! [dubbo-admin-ui@1.0.0](mailto:dubbo-admin-ui@1.0.0) build:`node build/build.js` 
[ERROR] npm ERR! Exit status 137
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the [dubbo-admin-ui@1.0.0](mailto:dubbo-admin-ui@1.0.0) build script.

解决办法:

服务器增加内存(推荐 4G 或以上),避免被内核OOM 

启动服务

#确保zookeeper已启动
[root@node1 ~]#zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower

#启动dubbo admin方法1
[root@ubuntu1804 ~]#cd /usr/local/src/dubbo-admin-develop;mvn --projects dubbo-admin-server spring-boot:run
#启动dubbo admin方法2
#指定用8888端口,默认8080
[root@ubuntu1804 ~]#java -jar /usr/local/src/dubbo-admin-develop/dubbo-admin-distribution/target/dubbo-admin-0.3.0-SNAPSHOT.jar--server.port=8888