Hadoop(亲自搭建四天经验分享,填坑版,看完你搭建失败我吃*)
废话不多说,宝宝心里苦!!!!初次体验博主就没有使用虚拟机,博主比较土豪,三台腾讯云,搭建四天都失败,Failed to start the agentjava.net.BindException: Cannot assign requested addressat java.net.PlainSocketImpl.socketBind(Native Method)
废话不多说,宝宝心里苦!!!!
初次体验博主就没有使用虚拟机,博主比较土豪,三台腾讯云,搭建四天都失败,
Failed to start the agentjava.net.BindException: Cannot assign requested address
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:170)
at org.jboss.remoting.transport.socket.SocketServerInvoker.createServerSocket(SocketServerInvoker.java:264)
at org.jboss.remoting.transport.socket.SocketServerInvoker.start(SocketServerInvoker.java:193)
at org.jboss.remoting.transport.Connector.start(Connector.java:324)
错误是这样的,你不知道吧,土豪博主直接使用的公网ip,导致的这种错误,我们发现腾讯云有这样一条公告,
非常有趣吧,土豪博主暴露了,其实用的三个人的学生机搭建的。
博主非常土豪,得知真相立马换了阿里云,购置两台服务器测试一把,一把就成功了,喜大普奔!!!!
ubuntu 14.04 64位 两台,一台为master,一台为slave1
增加hadoop用户组
sudo addgroup hadoop
sudo adduser -ingroup hadoop hadoop
sudo vim /etc/sudoers(增加 hadoop ALL=(ALL:ALL) ALL)
修改主机名
sudo vim /etc/hostname(删除其中,改为master或者slave1或者slave2……)
修改hosts
sudo vim /etc/hosts(把群集的内网ip对应的主机名添加进去)
例如
10.116.154.134 master
10.116.32.20 slave1
重启机器
shutdown -r now
安装SSH无密码登录
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub slave1(复制到群集其他机器)
群集之间相互操作,使每个机器的authorized_keys内容保持一致
安装JDK
apt-get install openjdk-7-jdk
vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export HADOOP_HOME=/home/hadoop/hadoop-2.6.0
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
立即生效
source /etc/profile
安装hadoop-2.6.0
wget http://xxx.com/hadoop-2.6.0.tar.gz
(自己找吧)
安装到/home/hadoop目录中解压
sudo tar -zxvf hadoop-2.6.0.tar.gz
配置文件
cd /home/hadoop/hadoop-2.6.0/etc/hadoop
core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:55555</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/hadoop_tmp</value>
</property>
</configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.safemode.extension</name>
<value>0</value>
</property>
<property>
<name>dfs.namenode.checkpoint.dir</name>
<value>file:///home/hadoop/hdfs/namesecondary</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///home/hadoop/hdfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///home/hadoop/hdfs/datanode</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobtracker.staging.root.dir</name>
<value>/user</value>
</property>
</configuration>
yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>master:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>master:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>master:8031</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>master:8033</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>master:8088</value>
</property>
</configuration>
hadoop-env.sh 修改JAVA_HOME路径
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export HADOOP_PREFIX=/home/hadoop/hadoop-2.6.0
slaves修改,添加全部奴隶主机
Slave1
Slave2
yarn-env.sh
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
先格式化后再启动,ip:50070查看live node数量,跟奴隶数量一致则成功
hadoop namenode -format
hdfs namenode -format
start-all.sh
告诉你什么叫正常
在这我们能看到奴隶存活的数量,我们只有一个奴隶,他活着,很舒服,
看了这篇笔记,你搭建不好,尽管XXXX
土豪博主觉得不爽,又搞了一台,添加了启动时,昨天添加的slave1没有启动成功,看了一下log
2017-03-30 18:03:04,067 INFO org.apache.hadoop.hdfs.server.common.Storage: Lock on /home/hadoop/hdfs/datanode/in_use.lock acquired by nodename 1832@slave1
2017-03-30 18:03:04,069 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed for Block pool <registering> (Datanode Uuid unassigned) service to master/10.116.154.134:55555. Exiting.
java.io.IOException: Incompatible clusterIDs in /home/hadoop/hdfs/datanode: namenode clusterID = CID-3ef26559-61af-4b6c-93ce-3b460e166c3c; datanode clusterID = CID-8a5fcfc2-ce5b-4f39-b114-8091622ce32f
at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:646)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.addStorageLocations(DataStorage.java:320)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:403)
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:422)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initStorage(DataNode.java:1311)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initBlockPool(DataNode.java:1276)
at org.apache.hadoop.hdfs.server.datanode.BPOfferService.verifyAndSetNamespaceInfo(BPOfferService.java:314)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.connectToNNAndHandshake(BPServiceActor.java:220)
at org.apache.hadoop.hdfs.server.datanode.BPServiceActor.run(BPServiceActor.java:828)
根据提示,删除了/home/hadoop/hdfs这个目录的所有文件,然后启动成功了,这下爽翻了。
今天安装了Spark,出现了问题,我们把服务器重启了一下,master的namenode,slave的datenode没有启动起来,我们分别找到master的hadoop下hdfs文件下的namenode-》current文件夹整个删除,同样的在slave上,删除datenode下的current,hadoop namenode -format ,start-all.sh, 启动成功
更多推荐
所有评论(0)