linux系统安装zookeeper

来源:互联网 发布:淘宝上传好评截图 编辑:程序博客网 时间:2024/06/14 18:30
一个新的linux 系统进行安装 zookeeper单机
ZooKeeper是用Java编写的,运行在Java环境上,因此,在部署zk的机器上需要安装Java运行环境。
为了正常运行zk,我们需要JRE1.6或者以上的版本,我用的jdk 1.7。

 


1 用户登录后 让用户拥有 root 权限  

用户切换到root 用户 命令:

su -    切换到root;  

输入密码:*****

修改 /etc/sudoers

vim /etc/sudoers

 字母 i  --开启编辑

查找 root    ALL=(ALL)       ALL

在 root 下面添加 用户  参数 与root相同 

2 创建文件夹  

su - 用户名   切换到用户
sudo mkdir 文件夹名称 /...
修改 读写权限  sudo chmod 777 文件夹名称/....(新建的文件夹用户进行操作 都需要进行 chmod 777 )


3 SecureFX 指定的文件夹  上传文件 jdk 和 zookeeper 
*.tar.gz包  
使用 tar -zxvf 文件名 进行解压 

*.zip
  解压zip 包命令是 unzip 文件名称



1) cd jdk1.7...解压好的文件夹
pwd 获取文件夹全路径 
进入 sudo vim /etc/profile 进行编辑 环境变量
export JAVA_HOME=java全路径
export PATH=$JAVA_HOME/bin:$PATH


2) cd  zookeeper 解压好的文件夹 
pwd 获取文件的全路径 
    进入 sudo vim /etc/profile 进行编辑 环境变量


    export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.5(这是我的路径)
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf


5 检测 是否配置成功  先进行文件的刷新
命令是:source /etc/profile


检测jdk  
命令窗口输入 javac 
结果是 一堆东西
Usage: javac <options> <source files>
where possible options include:
-g                         Generate all debugging info
-g:none                    Generate no debugging info
-g:{lines,vars,source}     Generate only some debugging info
-nowarn                    Generate no warnings
-verbose                   Output messages about what the compiler is doing
-deprecation               Output source locations where deprecated APIs are used
-classpath <path>          Specify where to find user class files and annotation processors
-cp <path>                 Specify where to find user class files and annotation processors
-sourcepath <path>         Specify where to find input source files
-bootclasspath <path>      Override location of bootstrap class files
-extdirs <dirs>            Override location of installed extensions
-endorseddirs <dirs>       Override location of endorsed standards path
-proc:{none,only}          Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path>      Specify where to find annotation processors
-d <directory>             Specify where to place generated class files
-s <directory>             Specify where to place generated source files
-implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding>       Specify character encoding used by source files
-source <release>          Provide source compatibility with specified release
-target <release>          Generate class files for specific VM version
-version                   Version information
-help                      Print a synopsis of standard options
-Akey[=value]              Options to pass to annotation processors
-X                         Print a synopsis of nonstandard options
-J<flag>                   Pass <flag> directly to the runtime system
-Werror                    Terminate compilation if warnings occur
@<filename>                Read options and filenames from file




检测zookeeper
echo $ZOOKEEPER_HOME

      结果是:zookeeper 的全路径
错误的话, 好好检查路径 和 环境变量
6  进入到 zookeeper/conf 目录 
cp zoo_sample.cfg zoo.cfg

sudo vim zoo.cfg 
修改dataDir = zookeeper 全路径 /data 例如:/usr/local/zookeeper/zookeeper-3.4.5/data


7 进入到 zookeeper/bin 目录 
  start 启动  , restart  重新启动 我比较偏向restart方便避免重复启动
./zkServer.sh restart 

检查启动结果    
./zkServer.sh status 

如果 环境变量配置成功,一般不会报错 , 没有环境变量 会 报出:
Error contacting service. It is probably not running.


cat zookeeper.out  查看日志

不要怕错误,多做几次

./zkServer.sh  stop  停止zookeeper