码迷,mamicode.com
首页 > 其他好文 > 详细

zookeeper的单节点搭建和分布式搭建

时间:2016-01-06 23:25:26      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

zookeeper的单节点搭建

1.把这个zookeeper-3.4.5.tar.gz文件上传到服务器上的/usr/local目录下
2.解压:tar -zxvf zookeeper-3.4.5.tar.gz
3.重命名:mv zookeeper-3.4.5 zookeeper
4.cd zookeeper/conf
5.修改配置文件的名称:mv zoo_sample.cfg zoo.cfg
6.cd ..
7.启动zookeeper:bin/zkServer.sh start
8.验证:jps,只要能看到有这个进程( QuorumPeerMain)就表示zookeeper已经正常启动

9.然后启动zookeeper的客户端,进入zookeeper 命令: bin/zkCli.sh

几个简单的命令:余下的命令用help参数查看

ls / 查看根目录下的所有节点

create /name hu 在根目录下创建一个节点name 内容是hu

 

启动Zookeeper集群模式       

                                                      
需要使用多台服务器,建议使用奇数台服务器,                                
在这使用三台,服务器的ip分别是:192.168.1.170 192.168.1.171 192.168.1.172
                                                                          
1:在192.168.1.170服务器上执行这些操作,把这个zookeeper-3.4.5.tar.gz文件上?
2:解压:tar -zxvf zookeeper-3.4.5.tar.gz                                 
3:重命名:mv zookeeper-3.4.5 zookeeper                                   
4:cd zookeeper/conf                                                      
5:修改配置文件的名称:mv zoo_sample.cfg  zoo.cfg                         
6:vi zoo.cfg                                                             
    修改配置文件中的datadir:/usr/local/zookeeper/data                       
    添加下面配置:                                                          
    server.0=192.168.1.170:2888:3888                                        
    server.1=192.168.1.171:2888:3888                                        
    server.2=192.168.1.172:2888:3888                                        
                                                                            
                                                                          
                                                                            
7:cd ..                                                                  
8:创建目录mkdir data                                                     
9:在data目录下创建文件vi myid,在里面保存当前节点的编号                  
    注意:在192.168.1.170服务器上面保存的编号是0                            
10:cd /usr/local                                                         
11:把170服务器上的zookeeper目录拷贝到其他两个节点                        
    scp -rq zookeeper 192.168.119.101:/usr/local                            
    scp -rq zookeeper 192.168.119.102:/usr/local                            
                                                                            
12:连接到192.168.1.171,cd /usr/local/zookeeper/data  修改myid中的编号为1
13:连接到192.168.1.172,cd /usr/local/zookeeper/data  修改myid中的编号为2
                                                                          
                                                                          
14:开始启动这三个节点上面的zookeeper服务                                 
    在170上的/usr/local/zookeeper目录下执行命令:bin/zkServer.sh start      
    在171上的/usr/local/zookeeper目录下执行命令:bin/zkServer.sh start      
    在172上的/usr/local/zookeeper目录下执行命令:bin/zkServer.sh start      
                                                                          
15:最后分别在每个节点上面执行jps验证下进程是否正常启动。                 

zookeeper的单节点搭建和分布式搭建

标签:

原文地址:http://www.cnblogs.com/hsw-time/p/5107737.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!