This topic describes how to create a user and grant the sudo permission to the user.
If you are an individual user, you can deploy OceanBase Database as the root user and skip this topic. If you are an enterprise user, we recommend that you create non-root users for the servers to ensure data security. You can create frequently used users as needed.
Note
You must perform this operation on each server.
To create a user and grant the sudo permission to the user, follow these steps:
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) Set the sudo permission for the admin user.
Run the following command to open the
/etc/sudoersfile:[root@test001 ~]# vim /etc/sudoersAdd the following line 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 you find that the
adminuser does not have the necessary permissions for the files, you can change the file ownership with the commands below:[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.