欢迎使用CSDN-markdown编辑器
来源:互联网 发布:淘宝靠谱的韩国代购 编辑:程序博客网 时间:2024/05/18 16:14
linux安装zookeeper详解
本次是单击版
tar -zxvf zookeeper-3.4.6.tar.gz //第一步解压
cd zookeeper-3.4.6 //第二步进入文件夹内部
mkdir data //创建data文件夹(data主要是放提供方的ip和端口号)(必须)
mkdir logs //创建日志包(可以不创建)
cd conf/ //进入到配置文件,配置data文件夹和logs文件夹
cp zoo_sample.cfg zoo.cfg //复制并改名(万一配置了还可以从新在来)
vim zoo.cfg //进入到配置文件
按 i 进入编辑模式
编辑完之后,按 :wq 保存退出
cd .
cd ..
返回安装目录 cd bin/ 进行启动
service iptables status 进入查看防火墙,如果没关,要关闭
service iptables stop 防火墙只关本次
chkconfig iptables off 防火墙彻底关闭
service iptables status 查看防火墙状态
./zkServer.sh start 启动服务(要在bin目录下)
./zkServer.sh status 查看状态
配约束
搭建Dubbo服务提供方
配置文件
dubbo-provider.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- 服务提供方 --> <!-- 1:起名称 --> <dubbo:application name="babasport-service-product"/> <!-- 2:连接zookeeper 协议写zookeeper,zookeeper底层走的是TCP协议 --> <dubbo:registry address="192.168.154.129:2181" protocol="zookeeper"/> <!-- 3:爆露端口号 默认20880 --> <dubbo:protocol port="20880"/> <!-- 4:爆露服务(接口) 本次为注解开发,所以不需要在写<bean>标签,添加实现类 --> <dubbo:service interface="cn.itcast.core.service.TestService" ref="testService" /> <!-- <bean id="testService" class="cn.itcast.core.service.TextServiceImpl"></bean> --></beans>
搭建Dubbo服务消费方
dubbo-consumer.xml
约束和提供方一样
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- 服务消费方 --> <!-- 1:起名称 --> <dubbo:application name="babasport-console"/> <!-- 2:连接zookeeper 协议写zookeeper,zookeeper底层走的是TCP协议 --> <dubbo:registry address="192.168.154.129:2181" protocol="zookeeper"/> <!-- 3:调用或者是引用服务 --> <dubbo:reference interface="cn.itcast.core.service.TestService" id="testService"/></beans>
dubbo优化
1:超时
服务消费方通过注册中心获取服务提供方的地址 调用服务提供方 由于服务提供方可能已经宕机(死机) 不能提供服务
服务消费方在1秒内没有得到回应 为了给用户提供非常服务 马上与服务提供方断开连接 再向注册中心获取新的服务提供方的地址 调用新的服务提供方
Dubbo用此方法来完成分布式情况下 服务器出现故障 而不影响用户的访问
在服务消费方的配置文件中配置
2:直接连接(开发阶段使用,项目上线了需要改回去)
在服务提供方的配置文件中配置
在服务消费方的配置文件中配置
3:服务消费方不检查 服务提供方(启动tomcat先后顺序可以随便启动)
全局设置
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- Socket端口状态说明 LISTENING、ESTABLISHED、TIME_WAIT及CLOSE_WAIT
- Python-科学计算的方法
- Centos7使用yum安装chrome浏览器
- 日记★DP★A-子集的和
- Pro TypeScript, 2nd Edition.pdf 2017 英文原版 免费下载
- 欢迎使用CSDN-markdown编辑器
- 学习分布式系统需要怎样的知识?
- PHP下编码转换函数mb_convert_encoding与iconv的使用说明
- 线段树1 HDU 1166 炮兵阵地
- 从穷人到富人的全过程,越看越触目惊心!
- GetCurrentDirectory()和GetMoudleFileName()获取进程所在目录
- Windows monkey 环境搭建教程
- CentOS 安装 node 8.x 版本
- TensorFlow中的onehot有什么作用,为什么要使用onehot向量呢?