zookeeper入门攻读

By admin in 美高梅手机版4858 on 2019年4月23日

zookeeper安装

zookeeper安装

zookeeper入门念书(二),zookeeper入门学习

zookeeper安装

单机情势

首先,下载zookeeper-3.4.8.tar.gz

创建/usr/zookeeper,解压到zookeeper目录

[[email protected]
zookeeper]# tar -zxvf zookeeper-3.4.8.tar.gz 

配备处境变量

为了未来操作方便,大家需求对Zookeeper的遭受变量举办布署,方法如下在/etc/profile文件中参预如下内容:

[[email protected]
liutie]# vi /etc/profile

#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
ZOOKEEPER_HOME=/usr/zookpeer/zookpeer-3.4.8
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:ZOOKEEPER_HOME/bin

使情状变量生效

[[email protected]
liutie]# source /etc/profile

进去zookeeper文件夹的bin目录修改zoo_simple.cfg为zoo.cfg

[[email protected]
conf]# mv zoo_sample.cfg zoo.cfg

修改zoo.cfg

[[email protected]
conf]# vi 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.  
# do not use /tmp for storage, /tmp here is just   
# example sakes.  
dataDir=/tmp/zookeeper  
# the port at which the clients will connect  
clientPort=2181  
#  
# Be sure to read the maintenance section of the   
# administrator guide before turning on autopurge.  
#  
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance  
#  
# The number of snapshots to retain in dataDir  
#autopurge.snapRetainCount=3  
# Purge task interval in hours  
# Set to "0" to disable auto purge feature  
#autopurge.purgeInterval=1 

封存后进入bin目录运转服务端

[[email protected]
bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper … already running as process 9176.

 

zookeeper安装 单机情势 首先,下载zookeeper-三.四.八.tar.gz
创制/usr/zookeeper,解压到zookeeper目录
[[email protected]

Zookerper在Linux上的安装

近日在品种的时候,遭遇一些linux的相关设置,纵然简易,可是步骤不少,一相当大心就会出错,这样就须求重新再来,实在是令人胃疼,所以那边做个小结,为需求的人留下一个参阅,也给自个儿加深一下记念。

单机格局

单机形式

先来讲一下zookeeper的设置

首先,下载zookeeper-3.4.8.tar.gz

首先,下载zookeeper-3.4.8.tar.gz

要设置zookeeper在Linux的虚拟机上,就亟要求先安装jdk,

1,在那前面,要先安插虚拟机的IP相关的设置:

命令: vi /etc/sysconfig/network-scripts/ifcfg-eth0

修改: DEBOOT=yes ,BOOTPROTO=static ,IPADDR=172.18.26.1,
NETMASK=255.255.255.0, DNS1=8.8.8.8。

  • 在修改完之后,记得实行这几个命令让修改生效:
  • service network restart

2,修改完那个设置未来,就足以在CRT中来举行linux命令,绝对来讲会有利于了繁多。

三,接下去,大家来安装jdk。

  • 此地需求说一下的是,假如设置的是多个虚拟机,在更改了ip之后,能够用ping
    加上你的本机的ip地址来测试一下是还是不是能够接连。如若急需ping的是外网,记得关闭防火墙。命令:service
    iptables start/stop。
  • 上传jdk的压缩文件,大家在/usr目录下开创3个java目录:
  • [root@localhost ~]# mkdir /usr/local/java
  • 解压jdk文件,然后将解压后的文件拷贝到/usr/local/java目录下,比量齐观命名称叫jdk1.7
  • [root@localhost ~]# mv jdk1.7.0_55 /usr/local/java/jdk1.7
  • 下一场设置碰到变量:
  • 命令: [root@localhost java]# vi /etc/profile

将上边包车型客车代码复制到文件中:

#set java environment
JAVA_HOME=/usr/local/java/jdk1.7
JRE_HOME=/usr/local/java/jdk1.7/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_zookeeper入门攻读。HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

  • 让修改生效: 这一步一定要铭记在心,不然会接连不上,
  • 命令: [root@localhost java]# source /etc/profile
  • 验证JDK是不是管用:
  • 命令: [美高梅手机版4858,root@localhost java]# java -version
  • 并发如下代码就表达配置成功:

java version “1.7.0_55”
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode)

创建/usr/zookeeper,解压到zookeeper目录

创建/usr/zookeeper,解压到zookeeper目录

接下去安装zookeeper

  • 一.把zookeeper的缩减包上传到Linux系统上.
  • 二,解压压缩包: tar -zxvf zookeeper-三.四.陆.tar.gz

留意:
在解压的时候,不一致类其他文本的解压情势各异,以.tar结尾的公文时,使用的是tar
…方式来解压,
可是若是是zip格式的压缩包,就提前解压,然后将中间的jar包上传到Linux.

  • 三,解压落成之后,在local下面创建zookeeper目录:
  • [root@localhost local]# mkdir zookeeper
  • 四,然后复制zookeeper-三.四.六到如下目录下,等量齐观命名字为zk_single
  • [root@localhost ~]# cp zookeeper-3.4.6
    /usr/local/zookeeper/zk_single -r
  • 5,进入到zk_single目录上面的conf,将zoo_sample.cfg文件重命名称叫zoo.cfg
  • [root@localhost conf]# mv zoo_sample.cfg zoo.cfg
  • 6,然后进到zk_single 下面的bin,实行运转的通令
  • [root@localhost zk_single]# cd bin
  • [root@localhost bin]# ls
    README.txt zkCli.cmd zkEnv.cmd zkServer.cmd zookeeper.out
    zkCleanup.sh zkCli.sh zkEnv.sh zkServer.sh
  • 7,初叶运营: [root@localhost bin]#
    ./zkServer.sh
    start
  • 八,查看情形: [root@localhost bin]#
    ./zkServer.sh
    status
  • 九,永恒关闭–修改配置开机不运营防火墙: chkconfig iptables off

[root@localhost zookeeper]# tar -zxvf zookeeper-3.4.8.tar.gz 

[root@localhost zookeeper]# tar -zxvf zookeeper-3.4.8.tar.gz 

Zookeeper集群的搭建

  • 1,在装置了jdk的基础上,以及zookeeper解压完结.
  • 贰,将zookeeper复制叁份

[root@localhost ~]# mkdir /usr/local/solr-cloud

[root@localhost ~]# cp -r zookeeper-3.4.6
/usr/local/solr-cloud/zookeeper01

[root@localhost ~]# cp -r zookeeper-3.4.6
/usr/local/solr-cloud/zookeeper02

[root@localhost ~]# cp -r zookeeper-3.4.6
/usr/local/solr-cloud/zookeeper03

  • 三,在种种 zookeeper 目录下创办四个 data 目录。

[root@localhost solr-cloud]# mkdir
/usr/local/solr-cloud/zookeeper01/data

[root@localhost solr-cloud]# mkdir
/usr/local/solr-cloud/zookeeper02/data

[root@localhost solr-cloud]# mkdir
/usr/local/solr-cloud/zookeeper03/data

  • 四,在 data 目录下创立四个 myid
    文件,文件名就叫做“myid”。内容就是每种实例的id。举例 1、 二、 三

[root@localhost solr-cloud]# echo 1 > zookeeper01/data/myid

[root@localhost solr-cloud]# echo 2 > zookeeper02/data/myid
[root@localhost solr-cloud]# echo 3 > zookeeper03/data/myid
[root@localhost solr-cloud]# cat zookeeper01/data/myid

1

小心: echo
命令的职能是在显示屏上突显1段文字,一般起到三个提示的功能。echo 一 >
zookeeper01/data/myid,将在显示屏上要显示的文字等新闻写入到 myid
文件中,
假定文件不存在则开创,要是存在则重写。

  • 伍,修改配置文件。把 conf 目录下的 zoo_sample.cfg 文件改名称叫 zoo.cfg
  • 六,然后对zoo.cfg进行修改:
  • vi zoo.cfg
  • 以 zookeeper0壹 为例, zookeeper0二, zookeeper0三 类似配置
  • 需求修改的如下:
  • dataDir是数额保存的目录,
    dataDir=/usr/local/solr-cloud/zookeeper01/data
  • 客户端连接zookeeper的端口号,保障各个示例接口不争论
    clientPort=2181
  • 集群中的节点列表,一,二,叁意味节点的id,
    IP后的端口号是zookeeper内部通信的端口,和投票大选的端口,每种端口都无法重复.

server.1=172.18.88.160:2881:3881

server.2=172.18.88.160:2882:3882

server.3=172.18.88.160:2883:3883

  • 柒,运行每一个 zookeeper 实例。编写脚本实行批管理:
    start-all-zookeeper.sh

[root@localhost solr-cloud]# vi
start-all-zookeeper.sh
cd zookeeper01/bin/

./zkServer.sh start

cd ../../

cd zookeeper02/bin/

./zkServer.sh start

cd ../../

cd zookeeper03/bin/

./zkServer.sh start

cd ../../

  • 八,给文件增加可施行权限
  • [root@localhost solr-cloud]# chmod u+x
    start-all-zookeeper.sh
  • 9.启动:
  • [root@localhost solr-cloud]#
    ./start-all-zookeeper.sh
  • 10,查看zookeeper的状态:
  • [root@localhost solr-cloud]#
    zookeeper03/bin/zkServer.sh
    status

完毕!

配置情形变量

配备遭逢变量

为了今后操作方便,大家须求对Zookeeper的意况变量进行安插,方法如下在/etc/profile文件中投入如下内容:

为了以往操作便利,我们要求对Zookeeper的景况变量举行布局,方法如下在/etc/profile文件中出席如下内容:

[root@localhost liutie]# vi /etc/profile

[root@localhost liutie]# vi /etc/profile

#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
ZOOKEEPER_HOME=/usr/zookpeer/zookpeer-3.4.8
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:ZOOKEEPER_HOME/bin

#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
ZOOKEEPER_HOME=/usr/zookpeer/zookpeer-3.4.8
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:ZOOKEEPER_HOME/bin

使境遇变量生效

使处境变量生效

[root@localhost liutie]# source /etc/profile

[root@localhost liutie]# source /etc/profile

进入zookeeper文件夹的bin目录修改zoo_simple.cfg为zoo.cfg

进入zookeeper文件夹的bin目录修改zoo_simple.cfg为zoo.cfg

[root@localhost conf]# mv zoo_sample.cfg zoo.cfg

[root@localhost conf]# mv zoo_sample.cfg zoo.cfg

修改zoo.cfg

修改zoo.cfg

[root@localhost conf]# vi zoo.cfg 

[root@localhost conf]# vi 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.  
# do not use /tmp for storage, /tmp here is just   
# example sakes.  
dataDir=/tmp/zookeeper  
# the port at which the clients will connect  
clientPort=2181  
#  
# Be sure to read the maintenance section of the   
# administrator guide before turning on autopurge.  
#  
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance  
#  
# The number of snapshots to retain in dataDir  
#autopurge.snapRetainCount=3  
# Purge task interval in hours  
# Set to "0" to disable auto purge feature  
#autopurge.purgeInterval=1 
# 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.  
# do not use /tmp for storage, /tmp here is just   
# example sakes.  
dataDir=/tmp/zookeeper  
# the port at which the clients will connect  
clientPort=2181  
#  
# Be sure to read the maintenance section of the   
# administrator guide before turning on autopurge.  
#  
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance  
#  
# The number of snapshots to retain in dataDir  
#autopurge.snapRetainCount=3  
# Purge task interval in hours  
# Set to "0" to disable auto purge feature  
#autopurge.purgeInterval=1 

保存后跻身bin目录运营服务端

保留后跻身bin目录运转服务端

[root@localhost bin]# ./zkServer.sh start

[root@localhost bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper … already running as process 9176.

ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper … already running as process 9176.

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有