Thursday, 27 October 2016

How to install MariaDB Server in a FreeNAS Jail

بسم الله الرحمن الرحيم



Description



A tutorial to install MariaDB Server v10.1.18 on a FreeNAS 9.10.1 Jail.


Assumptions and Prerequisites 




  • Domain: example.com
  • Hostname: db.example.com
  • OS: FreeNAS 9.10.1-U2 (FreeBSD 10.3-STABLE)
  • Container: Warden Jail
  • Jail Name: db
  • Private IP: 10.0.0.57
  • Subnet Mask: 255.255.255.0/24
  • Database Version: MariaDB v10.1.18
  • Database Server Type: Medium
  • SSL Certificates have been generated 
  • CA Certificate File: /usr/local/etc/ssl/certs/ca.pem
  • SSL Certificate File: /usr/local/etc/ssl/certs/db.example.com.crt
  • SSL Key File: /usr/local/etc/ssl/private/db.example.com.key


Instructions


Install MariaDB
# pkg install mariadb101-server

Configure Settings
Choose Configuration file for Database server: my-small.cnf, my-medium.cnf, my-large.cnf, or my-huge.cnf
# cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf 

Enable MariaDB Server to run and start on boot
# sysrc mysql_enable=yes

Start MariaDB Server
# service mysql-server start

Configure secure setup for production
# mysql_secure_installation
   Set root password? [Y/n]: y
   Remove anonymous users? [Y/n]: y
   Disallow root login remotely? [Y/n]: y
   Remove test database and access to it? [Y/n]: y
   Reload privilege tables now? [Y/n]: y

Test root Login
# mysql -u root -p

Test sql queries
# select user,host,password from mysql.user;
# show databases; 
# exit;

Enable SSL on MariaDB Server
# vi /usr/local/etc/my.cnf
   (27)  # The MariaDB server
   (28)  [mysqld]
   (29)  ssl-ca=/usr/local/etc/ssl/certs/ca.pem
   (30)  ssl-cert=/usr/local/etc/ssl/certs/db.example.com.crt
   (31)  ssl-key=/usr/local/etc/ssl/private/db.example.com.key 
   (32)  bind-address    = 10.0.0.57 
   (33)  port = 3306

No comments: