Skip to content

Commit

Permalink
Fix balance data (#2105)
Browse files Browse the repository at this point in the history
* fix balance data

* Update 4.job-statements.md
  • Loading branch information
cooper-lzy authored May 29, 2023
1 parent 131d088 commit fd66c58
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
site/
*.DS_Store

*.diff
2 changes: 1 addition & 1 deletion docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
## Operation and maintenance statements
* [BALANCE](../synchronization-and-migration/2.balance-syntax.md)
* [SUBMIT JOB BALANCE](../synchronization-and-migration/2.balance-syntax.md)
|Syntax|Description|
|-|-|
Expand Down
19 changes: 19 additions & 0 deletions docs-2.0/3.ngql-guide/4.job-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ nebula> SUBMIT JOB BALANCE DATA;
+------------+
```

## SUBMIT JOB BALANCE DATA REMOVE

!!! enterpriseonly

Only available for the NebulaGraph Enterprise Edition.

Starts a job to balance the distribution of storage partitions in the current graph space. The default port is `9779`. It returns the job ID.

For example:

```ngql
nebula> SUBMIT JOB BALANCE DATA REMOVE 192.168.8.100:9779;
+------------+
| New Job Id |
+------------+
| 29 |
+------------+
```

{{ ent.ent_end }}

<!-- balance-3.1
Expand Down
2 changes: 1 addition & 1 deletion docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CREATE SPACE [IF NOT EXISTS] <graph_space_name> (

!!! caution

- If the replica number is set to one, you will not be able to load balance or scale out the NebulaGraph Storage Service with the [BALANCE](../../8.service-tuning/load-balance.md) statement.
- If the replica number is set to one, you will not be able to load balance or scale out the NebulaGraph Storage Service with the [SUBMIT JOB BALANCE](../../8.service-tuning/load-balance.md) statement.

- Restrictions on VID type change and VID length:

Expand Down
24 changes: 12 additions & 12 deletions docs-2.0/8.service-tuning/load-balance.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Storage load balance

You can use the `BALANCE` statement to balance the distribution of partitions and Raft leaders, or clear some Storage servers for easy maintenance. For details, see [BALANCE](../synchronization-and-migration/2.balance-syntax.md).
You can use the `SUBMIT JOB BALANCE` statement to balance the distribution of partitions and Raft leaders, or clear some Storage servers for easy maintenance. For details, see [SUBMIT JOB BALANCE](../synchronization-and-migration/2.balance-syntax.md).

!!! danger

Expand All @@ -15,9 +15,9 @@ You can use the `BALANCE` statement to balance the distribution of partitions an

!!! note

If the current graph space already has a `BALANCE DATA` job in the `FAILED` status, you can restore the `FAILED` job, but cannot start a new `BALANCE DATA` job. If the job continues to fail, manually stop it, and then you can start a new one.
If the current graph space already has a `SUBMIT JOB BALANCE DATA` job in the `FAILED` status, you can restore the `FAILED` job, but cannot start a new `SUBMIT JOB BALANCE DATA` job. If the job continues to fail, manually stop it, and then you can start a new one.

The `BALANCE DATA` commands starts a job to balance the distribution of storage partitions in the current graph space by creating and executing a set of subtasks.
The `SUBMIT JOB BALANCE DATA` commands starts a job to balance the distribution of storage partitions in the current graph space by creating and executing a set of subtasks.

### Examples

Expand All @@ -35,19 +35,19 @@ After you add new storage hosts into the cluster, no partition is deployed on th
+-----------------+------+----------+--------------+-----------------------+------------------------+----------------------+
```
2. Enter the graph space `basketballplayer`, and execute the command `BALANCE DATA` to balance the distribution of storage partitions.
2. Enter the graph space `basketballplayer`, and execute the command `SUBMIT JOB BALANCE DATA` to balance the distribution of storage partitions.
```ngql
nebula> USE basketballplayer;
nebula> BALANCE DATA;
nebula> SUBMIT JOB BALANCE DATA;
+------------+
| New Job Id |
+------------+
| 25 |
+------------+
```
3. The job ID is returned after running `BALANCE DATA`. Run `SHOW JOB <job_id>` to check the status of the job.
3. The job ID is returned after running `SUBMIT JOB BALANCE DATA`. Run `SHOW JOB <job_id>` to check the status of the job.
```ngql
nebula> SHOW JOB 25;
Expand All @@ -63,7 +63,7 @@ After you add new storage hosts into the cluster, no partition is deployed on th
!!! Note
`BALANCE DATA` does not balance the leader distribution. For more information, see [Balance leader distribution](#balance_leader_distribution).
`SUBMIT JOB BALANCE DATA` does not balance the leader distribution. For more information, see [Balance leader distribution](#balance_leader_distribution).
```ngql
nebula> SHOW HOSTS;
Expand Down Expand Up @@ -97,16 +97,16 @@ To restore a balance job in the `FAILED` or `STOPPED` status, run `RECOVER JOB <

!!! note

For a `STOPPED` `BALANCE DATA` job, NebulaGraph detects whether the same type of `FAILED` jobs or `FINISHED` jobs have been created since the start time of the job. If so, the `STOPPED` job cannot be restored. For example, if chronologically there are STOPPED job1, FINISHED job2, and STOPPED Job3, only job3 can be restored, and job1 cannot.
For a `STOPPED` `SUBMIT JOB BALANCE DATA` job, NebulaGraph detects whether the same type of `FAILED` jobs or `FINISHED` jobs have been created since the start time of the job. If so, the `STOPPED` job cannot be restored. For example, if chronologically there are STOPPED job1, FINISHED job2, and STOPPED Job3, only job3 can be restored, and job1 cannot.

### Migrate partition

To migrate specified partitions and scale in the cluster, you can run `BALANCE DATA REMOVE <ip:port> [,<ip>:<port> ...]`.
To migrate specified partitions and scale in the cluster, you can run `SUBMIT JOB BALANCE DATA REMOVE <ip:port> [,<ip>:<port> ...]`.

For example, to migrate the partitions in server `192.168.8.100:9779`, the command as following:

```ngql
nebula> BALANCE DATA REMOVE 192.168.8.100:9779;
nebula> SUBMIT JOB BALANCE DATA REMOVE 192.168.8.100:9779;
nebula> SHOW HOSTS;
+-----------------+------+----------+--------------+-----------------------+------------------------+----------------------+
| Host | Port | Status | Leader count | Leader distribution | Partition distribution | Version |
Expand Down Expand Up @@ -248,12 +248,12 @@ To remove the following storage servers.
-->
## Balance leader distribution

To balance the raft leaders, run `BALANCE LEADER`.
To balance the raft leaders, run `SUBMIT JOB BALANCE LEADER`.

### Example

```ngql
nebula> BALANCE LEADER;
nebula> SUBMIT JOB BALANCE LEADER;
```

Run `SHOW HOSTS` to check the balance result.
Expand Down
21 changes: 14 additions & 7 deletions docs-2.0/synchronization-and-migration/2.balance-syntax.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# BALANCE syntax

The `BALANCE` statements support the load balancing operations of the NebulaGraph Storage services. For more information about storage load balancing and examples for using the `BALANCE` statements, see [Storage load balance](../8.service-tuning/load-balance.md).
We can submit tasks to load balance Storage services in NebulaGraph. For more information about storage load balancing and examples, see [Storage load balance](../8.service-tuning/load-balance.md).

The `BALANCE` statements are listed as follows.
The syntax for load balance is described as follows.

{{ comm.comm_begin }}

|Syntax|Description|
|:---|:---|
|`BALANCE LEADER`| Starts a job to balance the distribution of all the storage leaders in graph spaces. It returns the job ID. |

{{ comm.comm_end }}

{{ ent.ent_begin }}

|Syntax|Description|
|:---|:---|
|`BALANCE LEADER`| Starts a job to balance the distribution of all the storage leaders in graph spaces. It returns the job ID. |
<!-- balance-3.1
|`BALANCE DATA`| Starts a job to balance the distribution of storage partitions in the current graph space. It returns the job ID. |
|`BALANCE DATA REMOVE <ip:port> [,<ip>:<port> ...]`| Migrate the partitions in the specified storage host to other storage hosts in the current graph space. |
|`BALANCE IN ZONE [REMOVE <ip>:<port> [,<ip>:<port> ...]]`| Starts a job to balance the distribution of storage partitions in each zone in the current graph space. It returns the job ID. You can use the `REMOVE` option to specify the Storage services that you want to clear. The partitions of these services will be moved to other services for easy maintenance.|
|`BALANCE ACROSS ZONE [REMOVE "zone_name" [,"zone_name" ...]]`| Starts a job to balance the distribution of storage partitions across each zone in the current graph space. It returns the job ID. You can use the `REMOVE` option to specify the zones that you want to clear. The partitions of these services will be moved to other services for easy maintenance.|

!!! note

`REMOVE` can only clear the partitions of the current graph space. If a Storage service has a large number of graph spaces, you need to switch to all different graph spaces to perform the `REMOVE` operation.
-->

{{ ent.ent_end }}

For details about how to view, stop, and restart a job, see [Job manager and the JOB statements](../3.ngql-guide/4.job-statements.md).

0 comments on commit fd66c58

Please sign in to comment.