本文共 3447 字,大约阅读时间需要 11 分钟。
namenode: 192.168.0.160datanode: 192.168.0.160,192.168.0.161mysql-server: 192.168.0.170hadoop版本: 2.6.5hive版本:1.2.2mysql版本:5.7主机操作系统:ubuntu-16.04-x64
在安装hive前,需要了解hive部署的三种模式:
本文讲解第三种部署方式,数据库采用mysql。
hive是基于hadoop来进行数据分析,因此需要先安装hadoop,可以参考
sudo apt-get install mysql-serversudo apt install mysql-clientsudo apt install libmysqlclient-dev
现在设置mysql允许远程访问
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1中的ip部分修改为0.0.0.0。
bind-address = 0.0.0.0
重启mysql服务
sudo service mysql restart
查看mysql服务的运行状态
sudo netstat -tlnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN #mysql进程 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN
下载hive,点击。
将下载后的二进制包上传到namenode上,并解压。
tar xf apache-hive-1.2.2-bin.tar.gz mv apache-hive-1.2.2-bin hive
修改配置文件conf/hive-env.sh
cp conf/hive-env.sh.template conf/hive-env.shvim conf/hive-env.sh#修改内容HADOOP_HOME=/home/hadoop/software/hadoop-2.6.5
修改配置文件conf/hive-site.conf
cp conf/hive-default.xml.template conf/hive-site.xmlvim conf/hive-site.xml#数据库URL#下面两项必须配置,不然启动会报错 javax.jdo.option.ConnectionURL jdbc:mysql://192.168.0.170:3306/hive?createDatabaseIfNoExist=true&characterEncoding=utf8&useSSL=true&useUnicode=true&serverTimezone=UTC JDBC connect string for a JDBC metastore system:user.name hadoop #数据库用户名 system:java.io.tmpdir /home/hadoop/software/hive/tmp #数据库连接驱动 javax.jdo.option.ConnectionUserName root Username to use against metastore database #数据库连接密码 javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver Driver class name for a JDBC metastore javax.jdo.option.ConnectionPassword 123456 password to use against metastore database
下载mysql jdbc驱动包,点击,并将驱动包拷贝到hive安装包lib路径下。
tar xf mysql-connector-java-5.1.46.tar.gzcp mysql-connector-java-5.1.46/mysql-connector-java-5.1.46.jar lib/# mysql server版本为5.7.x时,mysql-connector的版本选择5.x,否则可能出现不可预知错误。
启动hadoop
./sbin/start-all.sh
初始化hive
./bin/schematool -dbType mysql -initSchema Metastore connection URL: jdbc:mysql://192.168.0.170:3306/hive?createDatabaseIfNoExist=true&characterEncoding=utf8&useSSL=true&useUnicode=true&serverTimezone=UTC Metastore Connection Driver : com.mysql.cj.jdbc.Driver Metastore connection User: root Starting metastore schema initialization to 1.2.0 Initialization script hive-schema-1.2.0.mysql.sql Initialization script completed schemaTool completed
启动hive
./bin/hiveLogging initialized using configuration in jar:file:/home/hadoop/software/hive/lib/hive-common-1.2.2.jar!/hive-log4j.propertieshive> show databases;OKdefaultTime taken: 0.021 seconds, Fetched: 1 row(s)hive>
至此hive安装完毕。
转载地址:http://yzjmb.baihongyu.com/