时间:2021-07-01 10:21:17 帮助过:27人阅读
机器mac book,virtualbox4.3.6,virtualbox安装ubunt13.10,在多点分布环境中,配置好一个机器后,clone出另外2个,一共三台机器。 1. Configure the Environment Bash语言: sudo apt-get install -y openjdk-7-jdk openssh-server sudo addgroup hadoop su
机器mac book,virtualbox4.3.6,virtualbox安装ubunt13.10,在多点分布环境中,配置好一个机器后,clone出另外2个,一共三台机器。
1. Configure the Environment
Bash语言: sudo apt-get install -y openjdk-7-jdk openssh-server
sudo addgroup hadoop
sudo adduser —ingroup hadoop hadoop # create password
sudo visudo
hadoop ALL=(ALL) ALL # hadoop user can use sudo
su - hadoop # need password
ssh-keygen -t rsa -P "" # Enter file (/home/hadoop/.ssh/id_rsa)
cat /home/hadoop/.ssh/id_rsa.pub >> /home/hadoop/.ssh/authorized_keys
wget http://apache.fayea.com/apache-mirror/hadoop/common/hadoop-2.3.0/hadoop-2.3.0.tar.gz
tar zxvf hadoop-2.3.0.tar.gz
sudo cp -r hadoop-2.3.0/ /opt
cd /opt
sudo ln -s hadoop-2.3.0 hadoop
sudo chown -R hadoop:hadoop hadoop-2.3.0
sed -i '$a \\nexport JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64' hadoop/etc/hadoop/hadoop-env.sh
2. Configure hadoop single Node environment
cp mapred-site.xml.template mapred-site.xml
vi mapred-site.xml
vi yarn-site.xml
补充配置:
mapred-site.xml
core-site.xml
hdfs-site.xml
Bash语言: cd /opt/hadoop
bin/hdfs namenode -format
sbin/hadoop-daemon.sh start namenode
sbin/hadoop-daemon.sh start datanode
sbin/yarn-daemon.sh start resourcemanager
sbin/yarn-daemon.sh start nodemanager
jps
# Run a job on this node
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.3.0.jar pi 5 10
3. Running Problem
14/01/04 05:38:22 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:8023. Already tried 9 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
netstat -atnp # found tcp6
Solve:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6 # 0 means ipv6 is on, 1 means off
cat /proc/sys/net/ipv6/conf/lo/disable_ipv6
cat /proc/sys/net/ipv6/conf/default/disable_ipv6
ip a | grep inet6 # have means ipv6 is on
vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
sudo sysctl -p # have the same effect with reboot
sudo /etc/init.d/networking restart
4. Cluster setup
Config /opt/hadoop/etc/hadoop/{hadoop-env.sh, yarn-env.sh}
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
cd /opt/hadoop
mkdir -p tmp/{data,name} # on every node. name on namenode, data on datanode
vi /etc/hosts # hostname also changed on each node
192.168.1.110 cloud1
192.168.1.112 cloud2
192.168.1.114 cloud3
vi /opt/hadoop/etc/hadoop/slaves
cloud2
cloud3
core-site.xml
据说dfs.datanode.data.dir 需要清空,不然datanode不能启动
hdfs-site.xml
yarn-site.xml
mapred-site.xml
cd /opt/hadoop/
bin/hdfs namenode -format
sbin/start-dfs.sh # cloud1 NameNode SecondaryNameNode, cloud2 and cloud3 DataNode
sbin/start-yarn.sh # cloud1 ResourceManager, cloud2 and cloud3 NodeManager
jps
查看集群状态 bin/hdfs dfsadmin -report
查看文件块组成 bin/hdfs fsck / -files -blocks
NameNode查看hdfs http://192.168.1.110:50070
查看RM http://192.168.1.110:8088
bin/hdfs dfs -mkdir /input
bin/hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.3.0.jar randomwriter input
5. Questions:
Q: 14/01/05 23:59:05 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
A: /opt/hadoop/lib/native/ 下面的动态链接库是32bit的,要替换成64位的
Q: ssh 登录出现Are you sure you want to continue connecting (yes/no)?解决方法
A: 修改/etc/ssh/ssh_config 将其中的# StrictHostKeyChecking ask 改成 StrictHostKeyChecking no
Q: 两个slaves的DataNode无法加入cluster系统,
A: 把/etc/hosts 里面127.0.1.1或localhost 的内容行删除