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

Change reuse doc #638

Merged
merged 3 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
213 changes: 0 additions & 213 deletions docs-2.0/2.quick-start/3.connect-to-nebula-graph.md
Original file line number Diff line number Diff line change
@@ -1,217 +1,4 @@
# Step 3:Connect to Nebula Graph

<<<<<<< Updated upstream
Nebula Graph supports multiple types of clients, including a CLI client, a GUI client, and clients developed in popular programming languages. This topic provides an overview of Nebula Graph clients and basic instructions on how to use the native CLI client, Nebula Console.

## Nebula Graph clients

You can use supported [clients or console](../20.appendix/6.eco-tool-version.md) to connect to Nebula Graph database.

<!-- TODO cloud service cannot be provided together with v{{ nebula.release }}.
If you do not have a Nebula Graph database yet, we recommend that you try the cloud service. [Nebula Graph Cloud Service](https://www.nebula-cloud.io/) supports on-demand deployment and fast building, and uses Nebula Graph Studio as its default client.
-->

## Use Nebula Console to connect to Nebula Graph

### Prerequisites

* Nebula Graph services are started. For how to start services, see [Start and Stop Nebula Graph](./5.start-stop-service.md).

* The machines that run Nebula Console and Nebula Graph services have network access to each other.

### Steps

1. On the [nebula-console](https://github.com/vesoft-inc/nebula-console/releases "the nebula-console Releases page") page, select a Nebula Console version and click **Assets**.

!!! Note

We recommend that you select the **latest** release.

![Select a Nebula Graph version and click **Assets**](../2.quick-start/console.png "Click Assets to show the available Nebula Graph binary files")

2. In the **Assets** area, find the correct binary file for the machine where you want to run Nebula Console and download the file to the machine.

![Click to download the package according to your hardware architecture](../2.quick-start/assets.png "Click the package name to download it")

3. (Optional) Rename the binary file to `nebula-console` for convenience.

!!! Note

For Windows, rename the file to `nebula-console.exe`.

4. On the machine that runs Nebula Console, run the following command to grant the execution privileges of the nebula-console binary file to the user.

!!! Note

For Windows, skip this step.

```bash
$ chmod 111 nebula-console
```

5. In the command line interface, change the working directory to the one where the nebula-console binary file is stored.

6. Run the following command to connect to Nebula Graph.

* For Linux or macOS:

```bash
$ ./nebula-console -addr <ip> -port <port> -u <username> -p <password>
[-t 120] [-e "nGQL_statement" | -f filename.nGQL]
```

* For Windows:

```powershell
> nebula-console.exe -addr <ip> -port <port> -u <username> -p <password>
[-t 120] [-e "nGQL_statement" | -f filename.nGQL]
```

The descriptions are as follows.

| Parameter | Description |
| - | - |
| `-h` | Shows the help menu. |
| `-addr` | Sets the IP address of the graphd service. The default address is 127.0.0.1. |
| `-port` | Sets the port number of the graphd service. The default port number is 9669.<!-- If you have deployed Nebula Graph in a docker container but Nebula Console is working outside the container, check the [source port](2.deploy-nebula-graph-with-docker-compose.md/#check_the_nebula_graph_service_status_and_port) of any nebula-graphd process and use it for connection. --> |
| `-u/-user` | Sets the username of your Nebula Graph account. Before enabling authentication, you can use any existing username (The default username is `root`). |
| `-p/-password` | Sets the password of your Nebula Graph account. Before enabling authentication, you can use any characters as the password. |
| `-t/-timeout` | Sets an integer-type timeout threshold of the connection. The unit is second. The default value is 120. |
| `-e/-eval` | Sets a string-type nGQL statement. The nGQL statement will be executed once the connection succeeds. The connection stops after the result is returned. |
| `-f/-file` | Sets the path of an nGQL file. The nGQL statements in the file are executed once the connection succeeds. The connection stops after the result is returned. |

Users can use the command of `./nebula-console --help` to get the details of all the parameters and can also find more details in the [Nebula Console Repository](https://github.com/vesoft-inc/nebula-console/tree/v2.0.0-ga).

## Nebula Console commands

Nebula Console supports some commands. Users can export all the query results into a CSV file or a DOT file, and import test datasets.

!!! Note

* The commands are case-insensitive.

### Export CSV files

!!! note

- The CSV file is stored in the working directory. Run the Linux command `pwd` to show the working directory.

- This command only takes effect on the next query statement.

The command is as follows.

```ngql
nebula> :CSV <file_name.csv>
```

### Export DOT files

!!! Note

- The DOT file is stored in the working directory. Run the Linux command `pwd` to show the working directory.

- The content of the DOT file can be copied and pasted in the [GraphvizOnline](https://dreampuf.github.io/GraphvizOnline/) to generate a visual execution plan diagram.

- This command only takes effect on the next query statement.

The command is as follows.

```ngql
nebula> :dot <file_name.dot>
```

The example is as follows.

```ngql
nebula> :dot a.dot
nebula> PROFILE FORMAT="dot" GO FROM "player100" OVER follow;
```

### Load test datasets

The name of the test dataset is nba. To check the detailed information on the Schema and data, run the relevant `SHOW` command.

The command is as follows.

```ngql
nebula> :play nba
```

### Repeat the execution

This command repeats the next command N times, and then prints the average execution time. The command is as follows.

```ngql
nebula> :repeat N
```

Examples are as follows.

```ngql
nebula> :repeat 3
nebula> GO FROM "player100" OVER follow;
+-------------+
| follow._dst |
+-------------+
| "player101" |
+-------------+
| "player125" |
+-------------+
Got 2 rows (time spent 2602/3214 us)

Fri, 20 Aug 2021 06:36:05 UTC

+-------------+
| follow._dst |
+-------------+
| "player101" |
+-------------+
| "player125" |
+-------------+
Got 2 rows (time spent 583/849 us)

Fri, 20 Aug 2021 06:36:05 UTC

+-------------+
| follow._dst |
+-------------+
| "player101" |
+-------------+
| "player125" |
+-------------+
Got 2 rows (time spent 496/671 us)

Fri, 20 Aug 2021 06:36:05 UTC

Executed 3 times, (total time spent 3681/4734 us), (average time spent 1227/1578 us)
```

### Sleep

The command sleeps for N seconds. It is often used to modify the Schema because the modification of the Schema is implemented asynchronously, and Nebula Graph synchronizes the data in the next heartbeat cycle. The command is as follows:

```ngql
nebula> :sleep N
```

## Disconnect Nebula Console from Nebula Graph

Users can use `:EXIT` or `:QUIT` to disconnect from Nebula Graph. For convenience, Nebula Console supports using these commands in lower case without the colon, such as `quit`.

The example is as follows.

```ngql
nebula> :QUIT

Bye root!
```

## FAQ

### How can I install Nebula Console from the source code?

To download and compile the latest source code of Nebula Console, follow the instructions on [GitHub Nebula Console](https://github.com/vesoft-inc/nebula-console#build-nebula-graph-console).
=======
{% include "/source_connect-to-nebula-graph.md" %}
<!-- The line above is for content reusing. The source file is in the docs-2.0/reuse directory. -->
>>>>>>> Stashed changes
Loading