Skip to content

Commit

Permalink
[Doc] update change_root_password_howto.md (#295)
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored Nov 1, 2023
1 parent 95436e2 commit 9d7ef19
Showing 1 changed file with 112 additions and 21 deletions.
133 changes: 112 additions & 21 deletions doc/change_root_password_howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,36 @@ password chosen for the root.

**A StarRocks cluster is deployed and up with empty root password by the operator.**

## Steps to Change the Password For root User
## 1. Change the password for root user

1. connect to starRocks FE with mysql client, and change the root user password.
```SQL
mysql -h <FE_IP/FE_SERVICE> -P 9030 -u root
Connect to StarRocks FE with a MySQL client and change the root user password.

# change root password to `mysql_password`
MySQL [(none)]> SET PASSWORD = PASSWORD('mysql_password');
```
```SQL
mysql
-h <FE_IP/FE_SERVICE> -P 9030 -u root

2. create a secret **rootcredential** with the key **password** to store the root password
# change root password to `mysql_password`
MySQL [(none)]> SET PASSWORD = PASSWORD('mysql_password');
```

## 2. Inject MYSQL_PWD environment variable to StarRocks components

There are two ways to deploy StarRocks cluster:

1. Deploy StarRocks cluster with `StarRocksCluster` CR yaml.
2. Deploy StarRocks cluster with Helm chart.

Therefore, there are two ways to inject the MYSQL_PWD environment variable into StarRocks components.

### 2.1 inject MYSQL_PWD environment variable with StarRocksCluster CRD yaml

1. Create a secret **rootcredential** with the key **password** to store the root password

```shell
kubectl create secret generic rootcredential --from-literal=password=mysql_password
```

3. Update StarRocks crd yaml

Add the following snippets to `starRocksFeSpec/starRocksBeSpec/starRocksCnSpec` respectively if the corresponding
2. Add the following snippets to `starRocksFeSpec/starRocksBeSpec/starRocksCnSpec` respectively if the corresponding
components are deployed.

```yaml
Expand Down Expand Up @@ -58,18 +69,98 @@ password chosen for the root.
key: password
```
4. Apply the crd yaml
3. Apply the crd yaml
```shell
kubectl apply -f <crd_yaml>
```

It will trigger a rolling restart of the cluster, wait until the cluster restart completed.

5. Verify the password is all set

After the pods are restarted, run the following command to check the correctness of the password.

``` shell
kubectl exec <podName> -- sh -c 'echo $MYSQL_PWD'
```
It will trigger a rolling restart of the cluster, wait until the cluster restart completed.

### 2.2 Inject MYSQL_PWD environment variable with helm chart

If you are using the `kube-starrocks` Helm chart, add the following snippets to `values.yaml`.

```yaml

starrocks:
# create secrets if necessary.
secrets:
- name: rootcredential
data:
password: mysql_password

starrocksFESpec:
feEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password

starrocksBeSpec:
beEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password

starrocksCnSpec:
cnEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password
```
If you are using the `starrocks` Helm chart, add the following snippets to `values.yaml`.

```yaml
# create secrets if necessary.
secrets:
- name: rootcredential
data:
password: mysql_password
starrocksFESpec:
feEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password
starrocksBeSpec:
beEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password
starrocksCnSpec:
cnEnvVars:
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: rootcredential
key: password
```

Run the following command to upgrade the cluster.

```shell
helm upgrade <release_name> <chart_path> -f values.yaml
```

It will trigger a rolling restart of the cluster, wait until the cluster restart completed.

## 3. Verify the password is all set

After the pods are restarted, run the following command to check the correctness of the password.

``` shell
kubectl exec <podName> -- sh -c 'echo $MYSQL_PWD'
```

0 comments on commit 9d7ef19

Please sign in to comment.