一、准备工作:
操作系统:Linux(CentOS 7.0)
下载
Java(jdk-8u111-linux-x64.rpm)
Hive2.1.1(apache-hive-2.1.1-bin.tar.gz jdk-8u111-linux-x64.rpm)
Hadoop2.7.3(hadoop-2.7.3.tar.gz)
下载Java(JDK)
点击打开链接
下载安装在官网可下载最新版(Hadoop/Hive)
点击打开链接
把下载文件存放在CentOS桌面文件(Hadoop)
二、安装配置
1、 安装 java (JDK)
- [root@localhost Hahoop]# yuminstall -y jdk-8u111-linux-x64.rpm
查看安装后的版本
- [root@localhost Hahoop]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM(build 25.111-b14, mixed mode)
2、 解压hadoop和hive程序
- [root@localhost Hahoop]# tar -xzfhadoop-2.7.3.tar.gz
- [root@localhost Hahoop]# tar -xzfapache-hive-2.1.1-bin.tar.gz
查看解压文件夹
- [root@localhost Hahoop]# ls
apache-hive-2.1.1-bin hadoop-2.7.3 jdk-8u111-linux-x64.rpm
apache-hive-2.1.1-bin.tar.gz hadoop-2.7.3.tar.gz
3、 移动解压文件并重命名hive/Hadoop
- [root@localhost Hahoop]# mvhadoop-2.7.3 /usr/Hadoop
- [root@localhost Hahoop]# mvapache-hive-2.1.1-bin /usr/hive
4、 配置环境变量(HADOOP)
- [root@localhost hadoop]# vim~/.bashrc
添加:
- # set hadoop/hive/jdk(java) path
- export HADOOP_HOME=/usr/hadoop
- export HIVE_HOME=/usr/hive
- export JAVA_HOME=/usr/java/jdk1.8.0_111
- export PATH="$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$JAVA_HOME/bin"
生效:
- [root@localhost hadoop]# source~/.bashrc
5、 创建目录Hadoop
- [root@localhost hadoop]# cd /usr/Hadoop
- [root@localhost hadoop]# mkdir tmp
- [root@localhost hadoop]# mkdir hdfs
- [root@localhost hadoop]# mkdir hdfs/data
- [root@localhost hadoop]# mkdir hdfs/name
6、 设置配置文件
5.0、指定文件所在路径
- [root@localhost hadoop]# cd/usr/hadoop/etc/Hadoop
5.1、配置hadoop-env.sh]
- <span style="font-weight: normal;">[root@localhost hadoop]# vimhadoop-env.sh</span>
--添加
- #export JAVA_HOME=${JAVA_HOME}
- export JAVA_HOME=/usr/java/jdk1.8.0_111
5.2、配置yarn-env.sh
- [root@localhost hadoop]# vim yarn-env.sh
添加
- # export JAVA_HOME=/home/y/libexec/jdk1.6.0/
- exportJAVA_HOME=/usr/java/jdk1.8.0_111
5.3、配置core-site.xml
- [root@localhost hadoop]# vimcore-site.xml
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost:9000</value>
- <description>HSDF的URL,文件系统:namenode标识:端口号</description>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/usr/hadoop/tmp</value>
- <description>本地hadoop临时文件夹</description>
- </property>
- </configuration>
5.4、配置hdfs-site.xml
- [root@localhost hadoop]# vim hdfs-site.xml
- <configuration>
- <property>
- <name>dfs.name.dir</name>
- <value>/usr/hadoop/hdfs/name</value>
- <description>namenode上存储hdfs名字空间元数据</description>
- </property>
- <property>
- <name>dfs.data.dir</name>
- <value>/usr/hadoop/hdfs/data</value>
- <description>datanode上数据块的物理存储位置</description>
- </property>
-
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- <description>副本个数,默认3应该小于datanode机器数量</description>
- </property>
- </configuration>
5.5、配置yarn-site.xml
- [root@localhost hadoop]# vim yarn-site.xml
- <configuration>
- <property>
- <name>yarn.nodemanager.aux-services</name>
- <value>mapreduce_shuffle</value>
- </property>
- <property>
- <name>yarn.resourcemanager.webapp.address</name>
- <value>localhost:8099</value>
- </property>
- </configuration>
5.6、配置mapred-site.xml(启用服务时没用到,可不用配置)
- [root@localhost hadoop]# mvmapred-site.xml.template mapred-site.xml
- [root@localhost hadoop]# vim mapred-site.xml
- <configuration>
- <property>
- <name>mapreduce.framework.name</name>
- <value>yarn</value>
-
- </property>
- </configuration>
6、配置ssh无密码(1.产生RSA密钥对;2.群集内共享密钥)启动hadoop服务(启动dfs/yarn时的无需密码.注:如果home目录没有通过NFS共享需要其他方法共享密钥(ssh-copy-id,复制到远程主机调用格式:ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.2)
- [root@localhost hive]# ssh-keygen -t rsa-p'' -f ~/.ssh/id_rsa
- [root@localhost hive]# cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys
7、启动Hadoop
7.1、格式化namenode
- [root@localhost hadoop]# bin/hdfs namenode-format
7.2、启动hdfs(按提示输入yes和账号密码,配置了(步骤6) ssh时跳过输入密码步骤)
- [root@localhost hadoop]# sbin/start-dfs.sh
7.3、启动yarn(按提示输入yes和账号密码,配置了(步骤6) ssh时跳过输入密码步骤)
- [root@localhost hadoop]# sbin/start-yarn.sh
7.4、查看进程:
- [root@localhost hadoop]# jps
26161 DataNode
26021 NameNode
26344 SecondaryNameNode
26890 Jps
26492 ResourceManager
26767 NodeManager