# 集群搭建概述与JDK安装

## Zookeeper集群搭建

zk集群，主从节点，心跳机制（选举模式）

![](/files/-LfnTHUOVwwv-ubwxu3l)

1.选举模式必须为奇数节点，最少为3节点

2.xx挂掉，从新选举一个新的节点zz为mater

3.当xx节点恢复，不会抢占master，以slave角色。

### Zookeeper集群搭建注意点

* 配置数据文件myid  1/2/3 对应server.1/2/3
* 通过\`./zkCli.sh -server \[ip]:\[port] 检测集群是否配置成功

## JDK安装

环境要求:必须要有jdk环境,如：jdk1.8

下载地址：

<http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz>

配置：

```
vi /etc/profile
export JAVA_HOME=/usr/jdk8
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
```

运行以下使配置生效

```
source /etc/profile
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xiaoxiami.gitbook.io/zookeeper/zookeeperhuan-jing-da-jian/ji-qun-da-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
