今天花了一个上午配置hive,途中遇到太多的坑,最后总算配置成功了
第一个坑就是我的文件夹是没有hive-default.xml,但他给了hive-defualt的template所以要先输入下面命令cd /usr/local/Cellar/hive/2.1.9/libexec/conf;cp hive-dfault.xml.template hive-defalut.xml
,没有这个文件即使配置了hive-site.xml,我也无法运行metastore,然后是hive-site的配置,mysql需要自己创建一个metastore名字的schema。在创建一个用户叫hiveuser,密码是hivepassword,后面都是配置
configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore?createDatabaseIfNotExist=true</value>
<description>metadata is stored in a MySQL server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>MySQL JDBC driver class</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hiveuser</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hivepassword</value>
<description>password for connecting to mysql server</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/user/hive/tmp</value>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/user/hive/tmp</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/user/hive/log</value>
</property>
<!--<property>
<name>hive.metastore.uris</name>
<value>thrift://localhost:9083</value>
<description>Thrift URI for the remote metastore. Used by metastore client to con
nect to remote metastore.</description>
</property>-->
<property>
<name>hive.server2.webui.host</name>
<value>localhost</value>
</property>
<property>
<name>hive.server2.webui.port</name>
<value>10002</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>localhost</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://localhost:9083</value>
</property>
<property>
<name>hive.server2.enable.doAs</name>
<value>true</value>
</property>
</configuration>
这个配置好后,文件配置就成功了,接着又有一个坑,每次运行hive-cli或者启动hiveserver2,都需要先启动metastore这个服务,hive --service metastore
,然后才能开启其他两个服务,也就是开启了metastore才能hive --service hiveserver2