dubbo+zookeeper的配置和启动

一、在Linux系统中安装Java(yum一键安装

参考网址:https://blog.csdn.net/qq_42815754/article/details/82968464

1、查看可安装的jdk版本:yum -y list java*

dubbo+zookeeper的配置和启动_第1张图片

2、选择自己需要的jdk版本进行安装:yum install -y java-1.8.0-openjdk-devel.x86_64,等待安装完成即可。

3、安装完成之后,查看安装的jdk版本:java -version

二、上传相关安装包到Linux的opt目录,并赋予权限:

dubbo+zookeeper的配置和启动_第2张图片

1、解压tomcat:tar -zxvf apache-tomcat-8.5.24.tar.gz

2、解压dubbo:unzip -d dubbo-admin dubbo-admin-2.6.0.war(如果遇到:-bash: unzip: command not found,安装压缩:yum -y install unzip)

3、解压zookeeper:tar -zxvf zookeeper-3.4.11.tar.gz

4、启动zookeeper

(1)进入zookeeper目录:cd zookeeper-3.4.11

(2)创建data目录:mkdir data

(3)修改配置文件,cd conf/--->cp zoo_sample.cfg zoo.cfg--->vi zoo.cfg,修改dataDir=/opt/zookeeper-3.4.11/data

dubbo+zookeeper的配置和启动_第3张图片

(4)启动:./opt/zookeeper-3.4.11/bin/zkServer.sh start

5、配置、启动tomcat访问dubbo

(1)修改配置文件:vi /opt/apache-tomcat-8.5.24/conf/server.xml,

dubbo+zookeeper的配置和启动_第4张图片

(2)启动tomcat:sh /opt/apache-tomcat-8.5.24/bin/startup.sh

(3)浏览器访问:http://192.168.50.3:8080/,账号和密码均为:rootdubbo+zookeeper的配置和启动_第5张图片

dubbo+zookeeper的配置和启动_第6张图片

三、制作开机自启动服务

1、制作服务

(1)进入脚本目录:cd /etc/init.d

(2)创建zookeeper脚本并授权:touch zookeeper,chmod +x zookeeper

dubbo+zookeeper的配置和启动_第7张图片

(3)添加脚本:vi zookeeper,注意ZK_PATH、JAVA_HOME要与系统一致。

#!/bin/bash
#chkconfig:2345 20 90
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
ZK_PATH=/opt/zookeeper-3.4.11
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64
case $1 in
         start) sh  $ZK_PATH/bin/zkServer.sh start;;
         stop)  sh  $ZK_PATH/bin/zkServer.sh stop;;
         status) sh  $ZK_PATH/bin/zkServer.sh status;;
         restart) sh $ZK_PATH/bin/zkServer.sh restart;;
         *)  echo "require start|stop|status|restart"  ;;
esac

(4)创建dubbo-admin脚本并授权:touch dubbo-admin,chmod +x dubbo-admin

dubbo+zookeeper的配置和启动_第8张图片

(5)添加脚本,vi dubbo-admin,注意processname、CATALANA_HOME、JAVA_HOME要与系统一致。

#!/bin/bash
#chkconfig:2345 20 90
#description:dubbo-admin
#processname:dubbo-admin
CATALANA_HOME=/opt/apache-tomcat-8.5.24
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64
case $1 in
start)  
    echo "Starting Tomcat..."  
    $CATALANA_HOME/bin/startup.sh  
    ;;  
  
stop)  
    echo "Stopping Tomcat..."  
    $CATALANA_HOME/bin/shutdown.sh  
    ;;  
  
restart)  
    echo "Stopping Tomcat..."  
    $CATALANA_HOME/bin/shutdown.sh  
    sleep 2  
    echo  
    echo "Starting Tomcat..."  
    $CATALANA_HOME/bin/startup.sh  
    ;;  
*)  
    echo "Usage: tomcat {start|stop|restart}"  
    ;; esac
 

(6)添加到系统服务:chkconfig --add dubbo-admin、chkconfig --add zookeeper

(7)service dubbo-admin on、service dubbo-admin on

(8)重启系统

(9)验证:ps -ef|grep java、ps -ef|grep zookeeper

你可能感兴趣的:(dubbo+zookeeper的配置和启动)