赞
踩
在Hadoop-2.7.3环境上部署Hive数据仓库,安装Hive需要apache-hive-2.1.1-bin.tar.gz软件包,在相关目录下解压软件包。
tar -zxvf [包名]
[root@master ~]# vi /etc/hosts
添加以下内容:
172.30.0.10 master
172.30.0.11 slave1
172.30.0.12 slave2
[root@master ~]# vi /root/.bash_profile
添加以下内容:
exprt HIVE_HOME=/opt/apache-hive-2.1.1-bin
export PATH=$PATH:$HIVE_HOME/bin
注意等号右边是安装hive的路径
[root@master ~]# cd /opt/apache-hive-2.1.1-bin/conf/
[root@master conf]# ls
beeline-log4j2.properties.template ivysettings.xml
hive-default.xml.template llap-cli-log4j2.properties.template
hive-env.sh.template llap-daemon-log4j2.properties.template
hive-exec-log4j2.properties.template parquet-logging.properties
hive-log4j2.properties.template
将文件名中的.template删除
格式:mv [原来的名字] [修改后的名字]
[root@master conf]# mv hive-env.sh.template hive-env.sh
vim /opt/apache-hive-2.1.1-bin/conf/hive-env.sh
#指定Hive配置文件的路径
export HIVE_CONF_DIR=/opt/apache-hive-2.1.1-bin/conf/
#指定Hive依赖的额外jar包的路径
export HIVE_AUX_JARS_PATH=/opt/apache-hive-2.1.1-bin/lib/
scp -r /opt/apache-hive-2.1.1-bin root@slave1:/opt
hive-site.xml
touch hive-site.xml
在主节点添加以下内容:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hive.metastore.warehouse.dir</name> <value>/hive/warehouse</value> <description>location of default database for the warehouse</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore.</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>Username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> <description>password to use against metastore database</description> </property> <property> <name>hive.querylog.location</name> <value>/opt/hive/logs</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.metastore.uris</name> <value>thrift://master:9083</value> <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> </property> <property> <name>hive.server2.webui.host</name> <value>0.0.0.0</value> </property> <property> <name>hive.server2.webui.port</name> <value>10002</value> </property> </configuration>
在子节点添加以下内容:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hive.metastore.warehouse.dir</name> <value>/hive/warehouse</value> <description>location of default database for the warehouse</description> </property> <property> <name>hive.querylog.location</name> <value>/opt/apache-hive-2.1.1-bin/logs</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.metastore.uris</name> <value>thrift://master:9083</value> <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> </property> </configuration>
yum list installed | grep mysql
如果有先检查是否可用,否则卸载掉。
格式:yum -y remove [SQL名]
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum install mysql-community-server
#/启动
service mysqld start
#查看MySQL的启动状态
systemctl status mysqld
#查看musql随机密码
grep 'temporary password' /var/log/mysqld.log
#登陆数据库
mysql -u root -p
出现“mysql>”字样表示登陆成功
mysql> set global validate_password_policy=0; #关闭密码复杂度策略
mysql>set global validate_password_length=1; #设置密码长度下限
#需改root初始密码。注意:此处的root并非主机登录的root
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
#创建hive用户供hive使用
mysql>create user 'hive'@'%' identified by '123456';
#此处user的名字需要跟hive-site.xml文件配置的一致
mysql>select user,host from mysql.user where user='hive';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
#刷新权限
mysql>flush privileges
schematool -dbType mysql -initSchema
注意:此处可能会遇到问题:Failed to get schema version。
此时需要查看下配置是否出错,在确认无误下。可能是JDBC版本与mysql版本不匹配了。可查看此文章:https://editor.csdn.net/md/?articleId=136310292。
hive --service metastore &
hiveserver2 &
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。