Using MariaDB
    • PDF

    Using MariaDB

    • PDF

    Article Summary

    Available in Classic and VPC

    About MariaDB Installer

    This page describes the concept and basic structure of NAVER CLOUD MariaDB Installer.
    "MariaDB" uses an open source relational database (RDBMS) called MariaDB, which is based on the same source code as MySQL.

    MariaDB

    MariaDB is a relational database that is widely used in the world created by MySQL developers. MariaDB provides a storage engine, plug-in, and many other tools. It has a fast and expandable structure so as to be used for various purposes.

    NAVER Cloud Platform MariaDB Installer configuration

    Installer service

    MariaDB Installer supported by NAVER Cloud Platform provides an environment file that offers a smooth operation standard for DB installation. In this regard, we do not provide additional technical support other than DB installation.

    RPM/APT

    For MariaDB installation, there are Source Compile / RPM,APT installation / Binary method. NAVER Cloud Platform provides RPM (APT) installation image, which is Normal Install method. The .repo file used by RPM(APT) installs MariaDB using the files officially provided by MariaDB, and it is included in the server image based on the latest version provided by Repo.

    RPM Install

    This is the package installed by RPM for CentOS 7.x with MariaDB.

    APT Install

    This is the package installed by APT for Ubuntu 16.X with MariaDB.

    Recommanded Parameters

    Recommended Parameter standardized in MariaDB installer image within NAVER Cloud Platform consists of the following:

    • innodb_file_per_table
    • innodb_log_file_size = 512M
    • innodb_log_files_in_group = 2
    • default_storage_engine=InnoDB
    • query_cache_type = ON
    • query_cache_size = 0M
    • sysdate-is-now

    innodb_file_per_table

    When used as a tablespace, the physical size will not be reduced when the table is dropped. Therefore, when deleting a table, the option is used to secure the physical size.

    innodb_log_file_size / innodb_log_files_in_group

    Increase the innodb_log_file_size option to prevent a bottleneck phenomenon for CheckPoint under heavy traffic.

    DB Restart is required to adjust these variables.

    default_storage_engine

    Specify a standard with InnoDB that can use Online-DDL and Transaction.

    query_cache_type / query_cache_size

    Set ON / 0 to allow a user to dynamically turn ON/OFF query_cache after DB activation. Then adjust it to suit your service situation.

    sysdate-is-now

    In case of using sysdate, the time type data may vary if the data processing time between Master and Slave is different in Replication configuration. Therefore, for sysdate, it will automatically replace the now.

    MariaDB Installer management

    This section describes the management methods related to MariaDB Installer.

    Create MariaDB image server

    If you create an instance server with MariaDB installed, MariaDB Daemon with my.cnf environment standardized in NAVER Cloud Platform will be created and started up, and will be provided after Daemon activation is completed.

    my.cnf

    Parameter description of my.cnf is as follows:

    PropertyDescription
    expire_logs_days = 7To prevent a log size set by a log-bin from increasing, save it for 7 days.
    innodb_file_per_tableWhen used as a tablespace, the physical size will not be reduced when the table is dropped. Therefore, when deleting a table, the option is used to secure the physical size.
    innodb_log_file_sizeIncrease the innodb_log_file_size option to prevent a bottleneck phenomenon for CheckPoint under heavy traffic.
    DB Restart is required to adjust the variables.
    innodb_log_files_in_groupSpecify the number of innodb_log_files. Two or more are recommended for Rotation.
    default_storage_engineSpecify a standard with InnoDB that can use Online-DDL and Transaction.
    query_cache_type

    query_cache_size
    Set ON / 0 to allow a user to dynamically turn ON/OFF query_cache after DB activation. Then adjust it to suit your service situation.
    sysdate-is-nowIn case of using sysdate, the time type data may vary if the data processing time between Master and Slave is different in Replication configuration. Therefore, for sysdate, it will automatically replace the now.

    The directory where MariaDB is installed is as follows.

    PropertyDescription
    DATADIR/var/lib/mysql/
    SLOW_LOG/var/lib/mysql/*slow.log
    my.cnf/etc/my.cnf - CentOS
    /etc/mysql/my.cnf - Ubuntu.
    • An error log for MariaDB is provided as the default, empty. If you need to configure it, you can add the following in my.cnf and restart your MariaDB daemon.
      log_error=mysqld.err

    Server creation procedure

    The process of creating MariaDB server is as follows.

    Connect to www.ncloud.com and log in

    database-7-1-101_en

    ① Click Console at the top right to connect to the nCloud Console.

    database-7-1-102_en

    ② On the nCloud Console screen, click [Create server].

    Create server

    Step 1. Select server image

    database-7-1-103_en

    ① Select the MariaDB version that corresponds to your OS version and click [Next] at the bottom.

    Step 2. Set server

    database-7-1-104_en

    ① Select a server type and the desired pricing plan.

    Step 3. Set authentication key

    database-7-1-105_en

    ① Select Use an existing authentication key.

    Step 4. Set firewall

    database-7-1-106_en

    ① Select Select an existing ACG or create a new one.

    Step 5. Confirm

    database-7-1-107_en

    ① Confirm your settings and create a server with MariaDB installed.

    Set server connection and confirm

    Set port forwarding

    database-7-1-108_en

    ① After the server creation, click [Set port forwarding] at the top.

    database-7-1-109_en

    ① Register an external port for SSH connection in the Set port forwarding screen.

    ② Register the external port and click [Add].

    database-7-1-110_en

    ③ Click [Apply].

    Get admin password

    database-7-1-111_en

    ① After setting the port forwarding, click [Manage servers] at the top.

    ② Click Get admin password.

    database-7-1-112_en

    ③ In the Get admin password window, attach your authentication key file.

    ④ Click [Get admin password].

    database-7-1-113_en

    ⑤ Remember the password on the next screen.

    Connect to server using terminal

    Use a terminal program to access as follows.

    • PORT: Port number set by a port forwarding
    • Public IP: Public IP for server connection displayed on the port forwarding screen
    • Password: Password shown as the administrator's password. Note that the initial password must be changed.
    ssh -p [PORT] root@[Public IP]
    

    After creating a server image

    1. If you do not immediately use the server image after creation, ShutDown MariaDB Daemon is recommended in order to prevent security threats.

    2. You must set a password because PostgreSQL does not provide an initial password.

    Run or stop MariaDB

    • To run or stop MariaDB Daemon, use the following commands.

      • CentOS
      shell> /sbin/service mysqld start
      shell> /sbin/service mysqld stop
      
      • Ubuntu
      Shell> /usr/sbin/service mysql start
      Shell> /usr/sbin/service mysql stop
      
    • To check whether MariaDB Daemon is running, use the following command.

    Shell> ps -ef | grep mysqld
    
    • Result ) MySQLd / mysqld process has to be shown.

    • MySQL created by NAVER Cloud Platform is accessible by the following command.

    Shell> mysql -uroot
    
    • An initial password is not provided according to the MariaDB password policy.

    • You must change your password at your first login in order to prevent security threats.

    • Use the following command to change the root password.

    mysql> set password=password('password');
    
    • The recommended basic policy for passwords is as follows.
    • At least 8 characters
    • At least 1 special character
    • At least 1 number
    • At least 1 case combination

    Terminate MariaDB image server

    We recommend following steps below when terminating a server where MariaDB is created on NAVER Cloud Platform.

    1. Back up the data stored in MariaDB.
    • For backed up data, keep it a separate repository after downloads.
    1. Stop MariaDB Daemon.

    2. Delete the data directory where MariaDB is stored.

    • e.g.) rm ‐rf /var/lib/mysql
    1. Click Stop > Terminate in the NAVER Cloud Platform Console.

    Enable external access

    If you use MariaDB on Ubuntu, you can only connect from localhost due to Default Parameter.

    In order to enable an external access, we will guide you through the following example.

    1. Connect to MariaDB DB.

    2. Grant an account permission.
      e.g.) GRANT ALL PRIVILEGES ON *.* to 'Account name'@'%' IDENTIFIED BY 'Password';

    3. Edit the environment file.
      e.g.) sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

    4. Comment out bind-address.
      database-1-115_en

    5. Restart MariaDB.


    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.