• CentOS安装jdk和Zookeeper


    查看Zookeeper版本:
    yum install -y nc
    echo stat |nc 127.0.0.1 2181

    安装Zookeeper需要jdk支持


    1.安装jdk
    mkdir /data1/software
    mkdir /data1/zookeeper/data -p
    mkdir /data1/zookeeper/log
    mkdir /usr/local/java
    cd /data1/software

    tar -zxvf jdk-8u73-linux-x64.tar.gz -C /usr/local
    mv /usr/local/jdk1.8.0_73 /usr/local/java

    vim /etc/profile:

    export JAVA_HOME=/usr/local/java
    export PATH=$PATH:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    #export KE_HOME=/data1/src/kafka-eagle-1.0.4
    #export PATH=$PATH:$KE_HOME/bin

    source /etc/profile
    java -version #验证java是否安装成功

    2.安装Zookeeper:

    tar -zxvf zookeeper-3.4.8.tar.gz -C /usr/local
    mv /usr/local/zookeeper-3.4.8 /usr/local/zookeeper
    cd /usr/local/zookeeper/conf/
    cp zoo_sample.cfg zoo.cfg

    vim zoo.cfg 

    tickTime=2000
    initLimit=10
    syncLimit=5
    dataDir=/data1/zookeeper/data
    dataLogDir=/data1/zookeeper/log
    clientPort=2181
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=1
    
    #配置集群
    server.1=10.10.201.82:2881:3881
    server.2=10.10.201.83:2881:3881
    server.3=10.10.201.84:2881:3881

    echo 1 > /data1/zookeeper/data/myid  #每台机器上执行
    echo 2 > /data1/zookeeper/data/myid #每台机器上执行
    echo 3 > /data1/zookeeper/data/myid #每台机器上执行

    启动Zookeeper服务:
    /usr/local/zookeeper/bin/zkServer.sh start

    zkServer.sh status #查看各节点状态,比如leader、follower

    详细参考:https://www.cnblogs.com/panwenbin-logs/p/10369402.html

     3.设置Zookeeper开机自启动

    在/etc/init.d/下新建文件 zookeeper,内容如下:

    #!/bin/bash
    #chkconfig: 345 20 90
    #description: zookeeper
    #processname: zookeeper
    
    # Source java env
    for commandline in $(cat /etc/profile.d/java.sh);do
        export ${commandline}
    done
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # Check networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
    
    RETVAL=0
    PROG=zookeeper
    ZK_SERVER="/usr/local/zookeeper/bin/zkServer.sh"
    ZK_LOGDIR="/data1/zookeeper/log"
    LOCKFILE="${ZK_LOGDIR}/zookeeper.lock"
    PID_FILE="/data1/zookeeper/data/zookeeper_server.pid"
    
    start() {
        echo -n $"Starting $PROG: "
    
        cd ${ZK_LOGDIR} && $ZK_SERVER start
    
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
            success;echo;touch $LOCKFILE
        else
            failure;echo
        fi
        return $RETVAL
    }
    
    stop() {
        echo -n $"Stopping $PROG: "
    
        if [ -f $PID_FILE ] ;then
           read PID <  "$PID_FILE"
        else
           failure;echo;
           echo -n $"$PID_FILE not found.";failure;echo
           return 1;
        fi
    
        if checkpid $PID; then
         cd ${ZK_LOGDIR} && $ZK_SERVER stop
            RETVAL=$?
            if [ $RETVAL -eq 0 ] ;then
                    success;echo
                    echo -n "Waiting for ${PROG} to shutdown .."
             while checkpid $PID;do
                     echo -n "."
                     sleep 1;
                    done
                    success;echo;rm -f $LOCKFILE
            else
                    failure;echo
            fi
        else
            echo -n $"${PROG} is dead and $PID_FILE exists.";failure;echo
            RETVAL=7
        fi
        return $RETVAL
    }
    
    
    status() {
         cd ${ZK_LOGDIR} && $ZK_SERVER status
    }
    
    case $1 in
        start)
            start
        ;;
    
        stop)
            stop
        ;;
    
        status)
            status
        ;;
    
        restart)
            stop
            start
        ;;
    
        *)
            echo "require start|stop|status|restart"
        ;;
    esac
    View Code

    chmod a+x zookeeper

    chkconfig --add zookeeper

    chkconfig zookeeper on

    在/etc/profile.d下新建文件java.sh,内容如下;

    JAVA_HOME=/usr/local/java
    JRE_HOME=/usr/local/java/jre
    JAVA_BIN=/usr/local/java/bin
    CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    PATH=$JAVA_BIN:$PATH

    service zookeeper start|stop|restart

     参考:https://www.cnblogs.com/happydreamzjl/articles/12186171.html

    https://blog.csdn.net/qq_43530416/article/details/107944942 #讲解细致

  • 相关阅读:
    Python randrange() 函数
    200行Python代码实现2048
    select默认下拉箭头改变、option样式清除
    图片垂直居中
    去除select边框和三角-----appearance:none
    原生 js 实现点击按钮复制文本
    This dependency was not found: * !!vue-style-loader!css-loader?……解决方案
    vue项目启动时将localhost替换成指定ip地址
    安装cnpm
    vue 项目要使用的库
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/15715369.html
Copyright © 2020-2023  润新知