离线电商数仓(六)之用户行为数据采集(六)组件安装(二)Zookeeper安装

1 安装ZK

集群规划

服务器hadoop102

服务器hadoop103

服务器hadoop104

Zookeeper

Zookeeper

Zookeeper

Zookeeper

2.2 ZK集群启动停止脚本

1)在hadoop102/home/atguigu/bin目录下创建脚本

[atguigu@hadoop102 bin]$ vim zk.sh

脚本中编写如下内容

#! /bin/bash

case $1 in
"start"){
    for i in hadoop102 hadoop103 hadoop104
    do
        ssh $i "source /etc/profile; /opt/module/zookeeper-3.4.10/bin/zkServer.sh start"
    done
};;
"stop"){
    for i in hadoop102 hadoop103 hadoop104
    do
        ssh $i "source /etc/profile; /opt/module/zookeeper-3.4.10/bin/zkServer.sh stop"
    done
};; 
"status"){
    for i in hadoop102 hadoop103 hadoop104
    do
        ssh $i "source /etc/profile; /opt/module/zookeeper-3.4.10/bin/zkServer.sh status"
    done
};;
esac

2)增加脚本执行权限

[atguigu@hadoop102 bin]$ chmod 777 zk.sh

3Zookeeper集群启动脚本

[atguigu@hadoop102 module]$ zk.sh start

4Zookeeper集群停止脚本

[atguigu@hadoop102 module]$ zk.sh stop

2.3 项目经验之Linux环境变量

1)修改/etc/profile文件:用来设置系统环境参数,比如$PATH. 这里面的环境变量是对系统内所有用户生效。使用bash命令,需要source  /etc/profile一下。

2)修改~/.bashrc文件:针对某一个特定的用户,环境变量的设置只对该用户自己有效。使用bash命令只要以该用户身份运行命令行就会读取该文件。

3)把/etc/profile里面环境变量追加到~/.bashrc目录

[atguigu@hadoop102 ~]$ cat /etc/profile >> ~/.bashrc
[atguigu@hadoop103 ~]$ cat /etc/profile >> ~/.bashrc
[atguigu@hadoop104 ~]$ cat /etc/profile >> ~/.bashrc

 2.4 群起脚本错误请看

Zookeeper集群自动启动脚本 -- export 的注意点

https://blog.csdn.net/qq_38200548/article/details/82929384

原文地址:https://www.cnblogs.com/qiu-hua/p/13504343.html