hadoop高可用集群配置
时间: 2023-11-25 20:49:34 浏览: 68
以下是hadoop高可用集群配置的步骤:
1. 配置hadoop集群的core-site.xml文件,增加如下配置:
```xml
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>zk1:2181,zk2:2181,zk3:2181</value>
</property>
```
2. 配置hadoop集群的hdfs-site.xml文件,增加如下配置:
```xml
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
</property>
<property>
<name>dfs.ha.namenodes.mycluster</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>node1:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>node2:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>node1:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>node2:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://node1:8485;node2:8485;node3:8485/mycluster</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/data/journal</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>sshfence</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/hadoop/.ssh/id_rsa</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
```
3. 配置hadoop集群的mapred-site.xml文件,增加如下配置:
```xml
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
```
4. 配置hadoop集群的yarn-site.xml文件,增加如下配置:
```xml
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>mycluster</value>
</property>
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>node1</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>node2</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>node1:8088</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>node2:8088</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>zk1:2181,zk2:2181,zk3:2181</value>
</property>
```
5. 配置zookeeper集群的zoo.cfg文件,增加如下配置:
```cfg
server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888
```
6. 在每个节点上创建一个myid文件,文件内容为该节点在zookeeper集群中的编号,例如在node1上创建myid文件,文件内容为1。
7. 启动zookeeper集群。
8. 在hadoop集群的每个节点上启动journalnode:
```bash
hadoop-daemon.sh start journalnode
```
9. 在namenode1上格式化hdfs:
```bash
hdfs namenode -format
```
10. 在namenode1上启动hdfs:
```bash
start-dfs.sh
```
11. 在namenode1上启动yarn:
```bash
start-yarn.sh
```
12. 在namenode1上启动自动故障转移:
```bash
hdfs haadmin -transitionToActive nn1
```
13. 在namenode2上启动hdfs:
```bash
start-dfs.sh
```
14. 在namenode2上启动yarn:
```bash
start-yarn.sh
```
15. 在namenode2上启动自动故障转移:
```bash
hdfs haadmin -transitionToStandby nn2
```
16. 测试hadoop高可用集群是否正常工作。