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 ~]# mkdir -p /home/admin [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.
Open the
/etc/sudoersfile and add the following content to/etc/sudoers:[root@test001 ~]# vim /etc/sudoers # Add the following content: ## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL admin ALL=(ALL) NOPASSWD: ALLChange the users to which the cluster files belong:
[root@test001 ~]# chown -R admin:admin /data [root@test001 ~]# chown -R admin:admin /redo [root@test001 ~]# chown -R admin:admin /home/adminHere,
/data,/redo, and/home/adminare sample mount directories. Replace them with actual ones.Run the following command to view the directory permission:
[root@test001 data]# ls -alFor example, the following output is returned:
drwxr-xr-x 2 admin admin 4096 Feb. 9 18:43 . drwxr-xr-x 2 admin admin 4096 Feb. 9 18:43 log1