- core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://yuntian</value>
</property>
<property>
<name>ha.zookeeper.quorum</name> //
定义zookeeper服务器
<value>node2:4180,node3:4180,node4:4180</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/hadoop</value>
</property>
</configuration>
- hdfs-site.xml
<configuration>
<property>
<name>dfs.nameservices</name>
<value>
yuntian</value>
</property>
<property>
<name>dfs.ha.namenodes.
yuntian</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.
yuntian.nn1</name>
<value>node1:9000</value>
</property>
<property>
<name>dfs.namenode.rpc-address.
yuntian.nn2</name>
<value>node2:9000</value>
</property>
<property>
<name>dfs.namenode.http-address.
yuntian.nn1</name>
<value>node1:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.
yuntian.nn2</name>
<value>node2:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name> //
定义qjournal服务器
<value>qjournal://node2:8485;node3:8485;node4:8485/
yuntian</value>
</property>
<property>
<name>dfs.client.failover.proxy.provider.
yuntian</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>sshfence</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/root/.ssh/
id_rsa</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/hadoop/data</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
</configuration>
- 准备zookeeper
- 三台zookeeper:node2,node3,node4
- 编辑conf/zoo.cfg配置文件 自己创建
tickTime=2000
initLimit=5
syncLimit=2
dataDir=/opt/zookeeper/data
dataLogDir=/var/logs/zookeeper
clientPort=4180 //
这里端口号注意core-site.xml
配置的端口号一致
server.2=node2:2888:3888
server.3=node3:2888:3888
server.4=node4:2888:3888
mkdir -p /opt/zookeeper/data
先创建dataDir
文件夹
- 在dataDir目录中创建一个myid的文件,文件内容为2,3,4
- 在bin下vim zkEnv.sh 修改ZOO_LOG_DIR="/var/logs/zookeeper" 日志路径
- 启动刚刚格式化的namenode(/sbin下) :./hadoop-daemone.sh start namenode
- 在没有格式化的namenode上执行:bin/hdfs namenode -bootstrapStandby
- 启动第二个namenode(/sbin下): ./hadoop-daemone.sh start namenode
全面启动
(/sbin)
:
./start-dfs.sh
所有启动(/sbin):./start-all.sh