Hadoop http address绑定内网地址
Hadoop默认配置里http address接口domain段均为0.0.0.0,表示可通过任一网卡访问http接口,对于双网卡服务器(一个内网,一个外网),意味着公网用户可以随意访问hadoop系统开放的web资源,存在极大的安全隐患。
我们可以修改配置将domain段替换成内网IP,这对于dfs.http.address、mapred.job.tracker.http.address没什么问题,但dfs.datanode.http.address需要到每个datanode上去修改,这太不现实了,可以通过以下方法实现自动配置。
通过local.bind.address参数 为http address绑定内网IP:
1、修改$HADOOP_HOME/conf/hadoop-env.sh
- #bind_ip=$(/sbin/ifconfig eth1:0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}')
- #replace eth1:0 with your NIC / alias 这种方式需要所有机器内外网对应的网卡顺序一致
- #bind_ip=$(/sbin/ifconfig | fgrep 'inet addr:172.16' | cut -d: -f2 | awk '{print $1}')
- #这种方式需要所有机器内网IP前缀一致
- bind_ip=$(/bin/hostname)
- #这种方式需要在/etc/hosts里将hostname指向内网IP
- export BIND_OPTS="-Dlocal.bind.address=${bind_ip}"
- # Command specific options appended to HADOOP_OPTS when specified
- export HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_NAMENODE_OPTS $BIND_OPTS"
- export HADOOP_SECONDARYNAMENODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_SECONDARYNAMENODE_OPTS $BIND_OPTS"
- export HADOOP_DATANODE_OPTS="-Dcom.sun.management.jmxremote $HADOOP_DATANODE_OPTS $BIND_OPTS"
- export HADOOP_BALANCER_OPTS="-Dcom.sun.management.jmxremote $HADOOP_BALANCER_OPTS $BIND_OPTS"
- export HADOOP_JOBTRACKER_OPTS="-Dcom.sun.management.jmxremote $HADOOP_JOBTRACKER_OPTS $BIND_OPTS"
2、修改$HADOOP_HOME/conf/hdfs-site.xml
- <property>
- <property>
- <name>dfs.http.address</name>
- <value>${local.bind.address}:50070</value>
- </property>
- <property>
- <name>dfs.https.address</name>
- <value>${local.bind.address}:50470</value>
- </property>
- <property>
- <name>dfs.secondary.http.address</name>
- <value>${local.bind.address}:50090</value>
- </property>
- <property>
- <name>dfs.datanode.address</name>
- <value>${local.bind.address}:50010</value>
- </property>
- <property>
- <name>dfs.datanode.ipc.address</name>
- <value>${local.bind.address}:50020</value>
- </property>
- <property>
- <name>dfs.datanode.http.address</name>
- <value>${local.bind.address}:50075</value>
- </property>
- <property>
- <name>dfs.datanode.https.address</name>
- <value>${local.bind.address}:50475</value>
- </property>
3、修改$HADOOP_HOME/conf/mapred-site.xml
- <property>
- <name>mapred.job.tracker.http.address</name>
- <value>${local.bind.address}:50030</value>
- </property>
- <property>
- <name>mapred.task.tracker.http.address</name>
- <value>${local.bind.address}:50060</value>
- </property>
4、重启
- $HADOOP_HOME/bin/stop-all.sh
- $HADOOP_HOME/bin/start-all.sh
相关推荐
HTKLPXH 2019-11-08
Linux 2011-05-07
云端轻躺 2011-10-30
cogbee 2011-10-15
thone00 2011-03-31
Mrsandman 2016-06-16
ITfooter 2019-06-28
chenhua 2019-06-28
wuyemenghuirt 2019-06-26
MichelinMessi 2017-09-05
yangbf 2016-08-29
raylanhu 2016-04-17
badun 2016-02-13
iammrziran 2017-11-10
wangkeIDC 2013-11-11
llfjfz 2017-03-14
songsong0 2017-01-12