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 ...
随机推荐
- android基础---->Fragment的使用
碎片(Fragment)是一种可以嵌入在活动当中的UI 片段,它能让程序更加合理和充分地利用大屏幕的空间,因而在平板上应用的非常广泛. Fragment的基础例子
- ubuntu下nginx编译安装
安装依赖库: sudo apt-get install libgd2-xpm sudo apt-get install libgd2-xpm-dev sudo apt-get install libg ...
- Linux应急响应思路详谈
一.主机篇: 1.自动化初筛,建议使用RootkitHunter (1)安装 $sudo wget https://jaist.dl.sourceforge.net/project/rkhunter/ ...
- 【BZOJ2137】submultiple 高斯消元求伯努利数
[BZOJ2137]submultiple Description 设函数g(N)表示N的约数个数.现在给出一个数M,求出所有M的约数x的g(x)的K次方和. Input 第一行输入N,K.N表示M由 ...
- Asp SqlDataSource将数据库数据绑定在 GridView
1.首先认识一下GridView的几条属性 ☻AllowPaging 确定是否可以分页 ☻AllowSorting 确定是否可以进行排序 ☻AlternatingRowStyle 指定奇数行样式 ...
- Appium中长按按钮操作
在一次项目中,appium要对某个按钮进行长按操作(大于2s),类似拍微信小视频,参考网上长按视频会报错 action1 = TouchActions(self.driver) el = self.d ...
- oracle通过sql随机取表中的10条记录
oracle通过sql随机取表中的10条记录: SELECT * FROM (SELECT * FROM T_USER ORDER BY DBMS_RANDOM.RANDOM()) WHERE Row ...
- Redis集群管理(二)
1.进入集群客户端 任意选一个redis节点,进入redis 所在目录 cd /redis 所在目录/src/ ./redis-cli -h 本地节点的ip -p redis的端口号 -a 密码 [r ...
- 自动化测试学习day4
主要学习内容:修改文件.集合.函数.模块 修改文件两种方法 修改文件方法一(缺点:代码繁琐,一次性将文件读出,文件过大可能会卡住) with open('geci', 'a+', encoding=' ...
- 持续交付的Mesos与Docker导入篇
变革这个词在当今的数字化时代司空见惯,IT技术每过一段时间就会有一起革新,从WEB2.0.虚拟化.云计算.大数据.微架构.DevOps再到今天的容器Docker与Mesos. Docker的出现方便了 ...