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

Add instructions to setup local MySQL and Postgres #3868

Merged
merged 10 commits into from
Jan 7, 2021
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For [manual setup or upgrading](docs/persistence.md) server schema --
* If server runs with SQL database, Use [Cadence SQL tool](tools/sql/README.md) to perform various tasks on database schema of SQL based persistence

TIPS: Run `make tools` to build all tools mentioned above.
> NOTE: See [CONTRIBUTING](CONTRIBUTING.md) for prerequisite of make command.
> NOTE: See [CONTRIBUTING](docs/readme/CONTRIBUTING.md) for prerequisite of make command.
### Use Cadence Web

Try out [Cadence Web UI](https://github.com/uber/cadence-web) to view your workflows on Cadence.
Expand All @@ -40,7 +40,7 @@ If you have a suggestion or change you would like to make to [cadenceworkflow.io

## Contributing

We'd love your help in making Cadence great. Please review our [contribution guide](CONTRIBUTING.md).
We'd love your help in making Cadence great. Please review our [contribution guide](docs/readme/CONTRIBUTING.md).

If you'd like to propose a new feature, first join the Cadence [discussion group](https://groups.google.com/d/forum/cadence-discussion) and [Slack channel](https://join.slack.com/t/uber-cadence/shared_invite/enQtNDczNTgxMjYxNDEzLTQyYjcxZDM2YTIxMTZkMzQ0NjgxYmI3OWY5ODhiOTliM2I5MzA4NTM4MjU4YzgzZDkwNGEzOTUzNTBlNDk3Yjc) to start a discussion and check if there are existing design discussions. Also peruse our [design docs](docs/design/index.md) in case a feature has been designed but not yet implemented. Once you're sure the proposal is not covered elsewhere, please follow our [proposal instructions](PROPOSALS.md).

Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md → docs/readme/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,24 @@ Connected to Test Cluster at 127.0.0.1:9042.
Use HELP for help.
cqlsh>
```
>If you are running Cadence on top of [Mysql](MYSQL_SETUP.md) or [Postgres](POSTGRES_SETUP.md), you can follow the instructions to run the SQL DB and then run:

Now you can setup the database schema
```bash
make install-schema

# If you use SQL DB, then run:
make install-schema-mysql OR make install-schema-postgres
```

Then you will be able to run a basic local Cadence server for development:
```bash
./cadence-server start

# If you use SQL DB, then run:
./cadence-server --zone <mysql/postgres> start
```

You can run some workflow [samples](https://github.com/uber-common/cadence-samples) to test the development server.

> This basic local server doesn't have some features like advanced visibility, archival, which require more dependency than Cassandra/Database and setup.
Expand Down
35 changes: 35 additions & 0 deletions docs/readme/MYSQL_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Setup local MySQL with Docker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why readme? this name doesn't give any useful information. Maybe setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the dir name

This document describes how to install MySQL 5.7 locally with Docker.

>Note: Install the docker on your machine before installing the MySQL.
* Make sure any MySQL containers are terminated and removed
```
docker ps -a
docker kill <container_id> && docker rm <container_id> # remove any MySQL containers.
```
* Fetch docker image (version 5.7 is what Travis runs so its what you will want locally)
```
docker pull mysql/mysql-server:5.7
```
* Run docker container (note the port mapping so that 3306 is exposed locally)
```
docker run -p 3306:3306 --name=mysql1 -d mysql/mysql-server:5.7
```
* When docker starts up the root MySQL user will have an auto generated password. You need to get that password to log into the container
```
docker logs mysql1 2>&1 | grep GENERATED
# The result looks like: [Entrypoint] GENERATED ROOT PASSWORD: iHqEvRYm6UP#YN$es;YnV3m(oJ
```
* Log into the container (when prompted for password use the password gotten from last step).
```
docker exec -it mysql1 mysql -uroot -p
```
* Before any SQL operations can be performed you must reset the root user's password (use anything you like in replace of root_password).
```
SET PASSWORD = PASSWORD('root_password');
```
* Now create the user that local MySQL tests will use. Also grant all privileges to user.
```
CREATE USER 'uber'@'%' IDENTIFIED BY 'uber';
GRANT ALL PRIVILEGES ON *.* TO 'uber'@'%';
```
22 changes: 22 additions & 0 deletions docs/readme/POSTGRES_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Setup local Postgres with Docker
This document describes how to install latest Postgre locally with Docker.

>Note: Install the docker on your machine before installing the MySQL.
* Make sure any MySQL containers are terminated and removed
```
docker ps -a
docker kill <container_id> && docker rm <container_id> # remove any Postgres containers.
```
* Fetch docker image
```
docker pull postgres
```
* Run docker container (note the port mapping so that 5432 is exposed locally)
```
mkdir -p ~/docker/volumes/postgres
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=cadence -d -p 5432:5432 -v ~/docker/volumes/postgres:/var/lib/postgresql/data postgres
```
* Log into the container (when prompted for password use the password gotten from last step).
```
psql -h localhost -U postgres -d cadence
```