《Hadoop管理二》集群添加新节点

Hadoop集群管理员需要经常向集群中添加节点,过程其实很简单:

  1. 按照之前datanode上的过程在新的机器上安装JDK、无密码SSH登录、解压相应版本的Hadoop
  2. 按照之前datanode上的过程在新的机器上配置hadoop-env.sh、core-site.xml、hdfs-site.xml、mapred-site.xml四个配置文件,将JAVA_HOME、hadoop.tmp.dir和fs.default.name、 dfs.replication、mapred.job.tracker进行相应的配置
  3. 配置网络地址加入到原来的集群中去
  4. 修改Namenode上的dfs.hosts(在hdfs-site.xml中有指定文件)和mapred.hosts(在mapred-site.xml中有指定文件),将新机器的ip地址加入其中。(如果有指定文件的话必须加入新的机器的ip地址。但是dfs.hosts和mapred.hosts属性可以为空,即不指定,这样所有的机器都可以加入集群)修改conf/slaves文件将新机器的ip地址加入其中
  5. 启动守护进程,命令分别是 bin/hadoop-daemon.sh start datanode 和 bin/hadoop-daemon.sh start tasktracker
  6. 还需要进行一下balance操作,将原来集群中的文件进行负载均衡存储到新的节点上,命令为bin/start-balancer.sh。

 

注:

  • dfs.hosts和mapred.hosts与conf/slaves 的区别。

dfs.host和mapred.hosts属性指定的文件不同于slaves文件。前者供Namenode和jobtracker使用,用来决定可以链接哪个工作节点。Hadoop控制脚本使用slaves文件执行集群范围的操作,例如重启集群。Hadoop守护进程从不使用slaves文件

  • balancer

1)如果不执行balancer命令,那么集群会把新的数据都存放在新的node上,这样会降低mapred的工作效率 
2)设置平衡阈值,默认是10%,值越低各节点越平衡,但消耗时间也更长。bin/start-balancer.sh -threshold 5 
3)设置balance的带宽,dfs.balance.bandwidthPerSec属性,默认只有1M/s。(在hdfs-site.xml中)

<property>
  <name>dfs.balance.bandwidthPerSec</name>
  <value>1048576</value>
  <description>
        Specifies the maximum amount of bandwidth that each datanode
        can utilize for the balancing purpose in term of
        the number of bytes per second.
  </description>
</property>

 

  • dfs.hosts
<property>
  <name>dfs.hosts</name>
  <value></value>
  <description>Names a file that contains a list of hosts that are
  permitted to connect to the namenode. The full pathname of the file
  must be specified.  If the value is empty, all hosts are
  permitted.</description>
</property>

 

  • mapred.hosts
dfs.hosts

<property>
  <name>dfs.hosts</name>
  <value></value>
  <description>Names a file that contains a list of hosts that are
  permitted to connect to the namenode. The full pathname of the file
  must be specified.  If the value is empty, all hosts are
  permitted.</description>
</property>
posted @ 2012-07-25 17:39  hanyuanbo  阅读(512)  评论(0编辑  收藏  举报