MariaDB 10.5 binary install (바이너리 설치)
- 네오클로바 DB지원사업부
1. About MariaDB
1.1 MariaDB 개요
1.2 MariaDB as a R-DBMS
1.3 Open Source Database System
2. 설치
2.1 설치 기본 정보
2.2 설치 준비
2.3 MariaDB 설치
2.4 MariaDB 시작 / 접속 / 종료
2.5 추가 설정
2. 2
http://neoclova.co.kr/
목차
1. About MariaDB 3
1.1 MariaDB 개요 3
1.2 MariaDB as a R-DBMS 3
1.3 Open Source Database System 3
2. 설치 4
2.1 설치 기본 정보 4
2.2 설치 준비 4
2.3 MariaDB 설치 5
2.4 MariaDB 시작 / 접속 / 종료 8
2.5 추가 설정 11
3. 3
http://neoclova.co.kr/
1. About MariaDB
1.1 MariaDB 개요
MariaDB는 전세계적으로 가장 널리 사용되고 있는 Open Source Database System인 MySQL 과의 호
환성을 가지면서 추가적인 기능들을 개발하여 배포/판매하고 있는 데이터베이스이다. 2009년 initial
release를 했다.
1.2 MariaDB as a R-DBMS
관계형 데이터베이스는 데이터를 하나의 커다란 저장 공간에 저장하지 않고 서로 별개의 테이블에 나
누어서 저장을 하는 시스템이다. 이를 통해 처리 속도와 유연성이 확보된다. SQL은 “Structured Query
language”의 약자이며, SQL은 ANSI/ISO 표준에서 정의한 데이터베이스 접속을 위한 가장 일반적인
표준 언어이다. 이 매뉴얼에서 언급하는 “SQL 표준”은 각 시점에서 발표된 SQL표준을 의미하는 것이
다.
1.3 Open Source Database System
MariaDB 데이터베이스는 GPL(GNU Public License)을 준수하는 오픈 소스 데이터베이스이며, GPL을
준수해서 사용하는 모든 사용자에게 무료로 배포되고 있다.
http://mariadb.org/
http://mariadb.com/
4. 4
http://neoclova.co.kr/
2. 설치
2.1 설치 기본 정보
항목 값
OS version CentOS 7.5
OS user maria
MariaDB version MariaDB 10.5.11
Base directory /usr/local/mariadb
Data directory /Neoclova/maria/data
Log directory /Neoclova/maria/log
Temp directory /Neoclova/maria/tmp
2.2 설치 준비
2.2.1 OS 계정 생성
[root@neoclova ~]# groupadd dba
[root@neoclova ~]# useradd -g dba maria
[root@neoclova ~]# id maria
uid=1001(maria) gid=1001(dba) groups=1001(dba)
[root@neoclova local]# grep maria /etc/passwd
maria:x:1001:1001::/home/maria:/bin/bash
[root@neoclova local]# grep dba /etc/group
dba:x:1001:
2.2.2 디렉토리 생성
[root@neoclova ~]# mkdir -p /Neoclova/maria/data /Neoclova/maria/log /Neoclova/maria/tmp
/Neoclova/maria/log/undo
[root@neoclova ~]# chown -R maria.dba /Neoclova/maria
[root@neoclova ~]# ls -lah /Neoclova/maria
total 0
drwxr-xr-x. 5 maria dba 40 Jun 24 04:21 .
drwxr-xr-x. 3 root root 19 Jun 24 04:21 ..
drwxr-xr-x. 2 maria dba 6 Jun 24 04:21 data
drwxr-xr-x. 2 maria dba 6 Jun 24 04:21 log
drwxr-xr-x. 2 maria dba 6 Jun 24 04:21 tmp
5. 5
http://neoclova.co.kr/
2.2.3 MariaDB Download
https://mariadb.org/download/
https://archive.mariadb.org/
[root@neoclova ~]# cd /usr/local/
[root@neoclova local]# curl https://archive.mariadb.org/mariadb-10.5.11/bintar-linux-
systemd-x86_64/mariadb-10.5.11-linux-systemd-x86_64.tar.gz -o mariadb.tgz
[root@neoclova local]# ls -lah mariadb.tgz
-rw-r--r--. 1 root root 334M Jun 24 04:41 mariadb.tgz
2.3 MariaDB 설치
2.3.1 MariaDB 엔진 설치 (tar 압축 해제 / 심볼릭 링크 / chown 설정)
[root@neoclova local]# ## tar extract
[root@neoclova local]# tar xvfz mariadb.tgz -C /usr/local/
[root@neoclova local]# ## symbolic link
[root@neoclova local]# ln -s mariadb-10.5.11-linux-systemd-x86_64/ mariadb
[root@neoclova local]# ## chown change
[root@neoclova local]# chown -R maria.dba maria*
[root@neoclova local]# ls -lah maria*
lrwxrwxrwx. 1 maria dba 37 Jun 24 04:45 mariadb -> mariadb-10.5.11-linux-systemd-
x86_64/
-rw-r--r--. 1 maria dba 334M Jun 24 04:41 mariadb.tgz
mariadb-10.5.11-linux-systemd-x86_64:
total 164K
drwxrwxr-x. 11 maria dba 245 Jun 22 02:15 .
drwxr-xr-x. 13 root root 209 Jun 24 04:45 ..
drwxr-xr-x. 2 maria dba 4.0K Oct 22 2020 bin
-rw-r--r--. 1 maria dba 18K Jun 18 10:19 COPYING
-rw-r--r--. 1 maria dba 2.1K Jun 18 10:19 CREDITS
drwxrwxr-x. 3 maria dba 19 Jun 22 02:15 include
-rw-r--r--. 1 maria dba 8.6K Jun 18 10:19 INSTALL-BINARY
drwxr-xr-x. 5 maria dba 273 Apr 8 18:52 lib
drwxrwxr-x. 4 maria dba 30 Jun 22 02:15 man
6. 6
http://neoclova.co.kr/
drwxrwxr-x. 9 maria dba 4.0K Jun 22 02:15 mysql-test
-rw-r--r--. 1 maria dba 3.0K Jun 18 10:19 README.md
-rw-r--r--. 1 maria dba 20K Jun 18 10:19 README-wsrep
drwxrwxr-x. 2 maria dba 56 Jun 22 02:15 scripts
drwxrwxr-x. 31 maria dba 4.0K Jun 22 02:15 share
drwxrwxr-x. 4 maria dba 4.0K Jun 22 02:15 sql-bench
drwxrwxr-x. 4 maria dba 180 Jun 22 02:15 support-files
-rw-r--r--. 1 maria dba 85K Jun 18 10:19 THIRDPARTY
2.3.2 my.cnf 설정
[root@neoclova local]# cd /Neoclova/maria
[root@neoclova maria]# vi my.cnf
[root@neoclova maria]# cat my.cnf
[mysql]
port = 63306
socket = /Neoclova/maria/tmp/maria.sock
[mysqld]
user = maria
port = 63306
basedir = /usr/local/mariadb
socket = /Neoclova/maria/tmp/maria.sock
pid-file = /Neoclova/maria/tmp/mariadbd.pid
datadir = /Neoclova/maria/data
log-error = /Neoclova/maria/log/maria_error.log
tmpdir = /Neoclova/maria/tmp
innodb_undo_directory = /Neoclova/maria/log/undo
transaction_isolation = READ-UNCOMMITTED
innodb_fast_shutdown = 0
#innodb_buffer_pool_size = 512M
[root@neoclova local]# chown -R maria.dba my.cnf
2.3.3 MariaDB install DB (initialize)
[root@neoclova maria]# yum install libaio
[root@neoclova maria]# /usr/local/mariadb/scripts/mariadb-install-db --defaults-
file=/Neoclova/maria/my.cnf --basedir=/usr/local/mariadb
Installing MariaDB/MySQL system tables in '/Neoclova/maria/data' ...
7. 7
http://neoclova.co.kr/
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is maria@localhost, it has no password either, but
you need to be the system 'maria' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr/local/mariadb' ; /usr/local/mariadb/bin/mysqld_safe --
datadir='/Neoclova/maria/data'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mariadb/mysql-test' ; perl mysql-test-run.pl
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
[root@neoclova maria]# ls -lah *
-rw-r--r--. 1 root root 404 Jun 24 05:03 my.cnf
data:
total 109M
drwxr-xr-x. 5 maria dba 162 Jun 24 05:06 .
drwxr-xr-x. 5 maria dba 54 Jun 24 05:03 ..
-rw-rw----. 1 maria dba 24K Jun 24 05:06 aria_log.00000001
-rw-rw----. 1 maria dba 52 Jun 24 05:06 aria_log_control
-rw-rw----. 1 maria dba 972 Jun 24 05:06 ib_buffer_pool
-rw-rw----. 1 maria dba 12M Jun 24 05:06 ibdata1
-rw-rw----. 1 maria dba 96M Jun 24 05:06 ib_logfile0
drwx------. 2 maria dba 4.0K Jun 24 05:06 mysql
drwx------. 2 maria dba 20 Jun 24 05:06 performance_schema
drwx------. 2 maria dba 20 Jun 24 05:06 test
log:
8. 8
http://neoclova.co.kr/
total 0
drwxr-xr-x. 2 maria dba 29 Jun 24 05:06 .
drwxr-xr-x. 5 maria dba 54 Jun 24 05:03 ..
-rw-rw----. 1 maria dba 0 Jun 24 05:06 maria_error.log
2.4 MariaDB 시작 / 접속 / 종료
2.4.1 MariaDB 시작
[root@neoclova maria]# su – maria
[maria@neoclova ~]$ /usr/local/mariadb/bin/mariadbd-safe --defaults-
file=/Neoclova/maria/my.cnf &
[1] 2428
210624 05:32:41 mysqld_safe Logging to '/Neoclova/maria/log/maria_error.log'.
210624 05:32:41 mysqld_safe Starting mariadbd daemon with databases from
/Neoclova/maria/data
프로세스 확인 및 에러로그 확인
[maria@neoclova ~]$ ps -ef | grep maria
maria 2428 2383 0 05:32 pts/0 00:00:00 /bin/sh /usr/local/mariadb/bin/mariadbd-
safe --defaults-file=/Neoclova/maria/my.cnf
maria 2529 2428 0 05:32 pts/0 00:00:00 /usr/local/mariadb/bin/mariadbd --
defaults-file=/Neoclova/maria/my.cnf --basedir=/usr/local/mariadb --
datadir=/Neoclova/maria/data --plugin-dir=/usr/local/mariadb/lib/plugin --log-
error=/Neoclova/maria/log/maria_error.log --pid-file=/Neoclova/maria/tmp/mariadbd.pid --
socket=/Neoclova/maria/tmp/maria.sock --port=63306
[maria@neoclova ~]$ cat /Neoclova/maria/log/maria_error.log
210624 05:32:41 mysqld_safe Starting mariadbd daemon with databases from
/Neoclova/maria/data
2021-06-24 5:32:41 0 [Note] /usr/local/mariadb/bin/mariadbd (mysqld 10.5.11-MariaDB)
starting as process 2529 ...
2021-06-24 5:32:41 0 [Warning] Could not increase number of max_open_files to more than
1024 (request: 32184)
2021-06-24 5:32:41 0 [Warning] Changed limits: max_open_files: 1024 max_connections:
151 (was 151) table_cache: 421 (was 2000)
2021-06-24 5:32:41 0 [Note] InnoDB: Uses event mutexes
2021-06-24 5:32:41 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-06-24 5:32:41 0 [Note] InnoDB: Number of pools: 1
2021-06-24 5:32:41 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
9. 9
http://neoclova.co.kr/
2021-06-24 5:32:41 0 [Note] mariadbd: O_TMPFILE is not supported on /Neoclova/maria/tmp
(disabling future attempts)
2021-06-24 5:32:41 0 [Note] InnoDB: Using Linux native AIO
2021-06-24 5:32:41 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728,
chunk size = 134217728
2021-06-24 5:32:41 0 [Note] InnoDB: Completed initialization of buffer pool
2021-06-24 5:32:41 0 [Note] InnoDB: 128 rollback segments are active.
2021-06-24 5:32:41 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-06-24 5:32:41 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically
writing the file full; Please wait ...
2021-06-24 5:32:41 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-06-24 5:32:41 0 [Note] InnoDB: 10.5.11 started; log sequence number 45142;
transaction id 20
2021-06-24 5:32:41 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-06-24 5:32:41 0 [Note] InnoDB: Loading buffer pool(s) from
/Neoclova/maria/data/ib_buffer_pool
2021-06-24 5:32:41 0 [Note] InnoDB: Buffer pool(s) load completed at 210624 5:32:41
2021-06-24 5:32:41 0 [Note] Server socket created on IP: '::'.
2021-06-24 5:32:41 0 [Note] Reading of all Master_info entries succeeded
2021-06-24 5:32:41 0 [Note] Added new Master_info '' to hash table
2021-06-24 5:32:41 0 [Note] /usr/local/mariadb/bin/mariadbd: ready for connections.
Version: '10.5.11-MariaDB' socket: '/Neoclova/maria/tmp/maria.sock' port: 63306
MariaDB Server
2.4.2 MariaDB 접속
[maria@neoclova ~]$ cd /usr/local/mariadb
[maria@neoclova mariadb]$ ./bin/mariadb --socket=/Neoclova/maria/tmp/maria.sock
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 10.5.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]> status
--------------
/usr/local/mariadb/bin/mariadb Ver 15.1 Distrib 10.5.11-MariaDB, for Linux (x86_64)
using readline 5.1
Connection id: 7
Current database:
Current user: maria@localhost
SSL: Not in use
10. 10
http://neoclova.co.kr/
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.5.11-MariaDB MariaDB Server
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /Neoclova/maria/tmp/maria.sock
Uptime: 11 min 16 sec
Threads: 1 Questions: 7 Slow queries: 0 Opens: 20 Open tables: 13 Queries per
second avg: 0.010
--------------
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]> select user, host, authentication_string from mysql.user;
+-------------+-----------+-----------------------+
| User | Host | authentication_string |
+-------------+-----------+-----------------------+
| mariadb.sys | localhost | |
| root | localhost | invalid |
| maria | localhost | invalid |
| | localhost | |
| | neoclova | |
+-------------+-----------+-----------------------+
5 rows in set (0.002 sec)
MariaDB [(none)]> set password for 'root'@'localhost' = password("db@neoclova.co.kr");
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> exit
Bye
12. 12
http://neoclova.co.kr/
[maria@neoclova ~]$ ls -lah maria*.sh
-rwxr-x---. 1 maria dba 72 Jun 24 05:45 maria.sh
-rwxr-x---. 1 maria dba 89 Jun 24 05:44 maria-start.sh
-rwxr-x---. 1 maria dba 97 Jun 24 05:44 maria-stop.sh
2.5.2 Bash Shell 설정
[maria@neoclova ~]$ vi .bash_profile
[maria@neoclova ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/mariadb/bin
export PATH
alias maria-start=~/maria-start.sh
alias maria-stop=~/maria-stop.sh
alias maria=~/maria.sh
[maria@neoclova ~]$ source .bash_profile
[maria@neoclova ~]$ alias | grep maria
alias maria='/home/maria/maria.sh'
alias maria-start='~/maria-start.sh'
alias maria-stop='~/maria-stop.sh'
2.5.3 Linux limit 설정
https://mariadb.com/kb/en/configuring-linux-for-mariadb/
[root@neoclova maria]# vi /etc/security/limits.conf
[root@neoclova maria]# grep maria /etc/security/limits.conf
maria soft nofile 65536
maria hard nofile 65536
13. 13
http://neoclova.co.kr/
2.5.4 systemd 설정 (service 등록)
[root@neoclova system]# vi /etc/systemd/system/maria.service
[root@neoclova system]# cat /etc/systemd/system/maria.service
[Unit]
Description=MariaDB Server
After=network.target
[Service]
Type=forking
User=maria
Group=dba
LimitNOFILE=infinity
TasksMax=infinity
ExecStart=/home/maria/maria-start.sh
ExecStop=/home/maria/maria-stop.sh
[Install]
WantedBy=multi-user.target
[root@neoclova system]# systemctl daemon-reload
[root@neoclova system]# visudo
[root@neoclova system]# grep maria /etc/sudoers
maria ALL=NOPASSWD:/usr/bin/systemctl start maria.service, /usr/bin/systemctl stop
maria.service, /usr/bin/systemctl status maria.service, /usr/bin/systemctl restart
maria.service
2.5.5 Secure installation
[maria@neoclova ~]$ mariadb-secure-installation --basedir=/usr/local/mariadb --
socket=/Neoclova/maria/tmp/maria.sock
print: /usr/local/mariadb/bin/my_print_defaults
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
14. 14
http://neoclova.co.kr/
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before 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 far
will 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 MariaDB
installation should now be secure.
Thanks for using MariaDB!