简体   繁体   English

hive 元存储在火花上自动创建

[英]hive metastore autocreate on spark

i'm trying to create a hive metastore to be hosted in mysql from spark.我正在尝试创建一个 hive 元存储,以从 spark 托管在 mysql 中。 the hive-site.xml is as followings: hive-site.xml 如下:

>>> -- hive-site.xml --- >>>>>>>>>>>>>>>>>>
<configuration>
  <property>
     <name>javax.jdo.option.ConnectionURL</name>
     <value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true</value>
   </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>xxxxxx</value>
    <description>password to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.cj.jdbc.Driver</value>
  </property>
  <property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/var/lib/hive/hive-warehouse</value>
    <description>Hive Metastore location</description>
  </property>
  <property>
    <name>datanucleus.autoCreateSchema</name>
    <value>false</value>
  </property>
  <property>
    <name>datanucleus.fixedDatastore</name>
    <value>true</value>
  </property>
  <property>
    <name>datanucleus.autoStartMechanism</name>
    <value>SchemaTable</value>
  </property>
  <property>
    <name>hive.metastore.schema.verification</name>
    <value>true</value>
  </property>
  <property>
    <name>datanucleus.schema.autoCreateTables</name>
    <value>true</value>
  </property>
</configuration>
<<< --- hive-site.xml --- <<<<<<<<<<<<<<<<<

the error message when i started thrift service (start-thriftserver.sh) from spark (3.1.1)当我从 spark (3.1.1) 启动节俭服务 (start-thriftserver.sh) 时的错误消息

...
    21/12/16 18:03:58 INFO Persistence: Property datanucleus.cache.level2 unknown - will be ignored
21/12/16 18:03:59 INFO BlockManagerMasterEndpoint: Registering block manager 192.168.45.28:27131 with 366.3 MiB RAM, BlockManagerId(0, 192.168.45.28, 27131, None)
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:19 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:20 INFO ObjectStore: Setting MetaStore object pin classes with hive.metastore.cache.pinobjtypes="Table,StorageDescriptor,SerDeInfo,Partition,Database,Type,FieldSchema,Order"
21/12/16 18:04:33 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:33 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:33 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:33 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:33 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:40 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:40 WARN Datastore: SQL Warning : 'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
21/12/16 18:04:58 ERROR Datastore: Error thrown executing CREATE TABLE `TBLS`
(
    `TBL_ID` BIGINT NOT NULL,
    `CREATE_TIME` INTEGER NOT NULL,
    `DB_ID` BIGINT NULL,
    `LAST_ACCESS_TIME` INTEGER NOT NULL,
    `OWNER` VARCHAR(767) BINARY NULL,
    `RETENTION` INTEGER NOT NULL,
    `IS_REWRITE_ENABLED` BIT NOT NULL,
    `SD_ID` BIGINT NULL,
    `TBL_NAME` VARCHAR(256) BINARY NULL,
    `TBL_TYPE` VARCHAR(128) BINARY NULL,
    `VIEW_EXPANDED_TEXT` TEXT [CHARACTER SET charset_name] [COLLATE collation_name] NULL,
    `VIEW_ORIGINAL_TEXT` TEXT [CHARACTER SET charset_name] [COLLATE collation_name] NULL,
    CONSTRAINT `TBLS_PK` PRIMARY KEY (`TBL_ID`)
) ENGINE=INNODB : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[CHARACTER SET charset_name] [COLLATE collation_name] NULL,
    `VIEW_ORIGINAL_T' at line 13
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[CHARACTER SET charset_name] [COLLATE collation_name] NULL,
    `VIEW_ORIGINAL_T' at line 13
...

before posted i tried drop database of mysql (8.0.25) to re-create different character set/collation for the db but it doesnt work out:在发布之前,我尝试删除 mysql (8.0.25) 的数据库来为数据库重新创建不同的字符集/排序规则,但它没有成功:

  1. utf8mb4/utf8mb4_0900_ai_ci utf8mb4/utf8mb4_0900_ai_ci
  2. utf8mb4/utf8mb4_general_ci utf8mb4/utf8mb4_general_ci
  3. binary/binary二进制/二进制

i'm not sure its something happened on metastore schema autocreate or something i can make adjustment for mysql?我不确定它在 Metastore 模式自动创建上发生了什么,或者我可以对 mysql 进行调整吗?

Getting the Same issue for me while doing from Java code with Mysql 8 Version在使用 Mysql 8 版本的 Java 代码时遇到同样的问题

public class HiveMetaStore {
public static void main(String[] args) {
    String warehouseLocation = new File("spark-warehouse").getAbsolutePath();
    SparkSession spark = SparkSession
            .builder()
            .master("local[4]")
            .appName("HiveMetaStore")
            .config("spark.sql.warehouse.dir", warehouseLocation)
            .config("spark.hadoop.javax.jdo.option.ConnectionURL", "jdbc:mysql://localhost:3306/metastore_db")
            .config("spark.hadoop.javax.jdo.option.ConnectionDriverName", "com.mysql.cj.jdbc.Driver")
            .config("spark.hadoop.javax.jdo.option.ConnectionUserName", "root")
            .config("spark.hadoop.javax.jdo.option.ConnectionPassword", "root")
            .config("spark.sql.hive.metastore.version", "2.3.9")
            .config("datanucleus.schema.autoCreateAll", true)
            .enableHiveSupport()
            .getOrCreate();
    spark.catalog().listDatabases().show(false);      
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM