Cara membuat database server mariadb pada CentOS 7
Server database adalah sebuah server yang dapat menyimpan sebuah basis data yang diperlukan untuk kebutuhan tertentu seperti untuk program, untuk data-data disebuah organisasi/sekolah dan perusahaan. Kita dapat membuat sebuah server database kita sendiri, pada sistem operasi CentOS 7, untuk membuat server database, pada server tersebut kita memerlukan aplikasi yang dapat menyediakan layanan database.
Aplikasi penyedia database yang saya bahas kali ini adalah MariaDB, aplikasi ini terdapat pada repositori SCLo, maka sebelum dapat menginstall MariaDB kita harus menginstall repo SCLo pada server yang akan kita konfigurasi.
Berikut ini adalah topologi server yang akan saya konfigurasi :
Topologi
Node01 DB Server
1. Install repo centos sclo terlebih dahulu, karena mariadb terdapat pada repo tersebut, jika pada repo centos default versinya masih yang 5.5, Setelah itu baru install mariadb.
[root@node01 ~]# yum -y install centos-release-scl-rh centos-release-scl[root@node01 ~]# yum --enablerepo=centos-sclo-rh -y install rh-mariadb102-mariadb-server
2. Setelah terinstall, berhubung aplikasi yang berasal dari repo sclo diinstall pada direktori /opt kita perlu melakukan load environtment agar mariadb dapat digunakan.
[root@node01 ~]# mysql #belum bisa digunakan-bash: mysql: command not found#kita aktifkan[root@node01 ~]# scl enable rh-mariadb102 bash[root@node01 ~]# mysql -V #baru bisa digunakanmysql Ver 15.1 Distrib 10.2.8-MariaDB, for Linux (x86_64) using EditLine wrapper#Buat agar otomatis terload saat booting[root@node01 ~]# vi /etc/profile.d/rh-mariadb102.sh#!/bin/bashsource /opt/rh/rh-mariadb102/enableexport X_SCLS="`scl enable rh-mariadb102 'echo $X_SCLS'`"
3. Edit file konfigurasi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf untuk menentukan character set.
[root@node01 ~]# vi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf.......[mysqld]datadir=/var/opt/rh/rh-mariadb102/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/opt/rh/rh-mariadb102/log/mariadb/mariadb.logpid-file=/run/rh-mariadb102-mariadb/mariadb.pidcharacter-set-server=utf8.......
4. Jalankan dan aktifkan service mariadb server.
[root@node01 ~]# systemctl start rh-mariadb102-mariadb[root@node01 ~]# systemctl enable rh-mariadb102-mariadbCreated symlink from /etc/systemd/system/multi-user.target.wants/rh-mariadb102-mariadb.service to /usr/lib/systemd/system/rh-mariadb102-mariadb.service.
5. Kemudian lakukan konfigurasi awal untuk menentukan root password dan yang lainnya.
[root@node01 ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): #kosongkanOK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] YNew password: #root passwordRe-enter new password:Password updated successfully!Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] Y... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] Y #ingin user root dapat diakses komputer lain atau tidak... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] Y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] Y... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
6. Setelah itu kita sudah dapat menggunakan server database ini.
[root@node01 ~]# mysql -u root -pEnter password:Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 16Server version: 10.2.8-MariaDB MariaDB ServerCopyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> select user,host,password from mysql.user;+------+-----------+-------------------------------------------+| user | host | password |+------+-----------+-------------------------------------------+| root | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 || root | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 || root | ::1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |+------+-----------+-------------------------------------------+3 rows in set (0.00 sec)MariaDB [(none)]> create database testdb;Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || testdb |+--------------------+4 rows in set (0.00 sec)MariaDB [(none)]>
7. Agar server dapat diakses dari luar kita perlu membuka firewall mysql.
[root@node01 ~]# firewall-cmd --add-service=mysql --permanentsuccess[root@node01 ~]# firewall-cmd --reloadsuccess
8. Untuk melihat error, log pada mariadb bisa menggunakan perintah dibawah ini.
[root@node01 ~]# tail -f /var/opt/rh/rh-mariadb102/log/mariadb/mariadb.log2018-06-29 8:49:39 140492900100288 [Note] InnoDB: Waiting for purge to start2018-06-29 8:49:39 140492900100288 [Note] InnoDB: 5.7.19 started; log sequence number 16202662018-06-29 8:49:39 140491962164992 [Note] InnoDB: Loading buffer pool(s) from /var/opt/rh/rh-mariadb102/lib/mysql/ib_buffer_pool2018-06-29 8:49:39 140491962164992 [Note] InnoDB: Buffer pool(s) load completed at 180629 8:49:392018-06-29 8:49:39 140492900100288 [Note] Plugin 'FEEDBACK' is disabled.2018-06-29 8:49:40 140492900100288 [Note] Server socket created on IP: '::'.2018-06-29 8:49:40 140492900100288 [Note] Reading of all Master_info entries succeded2018-06-29 8:49:40 140492900100288 [Note] Added new Master_info '' to hash table2018-06-29 8:49:40 140492900100288 [Note] /opt/rh/rh-mariadb102/root/usr/libexec/mysqld: ready for connections.Version: '10.2.8-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Sampai disini saja postingan saya kali ini,
Sekian terima kasih.
Posting Komentar untuk "Cara membuat database server mariadb pada CentOS 7"