The management of Doris nodes requires connecting to the live FE nodes via the MySQL protocol using a username and password for operations. Doris implements a permission management mechanism similar to RBAC, and the management of nodes requires the user to have the Node_priv permission. By default, Doris Operator deploys and manages the cluster configured with DorisCluster resources using the root user with all permissions in passwordless mode. After adding a password to the root user, it is necessary to explicitly configure the username and password with Node_Priv permission in the DorisCluster resource, so that Doris Operator can perform automated management operations on the cluster.
DorisCluster resources provide two ways to configure the username and password required for managing cluster nodes, including:
Doris supports configuring the root user‘s password in encrypted form in fe.conf. To configure the root user’s password during the first deployment of Doris, follow these steps so that Doris Operator can automatically manage the cluster nodes:
1. Generate the Root Encrypted Password
Doris supports setting the root user's password in the fe.conf in encrypted form. The password encryption is implemented using two-stage SHA-1 encryption. The code implementation is as follows:
Java Code for Two-Stage SHA-2 Encryption:
import org.apache.commons.codec.digest.DigestUtils; public static void main( String[] args ) { //the original password String a = "123456"; String b = DigestUtils.sha1Hex(DigestUtils.sha1(a.getBytes())).toUpperCase(); //output the 2 stage encrypted password. System.out.println("*"+b); }
Golang Code for Two-Stage SHA-1 Encryption:
import ( "crypto/sha1" "encoding/hex" "fmt" "strings" ) func main() { //original password plan := "123456" //the first stage encryption. h := sha1.New() h.Write([]byte(plan)) eb := h.Sum(nil) //the two stage encryption. h.Reset() h.Write(eb) teb := h.Sum(nil) dst := hex.EncodeToString(teb) tes := strings.ToUpper(fmt.Sprintf("%s", dst)) //output the 2 stage encrypted password. fmt.Println("*"+tes) }
Configure the encrypted password into fe.conf according to the requirements of the configuration file format. Then, distribute the configuration file to the k8s cluster in the form of a configmap according to the introduction in the Cluster Parameter Configuration Section.
2. Configure the DorisCluster Resource
After setting the root initialization password in the configuration file, the root password will take effect immediately after the first Doris FE node starts. When other nodes join the cluster, Doris Operator needs to operate using the root username + password. It is necessary to specify the username + password in the deployed DorisCluster resource so that Doris Operator can automatically manage the cluster nodes.
spec: adminUser: name: root password: ${password}Here, ${password} is the unencrypted password of root.
stringData: username: root password: ${password}Here, ${password} is the unencrypted password set for root. b. Configure the DorisCluster Resource to be Deployed
spec: authSecret: ${secretName}Here, ${secretName} is the name of the Secret containing the root username and password.
During the first deployment, do not set the initialization password of root. Instead, set the non-root user and login password through the environment variable or using Secret. The auxiliary services of the Doris container will automatically create the configured user in the database, set the password, and grant the Node_priv permission. Doris Operator will manage the cluster nodes using the automatically created username and password.
spec: adminUser: name: ${DB_ADMIN_USER} password: ${DB_ADMIN_PASSWD}Here, ${DB_ADMIN_USER} is the newly created username, and ${DB_ADMIN_PASSWD} is the password set for the newly created username.
stringData: username: ${DB_ADMIN_USER} password: ${DB_ADMIN_PASSWD}Here, ${DB_ADMIN_USER} is the newly created username, and ${DB_ADMIN_PASSWD} is the password set for the newly created username.
kubectl -n ${namespace} apply -f ${secretFileName}.yaml. Here, ${namespace} is the namespace where the DorisCluster resource needs to be deployed, and ${secretFileName} is the file name of the Secret to be deployed.spec: authSecret: ${secretName}Here, ${secretName} is the name of the deployed Basic authentication Secret.
:::tip Tip
After deployment, please set the root password. Doris Operator will switch to using the automatically newly created username and password to manage the nodes. Please avoid deleting the automatically created user.
:::
After the Doris cluster is deployed and the root user's password is set, it is necessary to configure a user with Node_priv permission into the DorisCluster resource so that Doris Operator can automatically manage the cluster nodes. It is not recommended to use root as this username. Please refer to the User Creation and Permission Assignment Section to create a new user and grant Node_priv permission. After creating the user, specify the new management user and password through the environment variable or Secret method, and configure the corresponding DorisCluster resource.
1. Create a User with Node_priv Permission
After connecting to the database using the MySQL protocol, use the following command to create a simple user with only Node_priv permission and set the password.
CREATE USER '${DB_ADMIN_USER}' IDENTIFIED BY '${DB_ADMIN_PASSWD}';
Here, ${DB_ADMIN_USER} is the username you hope to create, and ${DB_ADMIN_PASSWD} is the password you hope to set for the newly created user.
2. Grant Node_priv Permission to the Newly Created User
After connecting to the database using the MySQL protocol, use the following command to grant Node_priv permission to the newly created user.
GRANT NODE_PRIV ON *.*.* TO ${DB_ADMIN_USER};
Here, ${DB_ADMIN_USER} is the newly created username.
For detailed usage of creating users, setting passwords, and granting permissions, please refer to the official document CREATE-USER section.
3. Configure DorisCluster
spec: adminUser: name: ${DB_ADMIN_USER} password: ${DB_ADMIN_PASSWD}Here, ${DB_ADMIN_USER} is the newly created username, and ${DB_ADIC_PASSWD} is the password set for the newly created user.
stringData: username: ${DB_ADMIN_USER} password: ${DB_ADMIN_PASSWD}Here, ${DB_ADMIN_USER} is the newly created username, and ${DB_ADMIN_PASSWD} is the password set for the newly created username.
spec: authSecret: ${secretName}Here, ${secretName} is the name of the deployed Basic authentication Secret.
:::tip Tip
After setting the root password and configuring the new username and password for managing nodes after deployment, the existing services will be restarted once in a rolling manner.
:::