• Zookeeper学习(1):安装


    zookeeper是通过java开发的,所以的运行需要依赖JAVA环境,安装zookeeper之前,先安装JDK。

    一、安装JDK

    1. 下载JDK,由于Zookeeper的运行需要依赖jdk1.8以上版本,所以我们下载jdk1.8+就可以了。

    wget https://repo.huaweicloud.com/java/jdk/8u181-b13/jdk-8u181-linux-x64.tar.gz
    

    2. 解压

    tar -zxvf jdk-8u181-linux-x64.tar.gz
    

    3. 由于我们本次的实验都是在/data下完成,所以将jdk文件夹移动到/data下。

    mv jdk1.8.0_181/ /data
    

    4. 设置环境变量

    vi /etc/profile.d/java.sh
    
    # set java env
    export JAVA_HOME=/data/jdk1.8.0_181
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
    
    # reload env
    source /etc/profile 

    5. 测试是否安装成功

    java -version
    # 显示版本
    java version "1.8.0_181"
    Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

    二、安装Zookeeper

    1. 下载Zookeeper,最新稳定版本是3.6.3

    wget https://archive.apache.org/dist/zookeeper/stable/apache-zookeeper-3.6.3-bin.tar.gz
    

    2. 解压

    tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz 
    

    3. 移动到/data

    mv apache-zookeeper-3.6.3-bin /data/zookeeper

    4. 设置环境变量

    vi /etc/profile.d/zookeeper.sh
    
    # set zookeeper env
    export ZOOKEEPER_HOME="/data/zookeeper" 
    export PATH="$ZOOKEEPER_HOME/bin:$PATH"
    
    # 设置完成后重加载环境变量
    source /etc/profile

    5. 设置Zookeeper配置文件

    1. Zookeeper目录下有一个试例,复制之后修改就可以了
    cp /data/zookeeper/conf/zoo_sample.cfg /data/zookeeper/conf/zoo.cfg
    
    2. 修改配置文件
    vi /data/zookeeper/conf/zoo.cfg
    
    # 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=/data/zookeeper/data
    # 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
    
    ## Metrics Providers
    #
    # https://prometheus.io Metrics Exporter
    #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
    #metricsProvider.httpPort=7000
    #metricsProvider.exportJvmInfo=true

    6. 启动Zookeeper

    zkServer.sh start
    
    ZooKeeper JMX enabled by default
    Using config: /data/zookeeper/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED
    
    # 可以在安装目录下的logs文件夹运行grep命令,查看是否有报错。
    grep -E -i "((exception)|(error))" *
    

      

  • 相关阅读:
    高危预警|RDP漏洞或引发大规模蠕虫爆发,用户可用阿里云免费检测服务自检,建议尽快修复
    高危预警| SQL数据库成主要攻击对象,或引发新一轮大规模勒索
    dp练习(7)—— 最小和
    dp练习(6)——搬运礼物
    dp练习(5)——最长严格上升子序列
    dp练习(4)——过河卒
    dp练习(3)——棋盘问题
    dp练习(2)——老鼠的旅行
    dp练习(1)——马走日字
    埃氏筛法——标记质数
  • 原文地址:https://www.cnblogs.com/tortoise512/p/16289674.html
Copyright © 2020-2023  润新知