(Optional) Create a user

2023-11-17 03:02:19  Updated

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:

  1. 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/admin
    
  2. Run the following command to set a password for the admin user:

    [root@test001 ~]# passwd admin
    
  3. (Optional) Set the sudo permission for the admin user.

    Open the /etc/sudoers file 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: ALL
    
  4. Change 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/admin
    

    Here, /data, /redo, and /home/admin are sample mount directories. Replace them with actual ones.

    Run the following command to view the directory permission:

    [root@test001 data]# ls -al
    

    For 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

Contact Us