CentOS7.2 安装zookeeper3.4.9
下载Zookeeper-3.4.9
在/usr/local下创建hadoop文件夹
将下载的文件迁移到该文件夹下,并解压
tar -zxvf zookeeper-3.4.9.tar.gz
进入conf配置文件夹
cd zookeeper-3.4.9/conf/
复制zoo_sample.cfg文件并命名为zoo.cfg
cp zoo_sample.cfg zoo.cfg
打开zoo.cfg,修改内容
#dataDir=/tmp/zookeeper
dataDir=/usr/local/hadoop/zookeeper-3.4.9/data
dataLogDir=/usr/local/hadoop/zookeeper-3.4.9/logs
修改后的完整内容:
# 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
dataDir=/usr/local/hadoop/zookeeper-3.4.9/data # 数据持久化路径
dataLogDir=/usr/local/hadoop/zookeeper-3.4.9/logs # 日志保存路径 # the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# 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
修改zookeeper的环境变量,打开/etc/profile文件,并在末尾添加以下内容:
# idea - zookeeper-3.4.9 config start
export ZOOKEEPER_HOME=/usr/local/hadoop/zookeeper-3.4.9/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
# idea - zookeeper-3.4.9 config start
添加后的完整内容:
# /etc/profile # System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
} if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi # Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done unset i
unset -f pathmunge export JAVA_HOME=/usr/local/jdk/jdk1.8.0_121
export JRE_HOME=/usr/local/jdk/jdk1.8.0_121/jre
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin # idea - zookeeper-3.4.9 config start
export ZOOKEEPER_HOME=/usr/local/hadoop/zookeeper-3.4.9/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
# idea - zookeeper-3.4.9 config start
使环境变量生效
source /etc/profile
启动Zookeeper服务:
[root@localhost ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查询Zookeeper状态:
[root@localhost ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone
停止Zookeeper服务:
[root@localhost ~]# zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
重启Zookeeper服务:
[root@localhost ~]# zkServer.sh restart
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /usr/local/hadoop/zookeeper-3.4.9/data # 数据持久化路径/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
设置为开机自启动:(都是网上找的,没有操作!)
方法1:
/etc/rc.d/rc.local
添加:
su -root -c '//usr/local/services/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start'
方法2:
在/etc/rc.d/init.d文件夹下创建zookeeper文件
赋予操作权限
[root@localhost init.d]# touch zookeeper
[root@localhost init.d]# chmod +x zookeeper
[root@localhost init.d]# ls
functions netconsole network README redis_6379 zookeeper
[root@localhost init.d]# ls -a
. .. functions netconsole network README redis_6379 zookeeper
[root@localhost init.d]# ls -all
总用量 40
drwxr-xr-x. 2 root root 99 4月 10 21:24 .
drwxr-xr-x. 10 root root 4096 4月 9 23:08 ..
-rw-r--r--. 1 root root 15131 9月 12 2016 functions
-rwxr-xr-x. 1 root root 2989 9月 12 2016 netconsole
-rwxr-xr-x. 1 root root 6643 9月 12 2016 network
-rw-r--r--. 1 root root 1160 3月 3 11:23 README
-rwxr-xr-x. 1 root root 1702 4月 8 22:52 redis_6379
-rwxr-xr-x. 1 root root 0 4月 10 21:24 zookeeper
[root@localhost init.d]# chkconfig -add zookeeper
-add: 未知的选项
[root@localhost init.d]# chkconfig --add zookeeper
zookeeper文件内容:
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
start) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh start;;
stop) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh stop;;
status) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh status;;
restart) su root /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
将zookeeper添加到开机启动里面
chkconfig --add zookeeper
开机启动:
chkconfig zookeeper on
======
Centos7.2安装zookeeper3.5.2-alpha
为了测试Curator3.2.1,重新安装zookeeper-3.5.2-alpha.tar.gz
操作与上面一样,只是换了文件夹名称为zookeeper
[root@localhost conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Error contacting service. It is probably not running.
[root@localhost conf]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START
解决:
查看logs里面的日志:
[root@localhost zookeeper-3.5.]# cd logs
[root@localhost logs]# ls
version- zookeeper-hongdada-server-localhost.localdomain.out
[root@localhost logs]# vi version-
[root@localhost logs]# vi zookeeper-hongdada-server-localhost.localdomain.out
logs:
-- ::, [myid:] - ERROR [main:ZooKeeperServerMain@] - Unable to start AdminServer, exiting abnormally
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port and command URL /commands
at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:)
Caused by: java.net.BindException: 地址已在使用
at sun.nio.ch.Net.bind0(Native Method)
很明显是由于端口占用。我服务器中的tomcat占用了8080端口,而zookeeper最近的版本中有个内嵌的管理控制台是通过jetty启动,也会占用8080 端口。
通过查看zookeeper的官方文档,发现有3种解决途径:
(1).删除jetty。
(2)修改端口。
修改方法的方法有两种,一种是在启动脚本中增加 -Dzookeeper.admin.serverPort=你的端口号.一种是在zoo.cfg中增加admin.serverPort=没有被占用的端口号
(3)停用这个服务,在启动脚本中增加"-Dzookeeper.admin.enableServer=false"
在zoo.cfg中添加配置admin.serverPort=2182
修改后的zoo.cfg
# The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes. #dataDir=/tmp/zookeeper
dataDir=/usr/local/hadoop/zookeeper-3.4./data
dataLogDir=/usr/local/hadoop/zookeeper-3.4./logs # the port at which the clients will connect
clientPort=
admin.serverPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
"zoo.cfg" 33L, 1045C
启动:
[root@localhost hadoop]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process .
[root@localhost hadoop]# zkServer
bash: zkServer: 未找到命令...
[root@localhost hadoop]# zkServer.sh --version
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Usage: /usr/local/hadoop/zookeeper//bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}
[root@localhost hadoop]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Mode: standalone
http://blog.csdn.net/cg_perfect/article/details/53053060
http://www.procedurego.com/article/58182.html
http://www.cnblogs.com/hapday/p/5617730.html
http://m.blog.csdn.net/article/details?id=52313834
http://jingyan.baidu.com/article/fec7a1e5136c571190b4e720.html
http://blog.csdn.net/xiaoyu411502/article/details/51441890
https://www.cnblogs.com/feiye512/p/5923683.html
CentOS7.2 安装zookeeper3.4.9的更多相关文章
- 在 CentOS7 上安装 zookeeper-3.4.9 服务
在 CentOS7 上安装 zookeeper-3.4.9 服务 1.创建 /usr/local/services/zookeeper 文件夹: mkdir -p /usr/local/service ...
- Linux CentOS7下安装Zookeeper-3.4.10服务(最新)
Linux CentOS7下安装Zookeeper-3.4.10服务(最新) 2017年10月27日 01:25:26 极速-蜗牛 阅读数:1933 版权声明:本文为博主原创文章,未经博主允许不得 ...
- 在 CentOS7 上安装 zookeeper-3.5.2 服务
[root@centos-linux src]# pwd /usr/local/src # 1.创建 /usr/local/src/zookeeper 文件夹 [root@centos-linux s ...
- 在CentOS7上安装JDK1.8
在CentOS7上安装JDK1.8 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建目录 to ...
- centos7 Linux 安装jdk1.8
在CentOS7上安装JDK1.8 1 通过 xshell 连接到CentOS7 服务器: 2 进入到目录 /usr/local/ 中(一般装应用环境我们都会在这个目录下装,也可自行选择目录): cd ...
- Hive(二)CentOS7.5安装Hive2.3.3
一 Hive的下载 软件下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hive/ 这里下载的版本是:apache-hive-2.3.3-bin.t ...
- 在CentOS7上安装和使用ZooKeeper最新版本(V3.4.12)
0.ZooKeeper文档 http://zookeeper.apache.org/doc/r3.4.11/zookeeperOver.html 1.准备 在CentOS7上安装zookeeper时, ...
- 如何在Centos7上安装zookeeper 多实例
一.如何在Centos7上安装zookeeper 多实例 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...
- centos7上安装zookeeper
centos7上安装zookeeper 1 准备工作 1.准备服务器,本次安装采用 centos7系统.内存2G.存储60G的虚拟机服务器一台: 2.服务器安装java环境: 参考文章<cent ...
随机推荐
- java 集合之HashMap
原文出处http://zhangshixi.iteye.com/blog/672697 1. HashMap概述: HashMap是基于哈希表的Map接口的非同步实现.此实现提供所有可选的映射操 ...
- 【文智背后的奥秘】系列篇——分布式爬虫之WebKit
版权声明:本文由文智原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/139 来源:腾云阁 https://www.qclou ...
- 在Linux中的.iso文件的处理方法
1,mkdir /a 2,mount MLNX_OFED_LINUX-4.4-2.0.7.0-rhel7.3-x86_64.iso /a3,cd /a4,这样就可以对文件进行操作了
- 【BZOJ2768】[JLOI2010]冠军调查/【BZOJ1934】[Shoi2007]Vote 善意的投票 最小割
[BZOJ2768][JLOI2010]冠军调查 Description 一年一度的欧洲足球冠军联赛已经进入了淘汰赛阶段.随着卫冕冠军巴萨罗那的淘汰,英超劲旅切尔西成为了头号热门.新浪体育最近在吉林教 ...
- Redis字符串类型的操作
set key value [ex 秒数] / [px 毫秒数] [nx] /[xx] 如: set a 1 ex 10 , 10秒有效 Set a 1 px 9000 , 9秒有效 注: 如果ex ...
- JS判断当前是否是IE浏览器,并返回时IE几?
原文参考: https://www.cnblogs.com/liuyanxia/p/5855760.html 具体代码示例: 这里返回的是:如果不是IE浏览器返回 -1 ,返回 7/8/9/10/11 ...
- Android 性能测试工具- GT
GT(随 身调)是APP的随身调测平台,它是直接运行在手机上的“集成调测环境”(IDTE, Integrated Debug&Test Environment).利用GT,仅凭一部手机,无需连 ...
- postgresql----字符串函数与操作符
函数 返回值类型 描述 示例 结果 string||string text 字符串连接 select 'Post'||'gresql'||' good!'; Postgresql good! stri ...
- LINQ中的连接(join)用法示例
Linq中连接主要有组连接.内连接.左外连接.交叉连接四种.各个用法如下. 1. 组连接 组连接是与分组查询是一样的.即根据分组得到结果. 如下例,根据publisther分组得到结果. 使用组连接的 ...
- Java中实现序列化的两种方式 Serializable 接口和 Externalizable接口
对象的序列化就是将对象写入输出流中. 反序列化就是从输入流中将对象读取出来. 用来实现序列化的类都在java.io包中,我们常用的类或接口有: ObjectOutputStream:提供序列化对象并把 ...