Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tidb as metastore #544

Merged
merged 7 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions config/hive-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:4000/metastore_db?createDatabaseIfNotExist=true&amp;useSSL=false&amp;autoReconnect=true</value>
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
<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>mine</value>
</property>
</configuration>
27 changes: 27 additions & 0 deletions docs/how_to_use_tidb_as_metastore_db.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Setting TiDB as metastore db

Generally sparking, you need setup tidb first and then copy `hive-site.xml` into Spark's `conf`
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
directory.

## Setup TiDB

First you need have a TiDB cluster present, and then use a mysql client log into TiDB cluster.
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
birdstorm marked this conversation as resolved.
Show resolved Hide resolved

You will need execute the following command:

```$xslt
CREATE USER 'hive'@'%' IDENTIFIED BY 'mine';
zhexuany marked this conversation as resolved.
Show resolved Hide resolved
GRANT ALL PRIVILEGES ON metastore.* TO 'hive'@'%';
zhexuany marked this conversation as resolved.
Show resolved Hide resolved
FLUSH PRIVILEGES;
```

It helps you create a user and grant access privileges to all databases and tables.

## Adding hive-site.xml configuration to Spark

Then you can find a sample conf file at config directory at [tispark](https://github.com/pingcap/tispark)
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
project. What you need to do is copy and paste such file into `SPARK_HOME/conf`. One last thing to mention
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
is that you need to adjust some properties if you change the user name or user password at
birdstorm marked this conversation as resolved.
Show resolved Hide resolved
setting up tidb step.

After you finish these two steps, you are able to use tidb to store meta info of Spark.