secondarynamenode的作用就是用来做checkpoint---相当于对NameNode节点的元数据备份
现在将secondarynamenode部署在另一台机器,是为了引入Zookeeper做自动切换
具体方法如下
1.修改conf/core-site.xml
增加或修改
<property>
<name>fs.checkpoint.period</name>
<value>3600</value>
<description>The number of seconds between two periodic checkpoints. </description>
</property>
<property>
<name>fs.checkpoint.size</name>
<value>67108864</value>
<description>The size of the current edit log (in bytes) that triggers a periodic checkpoint even if the fs.checkpoint.period hasn't expired. </description>
</property>
<name>fs.checkpoint.period</name>
<value>3600</value>
<description>The number of seconds between two periodic checkpoints. </description>
</property>
<property>
<name>fs.checkpoint.size</name>
<value>67108864</value>
<description>The size of the current edit log (in bytes) that triggers a periodic checkpoint even if the fs.checkpoint.period hasn't expired. </description>
</property>
<property>
<name>fs.checkpoint.dir</name> --可以不写,默认为 {hadoopdata}/dfs/namesecondary
<value>/data/work/hdfs/namesecondary</value>
<description>Determines where on the local filesystem the DFS secondary name node should store the temporary images to merge. If this is a comma-delimited list of directories then the image is replicated in all of the directories for redundancy. </description>
</property>
<name>fs.checkpoint.dir</name> --可以不写,默认为 {hadoopdata}/dfs/namesecondary
<value>/data/work/hdfs/namesecondary</value>
<description>Determines where on the local filesystem the DFS secondary name node should store the temporary images to merge. If this is a comma-delimited list of directories then the image is replicated in all of the directories for redundancy. </description>
</property>
2.修改conf/hdfs-site.xml
<property>
<name>dfs.http.address</name>
<value>0.0.0.0:50070</value>
<description> The address and the base port where the dfs namenode web ui will listen on. If the port is 0 then the server will start on a free port. </description>
</property>
<description> The address and the base port where the dfs namenode web ui will listen on. If the port is 0 then the server will start on a free port. </description>
</property>
0.0.0.0改为namenode的IP地址(Master的IP)
3.修改conf/masters
将secondarynamenode的机器IP写入,可以多写,一行一个IP
4.重启HADOOP,检查secondarynamenode是否已启动
在Master节点上输入 jps 可以看到 NameNode,Jobtracker
在DataNode上输入jps可以看到 DataNode,Tasktracker
在secondarynamenode上输入jps可以看到 Secondarynamenode
进入secondarynamenode的目录/data/work/hdfs/namesecondary
正确的结果:
如果没有,请耐心等待,只有到了设置的checkpoint的时间或者大小,才会生成。