在本地主机上面ping虚拟机,看能否连接,我配置的虚拟机地址
ping 192.168.25.128
使用xftp工具连接虚拟机,将zookeeper压缩包上传到虚拟机上面
使用xshell连接虚拟机解压压缩包,(先保证虚拟机中安装好了jdk)
查看linux中的jdk版本(非默认版本),可以看到版本是1.7.0_55,不是默认版本,默认的是jdk1.6,所以我的已经安装好了jdk
[itcast@localhost zookeeper-3.4.6]$ 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)
[itcast@localhost zookeeper-3.4.6]$
解压zookeeper:
tar –xvf zookeeper-3.4.6.jar
解压后如下:
xshell中输命令:进入解压后的文件
[itcast@localhost ~]$ cd zookeeper-3.4.6
在当前目录创建一个文件夹data;
[itcast@localhost zookeeper-3.4.6]$ mkdir data
进入解压后的zookeeper,修改配置文件,修改之前需要找到刚才创建的data的目录
复制一个连接,会自动连接当前的linux:
进入解压后的文件中的data目录,输入命令
[itcast@localhost data]$ pwd
复制data所在的地址,等下要用
在第一个窗口进入conf文件
将cfg结尾的文件重命名,改为如下的名称:
修改名称的命令为:
[itcast@localhost conf]$ mv 原名称 zoo.cfg
编辑zoo.cfg:
[itcast@localhost conf]$ vim zoo.cfg
光标移到这一行,输入i,开启编辑状态
将dataDir的地址改为刚才复制的地址(也就是新建的data目录的地址),我的图上的是已经改好的
保存退出vim编辑:输入命令 :wq,如果出现文件是readOnly就用命令 : wq!
注意命令的前面有个冒号的
以上步骤就完成了zookeeper在虚拟机上的安装
以下是启动和停止zookeeper的服务
进入解压文件:
[itcast@localhost conf]$ cd ~
[itcast@localhost ~]$ ll
total 17324
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Desktop
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Documents
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Downloads
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Music
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Pictures
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Public
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Templates
drwxr-xr-x. 2 itcast itcast 4096 May 16 2015 Videos
drwxr-xr-x. 11 itcast itcast 4096 Sep 19 04:49 zookeeper-3.4.6
-rw-rw-r--. 1 itcast itcast 17699306 Sep 19 03:01 zookeeper-3.4.6.tar.gz
[itcast@localhost ~]$ cd zookeeper-3.4.6
[itcast@localhost zookeeper-3.4.6]$ ll
total 1572
drwxr-xr-x. 2 itcast itcast 4096 Feb 20 2014 bin
-rw-rw-r--. 1 itcast itcast 82446 Feb 20 2014 build.xml
-rw-rw-r--. 1 itcast itcast 80776 Feb 20 2014 CHANGES.txt
drwxr-xr-x. 2 itcast itcast 4096 Sep 20 02:15 conf
drwxr-xr-x. 10 itcast itcast 4096 Feb 20 2014 contrib
drwxrwxr-x. 3 itcast itcast 4096 Sep 20 01:18 data
drwxr-xr-x. 2 itcast itcast 4096 Feb 20 2014 dist-maven
drwxr-xr-x. 6 itcast itcast 4096 Feb 20 2014 docs
-rw-rw-r--. 1 itcast itcast 1953 Feb 20 2014 ivysettings.xml
-rw-rw-r--. 1 itcast itcast 3375 Feb 20 2014 ivy.xml
drwxr-xr-x. 4 itcast itcast 4096 Feb 20 2014 lib
-rw-rw-r--. 1 itcast itcast 11358 Feb 20 2014 LICENSE.txt
-rw-rw-r--. 1 itcast itcast 170 Feb 20 2014 NOTICE.txt
-rw-rw-r--. 1 itcast itcast 1770 Feb 20 2014 README_packaging.txt
-rw-rw-r--. 1 itcast itcast 1585 Feb 20 2014 README.txt
drwxr-xr-x. 5 itcast itcast 4096 Feb 20 2014 recipes
drwxr-xr-x. 8 itcast itcast 4096 Feb 20 2014 src
-rw-rw-r--. 1 itcast itcast 1340305 Feb 20 2014 zookeeper-3.4.6.jar
-rw-rw-r--. 1 itcast itcast 836 Feb 20 2014 zookeeper-3.4.6.jar.asc
-rw-rw-r--. 1 itcast itcast 33 Feb 20 2014 zookeeper-3.4.6.jar.md5
-rw-rw-r--. 1 itcast itcast 41 Feb 20 2014 zookeeper-3.4.6.jar.sha1
-rw-rw-r--. 1 itcast itcast 15339 Sep 20 01:33 zookeeper.out
[itcast@localhost zookeeper-3.4.6]$
启动zookeeper