ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)
来源:互联网 发布:java trimend 编辑:程序博客网 时间:2024/05/21 10:30
1、下载源码
官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载
这里选择3.4.10进行下载:
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
下载完成后执行以下命令进行解压:
tar -zxvf zookeeper-3.4.10.tar.gz
2、配置Zookeeper
[fendo@localhost ~]$ cd zookeeper-3.4.10/[fendo@localhost zookeeper-3.4.10]$ mkdir data[fendo@localhost zookeeper-3.4.10]$ mkdir logs
将zookeeper-3.4.10/conf目录下的zoo_sample.cfg文件拷贝一份,命名为zoo.cfg
[fendo@localhost conf]$ cp zoo_sample.cfg zoo.cfg
然后修改zoo.cfg文件
vim zoo.cfg
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/home/fendo/zookeeper-3.4.10/datadataLogDir=/home/fendo/zookeeper-3.4.10/logs# the port at which the clients will connectclientPort=2181# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60server.1=192.168.84.130:2888:3888
其中:
2888端口号是zookeeper服务之间通信的端口。
3888是zookeeper与其他应用程序通信的端口。
然后在dataDir=/home/fendo/zookeeper-3.4.10/data下创建myid文件(编辑myid文件,并在对应的IP的机器上输入对应的编号。如在zookeeper上,myid 文件内容就是1。如果只在单点上进行安装配置,那么只有一个server.1)
vim myid
fendo用户下修改.bash_profile,增加zookeeper配置:
vim /home/fendo/.bash_profile
# zookeeper env export ZOOKEEPER_HOME=/home/fendo/zookeeper-3.4.10 export PATH=$ZOOKEEPER_HOME/bin:$PATH
使配置文件生效
source /home/fendo/.bash_profile
关闭防火墙
切换到root用户下,执行以下命令:
systemctl stop firewalld.service
3、测试Zookeeper
#使用fendo用户到/home/fendo/zookeeper-3.4.10/bin目录中执行 ./zkServer.sh start #查看进程jps其中,QuorumPeerMain是zookeeper进程,启动正常。 #查看状态 ./zkServer.sh status #服务器输出信息 tail -500f zookeeper.out #停止zookeeper进程 ./zkServer.sh stop
设置zookeeper服务开机启动
# 切换到/etc/rc.d/init.d/目录下 cd /etc/rc.d/init.d # 创建zookeeper文件 touch zookeeper #更新权限 chmod +x zookeeper #编辑文件,在zookeeper里面输入如下内容 #!/bin/bash #chkconfig:2345 20 90 #description:zookeeper #processname:zookeeper export JAVA_HOME=/user/local/java/jdk1.7.0_79 export PATH=$JAVA_HOME/bin:$PATH case $1 in start)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh start;; stop)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh stop;; status)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh status;; restart)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh restart;; *) echo "require start|stop|status|restart" ;; esac
然后我们就可以用service zookeeper start/stop来启动停止zookeeper服务了
使用命令把zookeeper添加到开机启动里面
chkconfig zookeeper on chkconfig --add zookeeper
添加完成之后接这个使用chkconfig --list 来看看我们添加的zookeeper是否在里面。
阅读全文
0 0
- ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)
- centos7 下安装zookeeper
- zookeeper单机版安装
- 安装单机版zookeeper
- zookeeper单机版安装
- CentOS 下安装单机版zookeeper
- linux下单机版zookeeper安装
- CentOS 7下安装 Zookeeper单机版
- CentOS7下搭建zookeeper单机环境
- zookeeper-ubuntu单机版安装
- linux 安装单机版zookeeper
- linux安装zookeeper单机版
- CentOS6.5下kafka+ZooKeeper下载与安装详细教程-单机版
- Windows下单机版Zookeeper下的安装
- Linux环境下安装Zookeeper (单机模式)
- ZooKeeper教程(二)----zookeeper单机版伪集群
- zookeeper之单机安装
- zookeeper之单机安装
- NYOJ 85. 有趣的数
- CentOS之iptables-yellowcong
- **随便写写(1)——欧几里得算法求最小公约数**
- 基于顺序链表的栈的顺序存储的C风格实现
- JS报错RangeError: Invalid string length
- ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)
- Python 序列化JSON串
- 河南理工大学校友会举办《“认识上海”大讲堂》第一期讲座
- KMP算法(C++)
- C语言define定义数组和函数指针
- java 集合类
- 页面加载速度优化
- Linux apache下虚拟主机配置
- Python3中的print函数以及与python2的比较