dubbo搭建

环境:

OS版本:CentOS 7.2

jdk "1.7.0_79"

Zookeeper version: 3.3.6-1366786

Dubbo版本:2.5.3

Apache Tomcat 7.0.69

测试环境为防止干扰,可检查并关闭linux安全设置:

# getenforce

Enforcing

# setenforce 0

编辑selinux,修改如下内容:

SELINUX=enforcing

vi /etc/sysconfig/selinux

SELINUX=disabled

#systemctl stop firewalld.service

#systemctl disable firewalld.service

1.设置主机名:

[[email protected] ~]# hostnamectl set-hostname test-dubbosvr

2.编辑hosts文件,添加记录:

ip hostname

# vi /etc/hosts

3.安装JDK:

下载jdk-7u79-linux-x64.tar.gz至/usr/local/src目录

建立安装目录:

# mkdir -pv /usr/local/java

mkdir: created directory ‘/usr/local/java’

解压jdk-7u79-linux-x64.tar.gz

[[email protected] src]# tar zxf jdk-7u79-linux-x64.tar.gz

[[email protected] src]# mv jdk1.7.0_79 /usr/local/java

检测当前java版本:

# java -version

-bash: java: command not found

安装jdk:

# alternatives --install /usr/bin/java java /usr/local/java/jdk1.7.0_79/bin/java 2

# alternatives --config java

There is 1 program that provides ‘java‘.

Selection    Command

-----------------------------------------------

*+ 1           /usr/local/java/jdk1.7.0_79/bin/java

Enter to keep the current selection[+], or type selection number:Please Enter

# alternatives --install /usr/bin/jar jar /usr/local/java/jdk1.7.0_79/bin/jar 2

# alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.7.0_79/bin/javac 2

检测java版本:

# java -version

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

配置环境变量:

# vi /etc/profile

添加内容:

export JAVA_HOME=/usr/local/java/jdk1.7.0_79

export JRE_HOME=/usr/local/java/jdk1.7.0_79/jre

export PATH=$PATH:/usr/local/java/jdk1.7.0_79/bin:/usr/local/java/jdk1.7.0_79/jre/bin

 

使环境变量生效:source /etc/profile

4.安装zookeeper(三节点伪分布式集群):

下载zookeeper-3.3.6.tar.gz至/usr/local/src目录

解压zookeeper-3.3.6.tar.gz

# tar zxf zookeeper-3.3.6.tar.gz

建立安装目录:

# mkdir -pv /usr/local/zookeeper/{server01,server02,server03}

mkdir: created directory ‘/usr/local/zookeeper’

mkdir: created directory ‘/usr/local/zookeeper/server01’

mkdir: created directory ‘/usr/local/zookeeper/server02’

mkdir: created directory ‘/usr/local/zookeeper/server03’

建立logs,data目录:

# mkdir -pv /usr/local/zookeeper/server01/{logs,data}

mkdir: created directory ‘/usr/local/zookeeper/server01/logs’

mkdir: created directory ‘/usr/local/zookeeper/server01/data’

# mkdir -pv /usr/local/zookeeper/server02/{logs,data}

mkdir: created directory ‘/usr/local/zookeeper/server02/logs’

mkdir: created directory ‘/usr/local/zookeeper/server02/data’

# mkdir -pv /usr/local/zookeeper/server03/{logs,data}

mkdir: created directory ‘/usr/local/zookeeper/server03/logs’

mkdir: created directory ‘/usr/local/zookeeper/server03/data’

# cd /usr/local/src/zookeeper-3.3.6/conf

# cp zoo_sample.cfg zoo.cfg

编辑zoo.cfg,内容如下:

# 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.

dataDir=/usr/local/zookeeper/server01/data

dataLogDir=/usr/local/zookeeper/server01/logs

# the port at which the clients will connect

clientPort=2181

server.1=192.168.195.136:2888:3888

server.2=192.168.195.136:2889:3889

server.3=192.168.195.136:2890:3890

复制/usr/local/src/zookeeper-3.3.6至/usr/local/zookeeper/server01目录下:

# cp -ar /usr/local/src/zookeeper-3.3.6 /usr/local/zookeeper/server01

# echo 1 > /usr/local/zookeeper/server01/data/myid

编辑/usr/local/src/zookeeper-3.3.6/conf/zoo.cfg,内容如下:

# 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.

dataDir=/usr/local/zookeeper/server02/data

dataLogDir=/usr/local/zookeeper/server02/logs

# the port at which the clients will connect

clientPort=2182

server.1=192.168.195.136:2888:3888

server.2=192.168.195.136:2889:3889

server.3=192.168.195.136:2890:3890

复制/usr/local/src/zookeeper-3.3.6至/usr/local/zookeeper/server02目录下:

# cp -ar /usr/local/src/zookeeper-3.3.6 /usr/local/zookeeper/server02

# echo 2 > /usr/local/zookeeper/server02/data/myid

编辑/usr/local/src/zookeeper-3.3.6/conf/zoo.cfg,内容如下:

# 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.

dataDir=/usr/local/zookeeper/server03/data

dataLogDir=/usr/local/zookeeper/server03/logs

# the port at which the clients will connect

clientPort=2183

server.1=192.168.195.136:2888:3888

server.2=192.168.195.136:2889:3889

server.3=192.168.195.136:2890:3890

复制/usr/local/src/zookeeper-3.3.6至/usr/local/zookeeper/server03目录下:

# cp -ar /usr/local/src/zookeeper-3.3.6 /usr/local/zookeeper/server03

# echo 3 > /usr/local/zookeeper/server03/data/myid

启动zookeeper(zkServer.sh start):

# /usr/local/zookeeper/server01/zookeeper-3.3.6/bin/zkServer.sh start

JMX enabled by default

Using config: /usr/local/zookeeper/server01/zookeeper-3.3.6/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

# /usr/local/zookeeper/server02/zookeeper-3.3.6/bin/zkServer.sh start

JMX enabled by default

Using config: /usr/local/zookeeper/server02/zookeeper-3.3.6/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

# /usr/local/zookeeper/server03/zookeeper-3.3.6/bin/zkServer.sh start

JMX enabled by default

Using config: /usr/local/zookeeper/server03/zookeeper-3.3.6/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

查看zookeeper状态(zkServer.sh status):

# /usr/local/zookeeper/server03/zookeeper-3.3.6/bin/zkServer.sh status

JMX enabled by default

Using config: /usr/local/zookeeper/server03/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode: follower

# /usr/local/zookeeper/server02/zookeeper-3.3.6/bin/zkServer.sh status

JMX enabled by default

Using config: /usr/local/zookeeper/server02/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode: leader

# /usr/local/zookeeper/server01/zookeeper-3.3.6/bin/zkServer.sh status

JMX enabled by default

Using config: /usr/local/zookeeper/server01/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode: follower

5.安装dubbo-monitor

下载dubbo-monitor-simple-2.5.3-assembly.tar.gz至/usr/local/src目录

建立安装目录:

# mkdir -pv /usr/local/dubbo

mkdir: created directory ‘/usr/local/dubbo’

解压dubbo-monitor-simple-2.5.3-assembly.tar.gz

# tar zxf dubbo-monitor-simple-2.5.3-assembly.tar.gz

复制/usr/local/src/dubbo-monitor-simple-2.5.3至/usr/local/dubbo目录下:

# cp -ar /usr/local/src/dubbo-monitor-simple-2.5.3 /usr/local/dubbo

编辑dubbo.properties:

注释如下内容:

dubbo.registry.address=multicast://224.5.6.7:1234

修改如下内容:

dubbo.registry.address=zookeeper://127.0.0.1:2181

dubbo.jetty.port=8080

dubbo.jetty.directory=${user.home}/monitor

dubbo.statistics.directory=${user.home}/monitor/statistics

dubbo.log4j.file=logs/dubbo-monitor-simple.log

#cd /usr/local/dubbo/dubbo-monitor-simple-2.5.3/conf

# vi dubbo.properties

dubbo.container=log4j,spring,registry,jetty

dubbo.application.name=simple-monitor

dubbo.application.owner=

#dubbo.registry.address=multicast://224.5.6.7:1234

dubbo.registry.address=zookeeper://192.168.195.136:2181?backup=192.168.195.136:2182,192.168.195.136:2183

#dubbo.registry.address=redis://127.0.0.1:6379

#dubbo.registry.address=dubbo://127.0.0.1:9090

dubbo.protocol.port=7070

dubbo.jetty.port=8088

dubbo.jetty.directory=/usr/local/dubbo/dubbo-monitor-simple-2.5.3/monitor

dubbo.charts.directory=${dubbo.jetty.directory}/charts

dubbo.statistics.directory=${dubbo.jetty.directory}/statistics

dubbo.log4j.file=/usr/local/dubbo/dubbo-monitor-simple-2.5.3/logs/dubbo-monitor-simple.log

dubbo.log4j.level=WARN

创建目录monitor,logs:

# mkdir -pv /usr/local/dubbo/dubbo-monitor-simple-2.5.3/{monitor,logs}

mkdir: created directory ‘/usr/local/dubbo/dubbo-monitor-simple-2.5.3/monitor’

mkdir: created directory ‘/usr/local/dubbo/dubbo-monitor-simple-2.5.3/logs’

创建目录charts,statistics:

# mkdir -pv /usr/local/dubbo/dubbo-monitor-simple-2.5.3/monitor/{charts,statistics}

mkdir: created directory ‘/usr/local/dubbo/dubbo-monitor-simple-2.5.3/monitor/charts’

mkdir: created directory ‘/usr/local/dubbo/dubbo-monitor-simple-2.5.3/monitor/statistics’

启动dubbo:

# /usr/local/dubbo/dubbo-monitor-simple-2.5.3/bin/start.sh

Starting the simple-monitor .......OK!

PID: 16835

STDOUT: /usr/local/dubbo/dubbo-monitor-simple-2.5.3/logs/stdout.log

检查端口状态:

# netstat -ano | grep 7070

tcp        0      0 0.0.0.0:7070            0.0.0.0:*               LISTEN      off (0.00/0/0)

# netstat -ano | grep 8088

tcp        0      0 0.0.0.0:8088            0.0.0.0:*               LISTEN      off (0.00/0/0)

6.安装tomcat,并安装配置dubbo-admin

下载apache-tomcat-7.0.69.tar.gz至/usr/local/src目录

解压apache-tomcat-7.0.69.tar.gz

# tar zxf apache-tomcat-7.0.69.tar.gz

建立安装目录/usr/local/dubbo/dubbo-admin-tomcat:

# mkdir -pv /usr/local/dubbo/dubbo-admin-tomcat

mkdir: created directory ‘/usr/local/dubbo/dubbo-admin-tomcat’

复制/usr/local/src/apache-tomcat-7.0.69目录下所有文件至/usr/local/dubbo/dubbo-admin-tomcat目录下:

(注:不包含/usr/local/src/apache-tomcat-7.0.69目录本身)

# cp -ar /usr/local/src/apache-tomcat-7.0.69/. /usr/local/dubbo/dubbo-admin-tomcat

删除tomcat自带的webapps/ROOT目录:

# rm -rf /usr/local/dubbo/dubbo-admin-tomcat/webapps/ROOT

下载dubbo-admin-2.5.3.war至/usr/local/src目录

解压dubbo-admin-2.5.3.war至/usr/local/dubbo/dubbo-admin-tomcat/webapps/ROOT目录:

# unzip /usr/local/src/dubbo-admin-2.5.3.war -d /usr/local/dubbo/dubbo-admin-tomcat/webapps/ROOT

编辑/usr/local/dubbo/dubbo-admin-tomcat/webapps/ROOT/WEB-INF/dubbo.properties文件:

修改如下内容:

dubbo.registry.address=zookeeper://127.0.0.1:2181?backup=127.0.0.1:2182,127.0.0.1:2183

vi /usr/local/dubbo/dubbo-admin-tomcat/webapps/ROOT/WEB-INF/dubbo.properties

dubbo.registry.address=zookeeper://192.168.195.136:2181?backup=192.168.195.136:2182,192.168.195.136:2183

dubbo.admin.root.password=root

dubbo.admin.guest.password=guest

启动tomcat:

# /usr/local/dubbo/dubbo-admin-tomcat/bin/startup.sh

Using CATALINA_BASE:   /usr/local/dubbo/dubbo-admin-tomcat

Using CATALINA_HOME:   /usr/local/dubbo/dubbo-admin-tomcat

Using CATALINA_TMPDIR: /usr/local/dubbo/dubbo-admin-tomcat/temp

Using JRE_HOME:        /usr/local/java/jdk1.7.0_79/jre

Using CLASSPATH:       /usr/local/dubbo/dubbo-admin-tomcat/bin/bootstrap.jar:/usr/local/dubbo/dubbo-admin-tomcat/bin/tomcat-juli.jar

Tomcat started.

检测端口及进程状态:

# netstat -nlp | grep 8080

tcp6       0      0 :::8080                 :::*                    LISTEN      16979/java

# ps -ef | grep 16979

root      16979      1  5 21:23 pts/0    00:00:03 /usr/local/java/jdk1.7.0_79/jre/bin/java -Djava.util.logging.config.file=/usr/local/dubbo/

dubbo-admin-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/usr/local/dubbo/dubbo-admin-tomcat/endorsed -classpath /usr/local/dubbo/dubbo-admin-tomcat/bin/bootstrap.jar:/usr/local/dubbo/dubbo-admin-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/dubbo/dubbo-admin-tomcat -Dcatalina.home=/usr/local/dubbo/dubbo-admin-tomcat -Djava.io.tmpdir=/usr/local/dubbo/dubbo-admin-tomcat/temp org.apache.catalina.startup.Bootstrap startroot      16995   2539  0 21:24 pts/0    00:00:00 grep --color=auto 16979

7.访问dubbo

http://192.168.195.136:8080

用户名:root

密码:root

8.重启机器后,需要先启动zookeeper,然后启动dubbo-monitor,最后启动dubbo-admin(即tomcat)。

时间: 2024-09-29 01:33:07

dubbo搭建的相关文章

Dubbo搭建HelloWorld-搭建服务提供者与服务消费者并完成远程调用(附代码下载)

场景 Dubbo简介与基本概念: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103555224 Dubbo环境搭建-ZooKeeper注册中心: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103555470 Dubbo环境搭建-管理控制台dubbo-admin实现服务监控: https://blog.csdn.net/BADAO_LIUMANG_QI

分布式网上商城项目-dubbo搭建与初次使用错误

1.Spring-service启动失败 1 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 2 3 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tes

dubbo+zookeeper搭建笔记

参考博客: http://blog.csdn.net/u013142781/article/details/50396621#reply http://blog.csdn.net/u013142781/article/details/50395650 https://my.oschina.net/penngo/blog/494838 http://blog.csdn.net/morning99/article/details/40426133 内容基本来自小宝鸽的博客,部分小地方自己稍作修改.

dubbo入门介绍及结合spring搭建(源码放送)

前言 关于dubbo的介绍网上有很多博文有入门级的说明,但在这里,将会提供给大家dubbo的入门介绍,dubbo结合spring项目的简单搭建,以及提供demo源代码的免费下载. dubbo的官方网址是:http://dubbo.io/ dubbo框架使用的demo源码下载地址:http://download.csdn.net/detail/fighterandknight/9514559 dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及

DUBBO+Zookeeper在Centos7中本地搭建及小案例

环境: 1.centos7 2.jdk-7u76-linux-x64.tar.gz 2.tomcat:apache-tomcat-7.0.59.tar.gz 3.zookeeper-3.4.6.tar.gz 4.dubbo-admin-2.5.3.war 具体的流程: 第一步:安装jdk,并且配置环境变量(*) xshell5命令: 1.解压jdk: tar xvf jdk-7u76-linux-x64.tar.gz 1 2.提取权限: chmod–R 777 /usr/local/java/j

dubbu 官方参考手册~备案(防止哪天阿里一生气把dubbo给删除了)

首页  ||  下载  ||  用户指南  ||  开发者指南  ||  管理员指南  ||  培训文档  ||  常见问题解答  ||  发布记录  ||  发展路线  ||  社区 English | 中文 用户指南 入门 背景 需求 架构 用法 快速启动 服务提供者 服务消费者 依赖 必需依赖 缺省依赖 可选依赖 成熟度 功能成熟度 策略成熟度 配置 Xml配置 属性配置 注解配置 API配置 示例 启动时检查 集群容错 负载均衡 线程模型 直连提供者 只订阅 只注册 静态服务 多协议 多

spring与dubbo分布式REST服务开发实战

本课程主要是使用 Spring技术栈 + dubbo 开发一个类似当当的图书电商后台的实战教程. 课程特点: 1.课程的技术体系足够系统.全面以及细致:课程中涉及的主要技术包括: Spring IO (依赖版本管理), Spring Boot(自动化配置,零XML), Spring MVC (RESTful API开发) , Spring Security, Spring Security Oauth(RESTful API安全), Spring Framework(基础框架,服务层开发), S

2018年最新手把手教你搭建中小型互联网公司后台服务架构与运维架构

本课程主要是针对如何从无到有搭建中小型互联网公司后台服务架构和运维架构的课程,课程所涉及的内容均是当前应用最广泛的技术和工具.本课程所讲解的技术体系已经在多个中小型互联网公司中实战运行使用,目前运行已经非常稳定,数据量也是在不断持续增加.并且,这个技术体系也正在被其他很多互联网公司应用,希望通过此课程,让大家能快速熟练掌握各个技术,并且能实际应用到项目中.课程将会通过实际案例讲解,并且会提供完整的视频案例源码供学员学习使用,同时有需要的企业或学员可以直接拿本套教学案例代码来使用或者二次开发. 本

Dubbo相关

1.Apache Dubbo是一款高性能的ava RPC 框架 特性 架构原理 调用关系 1. 服务容器负责启动,加载,运行服务提供者. 2. 服务提供者在启动时,向注册中心注册自己提供的服务. 3. 服务消费者在启动时,向注册中心订阅自己所需的服务. 4. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推送变更数据给消费者. 5. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,如果调用失败,再选另一台调用. 6. 服务消费者和提供者,在内存