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中迭代器实现的原理
一. 引言 迭代这个名词对于熟悉Java的人来说绝对不陌生.我们常常使用JDK提供的迭代接口进行java collection的遍历: Iterator it = list.iterator();wh ...
- centos7 ubuntu14 添加sudo 权限 ,禁用每次sudo 需要输入密码
安装完centos7后,默认没有启用sudo,首先应该是对sudo进行设置.sudo的作用就是使当前非root用户在使用没有权限的命令 时,直接在命令前加入sudo,在输入自己当前用户的密码就可以完成 ...
- Docker源码分析(六):Docker Daemon网络
1. 前言 Docker作为一个开源的轻量级虚拟化容器引擎技术,已然给云计算领域带来了新的发展模式.Docker借助容器技术彻底释放了轻量级虚拟化技术的威力,让容器的伸缩.应用的运行都变得前所未有的方 ...
- LeetCode——Best Time to Buy and Sell Stock III
Description: Say you have an array for which the ith element is the price of a given stock on day i. ...
- Android Framewrork资源类型有哪些?
1. Google Framework res frameworks/base/core/res/res/values <public type="attr" name=&q ...
- jconsole远程连接超时问题解决方法
根据oracle网站上的文档,本地使用jconsole没有问题.但当我从windows连接到linux时(centos5.4)时,老是连接不上). 原因是Linux上JVM给jconsole的RMI配 ...
- Fundamental theorem of arithmetic 为什么1不是质数
https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic In number theory, the fundamental th ...
- 电子商务(电销)平台中订单模块(Order)数据库设计明细
电子商务(电销)平台中订单模块(Order)数据库设计明细 - sochishun - 博客园 http://www.cnblogs.com/sochishun/p/7040628.html 电子商务 ...
- 设计模式之——Chain of Responsibility
Chain of Responsibility模式又叫做责任链模式,是将多个对象组成一条职责链,然后按照职责链上的顺序一个一个的找出是谁来负责处理. 这个模式很简单,下面就是一个实例程序,有六个处理器 ...
- Python爬虫实例(五) requests+flask构建自己的电影库
目标任务:使用requests抓取电影网站信息和下载链接保存到数据库中,然后使用flask做数据展示. 爬取的网站在这里 最终效果如下: 主页: 可以进行搜索:输入水形物语 点击标题进入详情页: 爬虫 ...