Hive安裝

qq_39682037發表於2020-09-24

hive安裝

由於centos7之後yum無法安裝mysql,這裡採用mariadb替代,mariadb與mysql採用一樣的操作方式

 [root@node1 ~]# yum -y install mariadb mariadb-server
[root@node1 app]# cd apache-hive-2.3.7-bin/
[root@node1 apache-hive-2.3.7-bin]# cd conf/
[root@node1 conf]# cp hive-default.xml.template hive-site.xml
[root@node1 conf]# vi hive-site.xml 

hive-site.xml

在hive-site.xml底部新增

    <property>
      <name>javax.jdo.option.ConnectionURL</name>
      <value>jdbc:mysql://node1:3306/hive?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>12345</value>
    </property>

在這裡插入圖片描述

將mysql的驅動jar包放在hive的lib目錄下
在這裡插入圖片描述
在初始化之前記得建立資料庫,我這裡設定的資料庫名字為hive

[root@node1 conf]# schematool -dbType mysql -initSchema

在這裡插入圖片描述
附執行成功效果圖
在這裡插入圖片描述

異常解決

執行異常

在這裡插入圖片描述

Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
	at org.apache.hadoop.fs.Path.initialize(Path.java:205)
	at org.apache.hadoop.fs.Path.<init>(Path.java:171)
	at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:663)
	at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:586)
	at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:553)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:750)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:686)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
	at java.net.URI.checkPath(URI.java:1823)
	at java.net.URI.<init>(URI.java:745)
	at org.apache.hadoop.fs.Path.initialize(Path.java:202)
	... 12 more

將hive-site.xml檔案中的${system:java.io.tmpdir}替換為hive的臨時目錄
例如我替換為/root/app/apache-hive-2.3.7-bin/tmp
在這裡插入圖片描述

mysql初始化異常

在資料庫中授權即可:
grant all privileges on . to root@’%’ identified by ‘12345’ with grant option;

在這裡插入圖片描述

相關文章