安装版本:hadoop-2.6.0-cdh5.15.1
下载地址:http://archive.cloudera.com/cdh5/cdh/5/
jdk版本:1.8
单节点安装步骤
添加hadoop用户
groupadd hadoop
useradd -g hadoop -m -s /bin/bash hadoop # 创建用户
passwd 123456 # 设置 hadoop 密码为 123456
添加hadoop用户管理员权限
visudo # vim /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
hadoop ALL=(ALL) ALL
## Allows people in group wheel without a password
%wheel ALL=(ALL) NOPASSWD: ALL
gpasswd -a hadoop wheel # 将 hadoop 用户加入到 wheel 组
安装并配置ssh无密码登陆
ssh-keygen -t rsa #生成 .ssh文件夹
[hadoop@hadoop000 ~]$ cd .ssh
[hadoop@hadoop000 .ssh]$ ll
total 16
-rw------- 1 hadoop hadoop 1675 Jun 28 13:56 id_rsa #ssh私钥
-rw-r--r-- 1 hadoop hadoop 398 Jun 28 13:56 id_rsa.pub #ssh公钥
-rw-r--r-- 1 hadoop hadoop 355 Jun 28 14:04 known_hosts
cat id_rsa.pub >> authorized_keys #设置免密登陆
-rw------- 1 hadoop hadoop 398 Jun 28 13:58 authorized_keys
chmod 600 authorized_keys #设置权限
安装hadoop
下载tar包并解压
配置jdk路径:
etc/hadoop/hadoop-env.sh
[hadoop@hadoop000 hadoop]$ vi ~/app/hadoop-2.6.0-cdh5.15.1/etc/hadoop/hadoop-env.sh
# The java implementation to use.
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/home/hadoop/app/jdk1.8.0_211
配置主节点的默认文件系统:
etc/hadoop/core-site.xml:
vi core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop000:8020</value>
</property>
</configuration>
配置文件系统的副本系数:
etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
配置hadoop临时文件存放目录(防止服务器重启tmp目录丢失):
etc/hadoop/hdfs-site.xml:
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/app/tmp</value>
</property>
第一次启动hdfs时先格式化hdfs:
[hadoop@hadoop000 tmp]$ hdfs namenode -format
启动hdfs服务:
sbin/./start-dfs.sh
[hadoop@hadoop000 sbin]$ ./start-dfs.sh
查看hdfs进程:
[hadoop@hadoop000 sbin]$ jps
26464 SecondaryNameNode
26196 NameNode
26567 Jps
26314 DataNode
hdfs管理界面:
http://localhost:50070
如果管理界面打不开,有可能是服务器防火墙打开了,
查看防火墙状态:
firewall-cmd --state
关闭防火墙:
sytemctl stop firewalled.service