-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Indexer/TiDB][EASY] Add pre-requisites to README.
## Description Explain what needs to be installed to get the MySQL version of the Indexer working. ## Test plan Try the steps and make sure they work.
- Loading branch information
Showing
1 changed file
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,26 +59,56 @@ Run this command under `sui/crates/sui-indexer`, which will wipe DB; In case of | |
```sh | ||
diesel database reset --database-url="<DATABASE_URL>" | ||
``` | ||
### Local Development(TiDB) | ||
|
||
## Steps to run locally (TiDB) | ||
|
||
### Prerequisites | ||
|
||
1. Install TiDB | ||
|
||
``` sh | ||
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | ||
``` | ||
|
||
2. Install a compatible version of MySQL (At the time of writing, this is MySQL 8.0 -- note that 8.3 is incompatible). | ||
|
||
``` sh | ||
brew install [email protected] | ||
``` | ||
|
||
3. Install a version of `diesel_cli` that supports MySQL (and probably also Postgres). This version of the CLI needs to be built against the version of MySQL that was installed in the previous step (compatible with the local installation of TiDB, 8.0.37 at time of writing). | ||
|
||
``` sh | ||
MYSQLCLIENT_LIB_DIR=/opt/homebrew/Cellar/[email protected]/8.0.37/lib/ cargo install diesel_cli --no-default-features --features postgres --features mysql --force | ||
``` | ||
|
||
### Run the indexer | ||
|
||
1.Run TiDB | ||
|
||
```sh | ||
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | ||
tiup playground | ||
``` | ||
|
||
2.Verify tidb is running by connecting to it using the mysql client, create database `test` | ||
|
||
```sh | ||
mysql --comments --host 127.0.0.1 --port 4000 -u root | ||
create database test; | ||
``` | ||
``` | ||
|
||
3.DB setup, under `sui/crates/sui-indexer` run: | ||
|
||
```sh | ||
# an example DATABASE_URL is "mysql://root:[email protected]:4000/test" | ||
diesel setup --database-url="<DATABASE_URL> --migration-dir='migrations/mysql'" | ||
diesel database reset --database-url="<DATABASE_URL> --migration-dir='migrations/mysql'" | ||
``` | ||
|
||
Note that you'll need an existing database for the above to work. Replace `test` with the name of the database created. | ||
4. run indexer as a writer, which pulls data from fullnode and writes data to DB | ||
|
||
```sh | ||
# Change the RPC_CLIENT_URL to http://0.0.0.0:9000 to run indexer against local validator & fullnode | ||
cargo run --bin sui-indexer --features mysql-feature --no-default-features -- --db-url "<DATABASE_URL>" --rpc-client-url "https://fullnode.devnet.sui.io:443" --fullnode-sync-worker --reset-db | ||
``` | ||
``` |