共计 4281 个字符,预计需要花费 11 分钟才能阅读完成。
丸趣 TV 小编给大家分享一下 hadoop 2 伪分布式如何搭建,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
单点伪分布式
1. 下载 hadoop
2. 安装 jdk,设置环境变量
export JAVA_HOME=/usr/local/java/jdk1.7.0_79
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=./:/$JAVA_HOME/lib:$JAVA_HOME/jre/lib
[root@iZ281cu2lqjZ etc]# source /etc/profile
3. 创建用于和组
groupadd hadoop
useradd -g hadoop yarn
useradd -g hadoop hdfs
useradd -g hadoop mapred
4. 创建数据和日志目录
mkdir -p /var/data/hadoop/hdfs/nn
mkdir -p /var/data/hadoop/hdfs/snn
mkdir -p /var/data/hadoop/hdfs/dn
chown hdfs:hadoop /var/data/hadoop/hdfs -R
mkdir -p /var/log/hadoop/yarn
chown yarn:hadoop /var/log/hadoop/yarn -R
进入 yarnhadoop 的目录中
mkdir logs
chmod g+w logs
chown yarn:hadoop . -R
5. 配置 core-site.xml
property
name fs.default.name /name
value hdfs://localhost:9000 /value
/property
property
name hadoop.http.staticuser.user /name
value hdfs /value
/property
fs.default.name 是 Namenode 指定了主机名和请求端口号;
hadoop.http.staticuser.user 是 hdfs 的默认用户名
6. 配置 hdfs.site.xml
property
name dfs.replication /name
value 1 /value — 默认为 3
/property
property
name dfs.namenode.name.dir /name
value file:/var/data/hadoop/hdfs/nn /value
/property
property
name fs.checkpoint.dir /name
value file:/var/data/hadoop/hdfs/snn /value
/property
property
name fs.checkpoint.edit.dir /name
value file:/var/data/hadoop/hdfs/snn /value
/property
property
name dfs.datanode.data.dir /name
value file:/var/data/hadoop/hdfs/db /value
/property
7. 配置 mapred-site.xml
property
name mapreduce.framework.name /name
value yarn /value
/property
为 mapreduce 制定框架名,使用 yarn
8 配置 yarn-site.xml
property
name yarn.nodemanager.aux-services /name
value mapreduce_shuffle /value
/property
property
name yarn.nodemanager.aux-services.mapreduce.shuffle.class /name
value org.apache.hadoop.mapred.ShuffleHandler /value
/property
主要是配置 shuffle,默认是没有配置 shuffle
9. 调整 JAVA 堆大小
hadoop-env.sh
HADOOP_HEAPSIZE= 500
yarn-env.sh
YARN_HEAPSIZE=500
10. 格式化 HDFS
切换到 hdfs 用户,进入到 hadoop bin 目录执行
./hdfss namenode -format
碰到问题
11../hdfs namenode -format
12.[hdfs@localhost sbin]$ ./hadoop-daemon.sh start namenode
starting namenode, logging to /opt/yarn/hadoop-2.7.1/logs/hadoop-hdfs-namenode-localhost.out
[hdfs@localhost sbin]$ ./hadoop-daemon.sh start secondarynamenode
starting secondarynamenode, logging to /opt/yarn/hadoop-2.7.1/logs/hadoop-hdfs-secondarynamenode-localhost.out
[hdfs@localhost sbin]$ ./hadoop-daemon.sh start datanode
starting datanode, logging to /opt/yarn/hadoop-2.7.1/logs/hadoop-hdfs-datanode-localhost.out
使用 JPS 可以检查进程
结果:
[hdfs@localhost sbin]$ jps
3915 SecondaryNameNode
3969 DataNode
3833 NameNode
4047 Jps
12. 启动 yarn
[yarn@localhost sbin]$ ./yarn-daemon.sh start nodemanager
/opt/yarn/hadoop-2.7.1/etc/hadoop/yarn-env.sh: line 121: unexpected EOF while looking for matching `
/opt/yarn/hadoop-2.7.1/etc/hadoop/yarn-env.sh: line 124: syntax error: unexpected end of file
starting nodemanager, logging to /opt/yarn/hadoop-2.7.1/logs/yarn-yarn-nodemanager-localhost.out
/opt/yarn/hadoop-2.7.1/etc/hadoop/yarn-env.sh: line 121: unexpected EOF while looking for matching `
/opt/yarn/hadoop-2.7.1/etc/hadoop/yarn-env.sh: line 124: syntax error: unexpected end of file
[yarn@localhost sbin]$ jps
4132 ResourceManager
4567 Jps
4456 NodeManager
13 验证
访问: ip:50070
ip:8088
最后可以运行 hadoop 包中的例子进行检验。这就是伪分布式简单的安装步骤。
问题:如果遇到 50070 端口不能访问就是 yarn 没有成功启动。
去 sbin 启动 yarn ./start-yarn.sh 时报
localhost: Error: JAVA_HOME is not set and could not be found.
需要修改 hadoop-env.xml 中 java_home 设置为绝对路径。
重启 yarn 解决问题。
配置 hbase:
修改 hbase-env.sh
修改# export JAVA_HOME=/usr/local/java/jdk1.7.0_79
修改 hbase-site.xml
configuration
property
name hbase.rootdir /name
value hdfs://localhost:9000/hbase /value
/property
property
name dfs.replication /name
value 1 /value
/property
property
name hbase.cluster.distributed /name
value true /value
/property
/configuration
启动 hbase:
[root@iZ281cu2lqjZ bin]# ./start-hbase.sh
root@localhost s password:
localhost: starting zookeeper, logging to /usr/local/hbase/hbase-1.1.4/bin/../logs/hbase-root-zookeeper-iZ281cu2lqjZ.out
starting master, logging to /usr/local/hbase/hbase-1.1.4/bin/../logs/hbase-root-master-iZ281cu2lqjZ.out
starting regionserver, logging to /usr/local/hbase/hbase-1.1.4/bin/../logs/hbase-root-1-regionserver-iZ281cu2lqjZ.out
[root@iZ281cu2lqjZ bin]# jps
1597 DataNode
3180 ResourceManager
3463 NodeManager
1462 NameNode
8680 HRegionServer
1543 SecondaryNameNode
8536 HQuorumPeer
8597 HMaster
8729 Jps
完成
看完了这篇文章,相信你对“hadoop 2 伪分布式如何搭建”有了一定的了解,如果想了解更多相关知识,欢迎关注丸趣 TV 行业资讯频道,感谢各位的阅读!