安装高可用Hadoop生态 (二) 安装Zookeeper
2. 安装Zookeeper
2.1. 解压程序
※ 3台服务器分别执行
tar -xf ~/install/zookeeper-3.4..tar.gz -C/opt/cloud/packages ln -s /opt/cloud/packages/zookeeper-3.4. /opt/cloud/bin/zookeeper
ln -s /opt/cloud/packages/zookeeper-3.4./conf /opt/cloud/etc/zookeeper mkdir -p /opt/cloud/data/zookeeper/dat
mkdir -p /opt/cloud/data/zookeeper/logdat
mkdir -p /opt/cloud/logs/zookeeper
2.2. 修改配置文件
2.2.1. 修改zoo.cfg
mv /opt/cloud/etc/zookeeper/zoo_sample.cfg /opt/cloud/etc/zookeeper/zoo.cfg
vi /opt/cloud/etc/zookeeper/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=/opt/cloud/data/zookeeper/dat
dataLogDir=/opt/cloud/data/zookeeper/logdat[] # the port at which the clients will connect
clientPort= # the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns= #
# 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=[] # Purge task interval in hours
# Set to "" to disable auto purge feature
autopurge.purgeInterval= # server.A=B:C:D
server.=hadoop1::[]
server.=hadoop2::
server.=hadoop3::
2.2.2. 修改log配置文件
vi /opt/cloud/etc/zookeeper/log4j.properties
修改配置项
zookeeper.root.logger=INFO, DRFA
zookeeper.log.dir=/opt/cloud/logs/zookeeper
增加DRFA日志定义
log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DRFA.Append=true
log4j.appender.DRFA.DatePattern='.'yyyy-MM-dd
log4j.appender.DRFA.File=${zookeeper.log.dir}/${zookeeper.log.file}
log4j.appender.DRFA.Threshold=${zookeeper.log.threshold}
log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{}@%L] - %m%n
log4j.appender.DRFA.Encoding=UTF-
#log4j.appender.DRFA.MaxFileSize=20MB
2.2.3. 复制到另外2台服务器
scp /opt/cloud/etc/zookeeper/zoo.cfg hadoop2:/opt/cloud/etc/zookeeper
scp /opt/cloud/etc/zookeeper/log4j.properties hadoop2:/opt/cloud/etc/zookeeper
scp /opt/cloud/etc/zookeeper/zoo.cfg hadoop3:/opt/cloud/etc/zookeeper
scp /opt/cloud/etc/zookeeper/log4j.properties hadoop3:/opt/cloud/etc/zookeeper
2.3. 生成myid
在dataDir目录下创建一个myid文件,然后分别在myid文件中按照zoo.cfg文件的server.A中A的数值,在不同机器上的该文件中填写相应的值。
ssh hadoop1 'echo 1 >/opt/cloud/data/zookeeper/dat/myid'
ssh hadoop2 'echo 2 >/opt/cloud/data/zookeeper/dat/myid'
ssh hadoop3 'echo 3 >/opt/cloud/data/zookeeper/dat/myid'
2.4. 设置环境变量
vi ~/.bashrc
增加
export ZOO_HOME=/opt/cloud/bin/zookeeper
export ZOOCFGDIR=${ZOO_HOME}/conf
export ZOO_LOG_DIR=/opt/cloud/logs/zookeeper
export PATH=$ZOO_HOME/bin:$PATH
即刻生效
source ~/.bashrc
复制到另外两台服务器
scp ~/.bashrc hadoop2:/home/hadoop
scp ~/.bashrc hadoop3:/home/hadoop
2.5. 手工执行
1.启动
zkServer.sh start
2.输入jps命令查看进程
QuorumPeerMain
Jps
其中,QuorumPeerMain是zookeeper进程,启动正常。
3、停止zookeeper进程
zkServer.sh stop
4、启动zookeeper集群
[hadoop@hadoop1 ~]$ cexec 'zkServer.sh start' ************************* cloud *************************
--------- hadoop1---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED --------- hadoop2---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED --------- hadoop3---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
5、查看zookeeper集群状态
[hadoop@hadoop1 ~]$ cexec 'zkServer.sh status' ************************* cloud ************************* --------- hadoop1---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Mode: follower --------- hadoop2---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Mode: follower --------- hadoop3---------
ZooKeeper JMX enabled by default
Using config: /opt/cloud/bin/zookeeper/bin/../conf/zoo.cfg
Mode: leader
6、启动客户端脚本
zkCli.sh
ls /zookeeper
ls /zookeeper/quota
2.6. 系统启动时自动运行
vi /opt/cloud/bin/zookeeper/bin/zkServer.sh
找到
nohup "$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
替换为
nohup "$JAVA" "-Dlog4j.configuration=file:${ZOOCFGDIR}/log4j.properties" \
复制到另外两台服务器
scp /opt/cloud/bin/zookeeper/bin/zkEnv.sh hadoop2:/opt/cloud/bin/zookeeper/bin/
scp /opt/cloud/bin/zookeeper/bin/zkServer.sh hadoop2:/opt/cloud/bin/zookeeper/bin/
scp /opt/cloud/bin/zookeeper/bin/zkEnv.sh hadoop3:/opt/cloud/bin/zookeeper/bin/
scp /opt/cloud/bin/zookeeper/bin/zkServer.sh hadoop3:/opt/cloud/bin/zookeeper/bin/
vi /etc/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper service
After=network.target [Service]
User=hadoop
Group=hadoop
Type=forking Environment = ZOO_HOME=/opt/cloud/bin/zookeeper
Environment = ZOOCFGDIR=/opt/cloud/bin/zookeeper/conf
Environment = ZOO_LOG_DIR=/opt/cloud/logs/zookeeper ExecStart=/usr/bin/sh -c '/opt/cloud/bin/zookeeper/bin/zkServer.sh start'
ExecStop =/usr/bin/sh -c '/opt/cloud/bin/zookeeper/bin/zkServer.sh stop' [Install]
WantedBy=multi-user.target
复制到另外两台服务器
scp /etc/systemd/system/zookeeper.service hadoop2:/etc/systemd/system/
scp /etc/systemd/system/zookeeper.service hadoop3:/etc/systemd/system/
重新加载配置信息:systemctl daemon-reload
启动zookeeper:systemctl start zookeeper
停止zookeeper:systemctl stop zookeeper
查看进程状态及日志(重要):systemctl status zookeeper
开机自启动:systemctl enable zookeeper
关闭自启动:systemctl disable zookeeper
启动服务设置为自动启动
systemctl daemon-reload
systemctl start zookeeper
systemctl status zookeeper
systemctl enable zookeeper
2.7. 卸载
root用户操作
- 停止并卸载zookeeper服务
systemctl stop zookeeper
systemctl disable zookeeper
rm /etc/systemd/system/zookeeper.service -f
- 复原环境变量
vi ~/.bashrc
删除zookeeper相关行
- 删除其他文件
rm /opt/cloud/bin/zookeeper/ -rf
rm /opt/cloud/data/zookeeper/ -rf
rm /opt/cloud/logs/zookeeper/ -rf
rm /opt/cloud/packages/zookeeper-3.4./ -rf
[1] #如果有高速设备,dateLogDir可以设置在高速设备上以大幅提高效率
[2] 设置数据定时清理机制
[3] # server.A=B:C:D:
# A 是一个数字,表示这个是第几号服务器
# B 是这个服务器的 ip 地址;
# C 表示的是这个服务器与集群中的
Leader 服务器交换信息的端口;
# D 表示用来执行选举时服务器相互通信的端口。
安装高可用Hadoop生态 (二) 安装Zookeeper的更多相关文章
- 安装高可用Hadoop生态 (三) 安装Hadoop
3. 安装Hadoop 3.1. 解压程序 ※ 3台服务器分别执行 .tar.gz -C/opt/cloud/packages /opt/cloud/bin/hadoop /etc/hadoop ...
- 安装高可用Hadoop生态 (一 ) 准备环境
为了学习Hadoop生态的部署和调优技术,在笔记本上的3台虚拟机部署Hadoop集群环境,要求保证HA,即主要服务没有单点故障,能够执行最基本功能,完成小内存模式的参数调整. 1. 准备环境 1 ...
- 安装高可用Hadoop生态 (四) 安装Spark
4. 安装Spark 4.1. 准备目录 -bin-without-hadoop.tgz -C /opt/cloud/packages/ -bin-without-hadoop /opt/clo ...
- 基于zookeeper的高可用Hadoop HA集群安装
(1)hadoop2.7.1源码编译 http://aperise.iteye.com/blog/2246856 (2)hadoop2.7.1安装准备 http://aperise.iteye.com ...
- kubernetes实战(二十五):kubeadm 安装 高可用 k8s v1.13.x
1.系统环境 使用kubeadm安装高可用k8s v.13.x较为简单,相比以往的版本省去了很多步骤. kubeadm安装高可用k8s v.11 和 v1.12 点我 主机信息 主机名 IP地址 说明 ...
- 企业运维实践-还不会部署高可用的kubernetes集群?使用kubeadm方式安装高可用k8s集群v1.23.7
关注「WeiyiGeek」公众号 设为「特别关注」每天带你玩转网络安全运维.应用开发.物联网IOT学习! 希望各位看友[关注.点赞.评论.收藏.投币],助力每一个梦想. 文章目录: 0x00 前言简述 ...
- 高可用Hadoop平台-Hue In Hadoop
1.概述 前面一篇博客<高可用Hadoop平台-Ganglia安装部署>,为大家介绍了Ganglia在Hadoop中的集成,今天为大家介绍另一款工具——Hue,该工具功能比较丰富,下面是今 ...
- 高可用Hadoop平台-实战尾声篇
1.概述 今天这篇博客就是<高可用Hadoop平台>的尾声篇了,从搭建安装到入门运行 Hadoop 版的 HelloWorld(WordCount 可以称的上是 Hadoop 版的 Hel ...
- 高可用Hadoop平台-Flume NG实战图解篇
1.概述 今天补充一篇关于Flume的博客,前面在讲解高可用的Hadoop平台的时候遗漏了这篇,本篇博客为大家讲述以下内容: Flume NG简述 单点Flume NG搭建.运行 高可用Flume N ...
随机推荐
- IDEA中全局搜索不起作用,解决办法
众所周知IDEA中全局搜索的快捷键是Ctrl+Shift+F,但是今天却碰到了用不了的情况,其实软件坏了的可能性很小,那就要从外部再来找原因,查看自己开的软件,一一查看快捷键,看是否是快捷键冲突: 1 ...
- Mysql的两种存储引擎以及区别
一.Mysql的两种存储引擎 1.MyISAM: ①不支持事务,但是整个操作是原子性的(事务具备四种特性:原子性.一致性.隔离性.持久性) ②不支持外键,支持表锁,每次所住的是整张表 MyIS ...
- 漏洞复现:MS17-010缓冲区溢出漏洞(永恒之蓝)
MS17-010缓冲区溢出漏洞复现 攻击机:Kali Linux 靶机:Windows7和2008 1.打开攻击机Kali Linux,msf更新到最新版本(现有版本5.x),更新命令:apt-get ...
- [币严区块链]以太坊(ETH)Dapp开发入门教程之宠物商店领养游戏
阅读本文前,你应该对以太坊.智能合约有所了解,如果你还不了解,建议你先看以太坊是什么 除此之外,你最好还了解一些HTML及JavaScript知识. 本文通过实例教大家来开发去中心化应用,应用效果如图 ...
- STL容器(Stack, Queue, List, Vector, Deque, Priority_Queue, Map, Pair, Set, Multiset, Multimap)
一.Stack(栈) 这个没啥好说的,就是后进先出的一个容器. 基本操作有: stack<int>q; q.push(); //入栈 q.pop(); //出栈 q.top(); //返回 ...
- 松软科技课堂:SQL--FULLJOIN关键字
SQL FULL JOIN 关键字(from:www.sysoft.net.cn) 只要其中某个表存在匹配,FULL JOIN 关键字就会返回行. FULL JOIN 关键字语法 SELECT col ...
- SSO-CAS实现单点登录服务端
目录 CAS-SSO 一.单点登录-CAS 二.下载搭建CAS 1. 下载 CAS 5.3 2. 导入IDEA 3. 打包war 3. war包部署到Tomcat 4. 启动Tomcat,访问 htt ...
- Java第三次作业第二题
2. [请复制本程序,作为java程序代码,进行编译,补充填写缺失代码部分,并实现题目要求功能,从而获得空白填写所需的内容.] 定义3个线程,模拟红绿灯的效果 一个线程控制画一个实心红圆 一个线程控制 ...
- py-faster-rcnn的常见错误
在py-faster-rcnn配置运行faster-rcnn-end2end-VGG-CNN_M_1024的过程中, 执行命令:./experiments/scripts/faster_rcnn_en ...
- Android [SharedPreference轻量级存储]
SharedPreferencesActivity.java package com.xdw.a122.data; import android.content.SharedPreferences; ...