Today, I started spark. I always reported an error when connecting hive. The error is as follows
21/12/12 19:55:26 ERROR Hive: Cannot initialize metastore due to autoCreate error javax.jdo.JDODataStoreException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables" Exception in thread "main" org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for mysql));
Looking at the yellow font in the back, I first initialized the metadata. I wrote it in my last blog. Later, I found that it was not the metadata problem, but the need to open {datanucleus schema.autoCreateTables
<property> <name>datanucleus.schema.autoCreateAll</name> <value>true</value> </property>
Complete hive site xm:
<configuration> <!-- Location of metadata generated by Hive--> <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> </property> <!--- Use local service to connect to Hive, default is true--> <property> <name>hive.metastore.local</name> <value>true</value> </property> <!-- URL address of the database connection JDBC--> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false&serverTimezone=UTC</value> </property> <!-- Database connection driver, i.e. MySQL driver--> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <!-- MySQL database user name--> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>root</value> </property> <!-- MySQL Database Password--> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> </property> <property> <name>hive.metastore.schema.verification</name> <value>false</value> </property> <property> <name>datanucleus.schema.autoCreateAll</name> <value>true</value> </property> </configuration>