一、hadoop下载,使用2.6.5版本
http://hadoop.apache.org/releases.html
tar -zxvf hadoop-2.6.5.tar.gz
笔者的路径是/root/Downloads/hadoop-2.6.5
二、Hadoop的配置
1、修改文件/root/Downloads/hadoop-2.6.5/etc/hadoop/hadoop-env.sh
export JAVA_HOME=/root/Downloads/jdk1.8.0_172
2、修改/etc/hadoop/core-site.xml 文件
hadoop.tmp.dir
file:/usr/local/hadoop/tmp
Abase for other temporary directories.
fs.defaultFS
hdfs://localhost:9000
HDFS,URI
3、修改etc/hadoop/hdfs-site.xml文件
dfs.replication
1
dfs.namenode.name.dir
file:/usr/local/hadoop/tmp/dfs/name
dfs.datanode.data.dir
file:/usr/local/hadoop/tmp/dfs/data
4、执行 NameNode 的格式化:
[root@bogon ~]# ./bin/hdfs namenode -format
成功的话,会看到 “successfully formatted” 和 “Exitting with status 0” 的提示,若为 “Exitting with status 1” 则是出错。
18/04/27 15:45:59 INFO common.Storage: Storage directory /usr/local/hadoop/tmp/dfs/name has been successfully formatted.
18/04/27 15:45:59 INFO namenode.FSImageFormatProtobuf: Saving image file /usr/local/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
18/04/27 15:45:59 INFO namenode.FSImageFormatProtobuf: Image file /usr/local/hadoop/tmp/dfs/name/current/fsimage.ckpt_0000000000000000000 of size 321 bytes saved in 0
seconds.
18/04/27 15:45:59 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
18/04/27 15:45:59 INFO util.ExitUtil: Exiting with status 0
18/04/27 15:45:59 INFO namenode.NameNode: SHUTDOWN_MSG:
5、SSH免密码登录(单机版不需要像某些教程提到的新建hadoop用户,即不新建用户)
[root@bogon ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
a1:52:80:19:6c:48:57:44:2b:6d:68:f7:ee:36:88:d3 root@bogon
The key's randomart image is:
+--[ DSA 1024]----+
|.+.==+ |
|. * o.. |
| . + =. . |
| . +... . |
| . ..S |
| .. |
| o .. |
| o E.o |
| . ... |
+-----------------+
[root@bogon ~]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[root@bogon ~]# chmod 0600 ~/.ssh/authorized_keys
6、hdfs启动与停止
[root@bogon hadoop-2.6.5]# ./sbin/start-dfs.sh
Starting namenodes on [localhost]
localhost: starting namenode, logging to /root/Downloads/hadoop-2.6.5/logs/hadoop-root-namenode-bogon.out
localhost: starting datanode, logging to /root/Downloads/hadoop-2.6.5/logs/hadoop-root-datanode-bogon.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /root/Downloads/hadoop-2.6.5/logs/hadoop-root-secondarynamenode-bogon.out
[root@bogon hadoop-2.6.5]# jps
9153 DataNode
9298 SecondaryNameNode
9413 Jps
9036 NameNode
[root@bogon hadoop-2.6.5]# ./sbin/stop-dfs.sh
启动完成后,可以通过命令 jps 来判断是否成功启动,若成功启动则会列出如下进程: “NameNode”、”DataNode”和SecondaryNameNode(如果 SecondaryNameNode 没有启动,请运行 sbin/stop-dfs.sh 关闭进程,然后再次尝试启动尝试)。如果没有 NameNode 或 DataNode ,那就是配置不成功,请仔细检查之前步骤,或通过查看启动日志排查原因。
7、web监控,浏览器输入
http://localhost:50070
8、配置yarn文件(非必须)
配置/etc/hadoop/mapred-site.xml 。这里注意一下,hadoop里面默认是mapred-site.xml.template 文件,如果配置yarn,把mapred-site.xml.template 重命名为mapred-site.xml 。如果不启动yarn,把重命名还原。
mapred-site.xml
mapreduce.framework.name
yarn
yarn-site.xml
yarn.nodemanager.aux-services
mapreduce_shuffle
YARN 是从 MapReduce 中分离出来的,负责资源管理与任务调度。YARN 运行于 MapReduce 之上,提供了高可用性、高扩展性,但 YARN 主要是为集群提供更好的资源管理与任务调度,然而这在单机上体现不出价值,反而会使程序跑得稍慢些。因此在单机上是否开启 YARN 就看实际情况了。
启动和停止的终端命令是:
[root@bogon hadoop-2.6.5]# ./sbin/start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /root/Downloads/hadoop-2.6.5/logs/yarn-root-resourcemanager-bogon.out
localhost: starting nodemanager, logging to /root/Downloads/hadoop-2.6.5/logs/yarn-root-nodemanager-bogon.out
[root@bogon hadoop-2.6.5]# jps
9153 DataNode
9298 SecondaryNameNode
10180 Jps
10056 ResourceManager
9036 NameNode
10142 NodeManager
[root@bogon hadoop-2.6.5]# ./sbin/stop-yarn.sh
三、Hase的配置
先看姊妹篇的介绍:CentOS7使用HBase-1.2.6单机版,无hadoop
再来修改配置文件/root/Downloads/hbase-1.2.6/conf/hbase-site.xml
hbase.tmp.dir
/usr/local/hbase/hbaseData
hbase.rootdir
hdfs://localhost:9000/hbase
hbase.zookeeper.quorum
localhost
启动验证
[root@bogon ~]# cd /root/Downloads/hbase-1.2.6/bin
[root@bogon bin]# ./start-hbase.sh
starting master, logging to /usr/local/hbase/logs/hbase-root-master-bogon.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
[root@bogon bin]# jps
9153 DataNode
9298 SecondaryNameNode
11379 Jps
11339 HMaster
9036 NameNode
我们来检测一下HBase有没有连接上Hadoop
[root@bogon ~]# cd /root/Downloads/hadoop-2.6.5/bin
[root@bogon bin]# hdfs dfs -ls /
Found 1 items
drwxr-xr-x - root supergroup 0 2018-04-27 17:05 /hbase
说明自动建立/hbase文件夹成功了,连接ok!
---
参考文献:
hadoop2.7.3在centos7上部署安装(单机版)
hadoop2.6.5和Hbase1.2.6单机搭建
Hadoop安装教程_单机/伪分布式配置_CentOS6.4/Hadoop2.6.0
本地主机操作虚拟机中的hadoop+hbase+自带zookeeper