环境:macOS High Sierra10.13.6、mysql8.0.15、Hadoop3.1.1、Hive3.1.1。
参考资料:
在mysql官网下载安装包。我下载的是mysql-8.0.15-macos10.14-x86_64.dmg。双击文件就进入了安装流程,按照提示操作就行了。
安装完成后,在终端输入mysql -uroot -ppwd
(pwd是root用户的密码),能进入mysql的命令行就说明安装成功。
可以在Hadoop官网下载压缩包,解压安装。也可以通过brew进行安装,安装完成后文件在/usr/local/Cellar下。
brew install hadoop
进入目录/usr/local/Cellar/hadoop/3.1.1/libexec/etc/hadoop,修改hadoop的配置文件。
(1)修改hadoop-env.sh,配置java jdk路径
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
(2) 修改core-site.xml,配置内容如下
<configuration>
<property>
<name>fs.defaultFSname>
<value>hdfs://locahost:9000value>
property>
configuration>
(3)修改hdfs-site.xml,修改配置如下
<configuration>
<property>
<name>dfs.replicationname>
<value>1value>
property>
configuration>
(4) 修改mapred-site.xml,修改配置如下
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
configuration>
(5)修改yarn-site.xml,修改内容如下
<configuration>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.resourcemanager.hostnamename>
<value>localhostvalue>
property>
configuration>
将hadoop添加到环境变量vim /etc/profile
,然后更新一下环境变量:source /etc/profile
export HADOOP_HOME=/usr/local/Cellar/hadoop/3.1.1
PATH=$PATH:$HADOOP_HOME/bin
进入/usr/local/Cellar/hadoop/3.1.1目录。
(1)格式化hadoop
bin/hdfs namenode -format
执行成功,会在/tmp/hadoop-root/name/current下生成文件。
(2) 启动hdfs
sbin/start-dfs.sh
如果报错
Starting namenodes on [locahost]
ERROR: Attempting to operate on hdfs namenode as root
ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.
Starting datanodes
ERROR: Attempting to operate on hdfs datanode as root
ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
]tarting secondary namenodes [account.jetbrains.com
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
2019-03-19 15:39:56,085 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
编辑sbin/start-dfs.sh,在文件开始空白处添加以下内容:
HDFS_DATANODE_USER=root
HDFS_DATANODE_SECURE_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
如果报错
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
参考Hadoop _ 疑难杂症 解决1 - WARN util.NativeCodeLoader: Unable to load native-hadoop library for your plat解决
(3) 启动yarn
sbin/start-yarn.sh
如果报错
Starting resourcemanager
ERROR: Attempting to operate on yarn resourcemanager as root
ERROR: but there is no YARN_RESOURCEMANAGER_USER defined. Aborting operation.
Starting nodemanagers
ERROR: Attempting to operate on yarn nodemanager as root
ERROR: but there is no YARN_NODEMANAGER_USER defined. Aborting operation.
编辑sbin/start-yarn.sh,在文件开始空白处添加以下内容:
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
(4)命令行查看和web访问
验证是否成功,使用命令:jps,输出如下即表示配置成功。
12272 Jps
4135 JobTracker
9500 SecondaryNameNode
9943 NodeManager
9664 ResourceManager
8898 NameNode
9174 DataNode
也可以在浏览器中查看hdfs和mr的状态。
(1)下载解压压缩包
在Hive官网下载对应版本的压缩包,我下载的是Hive3.1.1。解压到/usr/local目录下:
sudo tar -zxvf apache-hive-3.1.1-bin.tar.gz -C /usr/local/
将文件重命名为hive文件:
mv apache-hive-3.1.1-bin hive
(2)修改环境变量
修改环境变量/etc/profile:
[root@s100 local]# vim /etc/profile
#hive
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
执行source /etc.profile
(3)验证安装
执行hive --version
有hive的版本显现,即安装成功!
(4)配置hive
修改hive-site.xml文件
javax.jdo.option.ConnectionUserName
root
javax.jdo.option.ConnectionPassword
123456
javax.jdo.option.ConnectionURL
jdbc:mysql://Master:3306/hive?createDatabaseIfNotExist=true
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
(5)将mysql的连接jar包拷贝到$HIVE_HOME/lib目录下
(6)启动hive
bin/hive