赞
踩
一 hadoop的安装
1.解决本机的免密钥登录问题
在root用户在输入 ssh-keygen -t -rsa,连着敲三下,生成本机的密钥,后进入/root/.ssh目录下,将密钥写入到权限文件中,即 cat id_rsa.pub >> authorized_keys
2.安装jdk
官网下载jdk后,解压至环境中的某一目录下,后在通过命令 vim /etc/profile,添加如下内容
export JAVA_HOME=/opt/install/jdk1.8.0_251
export PATH=$JAVA_HOME/bin:$PATH
添加完毕后,source /etc/profile,生效配置,在命令行中输入 java -version,验证jdk是否安装完毕
3.官网下载hadoop,本文以3.2.1为例,解压至指定目录下,
进入解压后的目录,分别新建data nameData nameDataDir
进入/opt/install/hadoop-3.2.1/etc/hadoop目录下,分别修改core-site.xml,内容为
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/install/hadoop-3.2.1/data</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/opt/install/hadoop-3.2.1/nameData</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://test:9000</value>
</property>
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property
修改hdfs-site.xml文件
<property>
<name>dfs.data.dir</name>
<value>/opt/install/hadoop-3.2.1/nameDataDir</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permissions.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.permissions</name>
<value>true</value>
</property>
修改yarn-site.xml文件为
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
修改hadoop-env.sh,添加内容 export JAVA_HOME=/opt/install/jdk1.8.0_251
4.修改start/stop-dfs.sh start/stop-yarn.sh,在文件头添加如下内容:
#!/usr/bin/env bash
HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
5.初始化namenode,命令为./hadoop dfs namenode -format
6.执行完毕后,进入sbin目录下输入,./start-all.sh,启动所有进程
7.启动完毕后,在本地浏览器中输入http://虚拟机IP地址:9870
二 hive的安装
1.官网上下载与hadoop相对应的hive版本,本文采用的hive版本为2.3.7
2.解压hive至指定的路径下,修改hive-site.xml(可以直接复制hive-default.xml)文件为
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_test?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.server2.thrift.client.user</name>
<value>root</value>
<description>Username to use against thrift client</description>
</property>
<property>
<name>hive.server2.thrift.client.password</name>
<value>123456</value>
<description>Password to use against thrift client</description>
</property>
<property>
<name>hive.server2.authentication</name>
<value>NONE</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>test</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>TCP port number to listen on, default 10000</description>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>true</value>
</property>
3.在hive-env.sh文件中添加如下内容
HADOOP_HOME=/opt/install/hadoop-3.2.1
# Hive Configuration Directory can be controlled by:
# export HIVE_CONF_DIR=
export HIVE_CONF_DIR=/opt/install/hive-2.3.7/conf
4.完成后,进入/opt/install/hive-2.3.7/bin目录下,执行./schematool -dbType mysql --initSchema完成数据库初始化
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。