This topic describes how to create a regular user and grant the sudo privilege to the user.
If you are an individual user, you can deploy the cluster as the root user and skip this step. If you are an enterprise user, we recommend that you create regular users on the servers to ensure security. You can create your frequently used accounts as needed.
Note
You must perform this operation on each server.
Follow these steps to create a user. The following example creates an admin user.
Run the following commands to create an admin user:
[root@test001 ~]# useradd -U admin -d /home/admin -s /bin/bash [root@test001 ~]# chown -R admin:admin /home/adminRun the following command to set a password for the admin user:
[root@test001 ~]# passwd admin(Optional) Grant the sudo privilege to the admin user.
Run the following command to open the
/etc/sudoersfile:[root@test001 ~]# vim /etc/sudoersAdd the following content at the end of the
/etc/sudoersfile:## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL admin ALL=(ALL) NOPASSWD: ALLRun the following command to check the directory permissions of the cluster-related files.
Taking the
datadirectory as an example:[root@test001 data]# ls -alThe result will be:
drwxr-xr-x 2 admin admin 4096 02/09 18:43 . drwxr-xr-x 2 admin admin 4096 02/09 18:43 log1If the
adminuser does not have the necessary privilege for the related files, run the following commands to change the file ownership:[root@test001 ~]# chown -R admin:admin /data [root@test001 ~]# chown -R admin:admin /redoHere,
/dataand/redoare example mount directories. You need to replace them with your actual mount directories.