• systemd(CentOS7)启动zookeeper


    1.准备zookeeper用户

    groupadd zookeeper
    useradd  -M -s /bin/false -g zookeeper zookeeper
    

    2.准备工作目录

    mkdir -p /zookeeper/{data,conf,logs,src}
    wget -P /zookeeper/src https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
    tar zxf /zookeeper/src/zookeeper-3.4.13.tar.gz
    chown zookeeper.zookeeper -R /zookeeper
    chmod 750 -R /zookeeper
    ln -s /zookeeper/src/zookeeper-3.4.13 /opt/zookeeper
    

    3.创建zookeeper配置文件:/zookeeper/conf/zoo.cfg

    • Standalone模式:
    tickTime=2000
    initLimit=10
    syncLimit=5
    clientPort=2181
    dataDir=/zookeeper/data
    dataLogDir=/zookeeper/data/logs
    
    • Clustered模式:
    tickTime=2000
    initLimit=10
    syncLimit=5
    clientPort=2181
    dataDir=/zookeeper/data
    dataLogDir=/zookeeper/data/logs
    
    server.1=zk1:2888:3888
    server.2=zk2:2888:3888
    server.3=zk3:2888:3888
    

    Clustered模式下需要创建myid文件,节点对应id:echo "1" > /zookeeper/data/myid

    4.编写systemd.service服务脚本:/etc/systemd/system/zookeeper.service

    [Unit]
    Description=ZooKeeper Service
    After=network.target
    After=syslog.target
    
    [Service]
    Environment=ZOO_LOG_DIR=/zookeeper/logs
    SyslogIdentifier=zookeeper
    
    Type=forking
    User=zookeeper
    Group=zookeeper
    ExecStart=/opt/zookeeper/bin/zkServer.sh start /zookeeper/conf/zoo.cfg
    ExecStop=/opt/zookeeper/bin/zkServer.sh stop /zookeeper/conf/zoo.cfg
    ExecReload=/opt/zookeeper/bin/zkServer.sh restart /zookeeper/conf/zoo.cfg
    
    
    [Install]
    WantedBy=default.target
    

    重新加载配置信息:systemctl daemon-reload
    启动zookeeper:systemctl start zookeeper.service
    关掉zookeeper:systemctl stop zookeeper.service
    查看进程状态及日志:systemctl status zookeeper.service
    开机自启动:systemctl enable zookeeper.service
    关闭自启动:systemctl disable zookeeper.service

  • 相关阅读:
    微信 ios端config配置失败 android端正常
    vscode离线安装插件
    win7中vscode会黑屏或者终端空白,无法输入
    vue中使用svg图片
    a.download下载文件 ---跨域问题
    background 背景图片 --css3
    box-shadow
    兄弟伪类
    canvas画时钟
    轮播图--使用原生js的轮播图
  • 原文地址:https://www.cnblogs.com/javaite/p/8710298.html
Copyright © 2020-2023  润新知