MariaDB는 GNU GPL 아래에서 자유와 오픈-소스 소프트웨어로 남기 위한 의도에서, MySQL 관계형 데이터베이스 관리 시스템의 커뮤니티-개발된, 상업적으로 지원되는 포크(fork)입니다. 개발은 오라클(Oracle Corporation)의 인수에 대한 우려 때문에 그것을 포크한, MySQL의 원래 개발자의 일부에 의해 주도되고 있습니다.
MariaDB는 MySQL과의 높은 호환성을 유지하려고 의도하고, 라이브러리 바이너리 패리티 및 MySQL APIs 및 명령과의 정확히 일치하는 드롭-인 대체 기능을 보장합니다. 그것은 새로운 스토리지 엔진, Aria을 포함하는데, 기본 트랜잭션 및 비-트랜잭션 엔진을 목표로 하는 MyISAM의 대안입니다. 초기에는 XtraDB를 기본 스토리지 엔진으로 사용했고, 버전 10.2부터 InnoDB로 다시 전환했습니다.
그의 주요 개발자는 MySQL AB의 설립자의 한 명이자 Monty Program AB의 설립자, Michael "Monty" Widenius입니다. 2008년 1월 16일, MySQL AB는 약 10억 달러에 썬 마이크로시스템즈에 의해 인수되는 것에 동의했다고 발표했습니다. 인수는 2008년 2월 26일에 완료되었습니다. MariaDB는 Monty의 어린 딸 Maria의 이름을 따서 지어졌으며, 비슷하게 MySQL은 다른 딸 My의 이름을 따서 지어졌습니다.
Installation
데비안 저장소에서 설치할 수 있습니다:
- sudo apt install mariadb-server
Service
설치와 함께 서비스가 시작되고 있습니다. 추후에 개별적으로 서비스를 시작할 때에는 다음과 같이 합니다.
- sudo systemctl start mariadb
Configuration
Preliminary configuration
서버를 처음 설치 후에는 몇 가지 해야 할 사항이 있습니다. 이중에서 제일 중요한 것이 데이터베이스 관리자(root)의 암호를 설정하는 일입니다. 이 과정을 잊지 않도록 명령어로 만들어 두었습니다.
- sudo mysql_secure_installation
이 과정 중에 관리자 암호를 새롭게 입력하는 것을 제외하고 나머지는 ↵ Enter를 입력해도 상관없습니다.
In-database configuration
데이터베이스 서버가 설정이 완료되어 동작하고 있다면, 테이블 조작 등을 위해서는 mysql 클라이언트 프로그램을 통해서 접근할 수 있습니다.
- mysql -u root -p -h localhost
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
추후에 이것이 문제가 되는 분들은 이 문서를 참고해서 다음과 같이 수정하시기 바랍니다.
- sudo mysql -u root -p
MariaDB [mysql]> use mysql;
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+-----------+-------------+
| User | Host | plugin |
+------+-----------+-------------+
| root | localhost | unix_socket |
+------+-----------+-------------+
MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit;
mysql_upgrade
데이터베이스 프로그램 업데이트 후에, 테이블 업데이트를 위해, 실행할 필요가 대체로 없는데, 왜냐하면, 프로그램 업데이트 중에 이 과정을 실행하기 때문입니다.
어쨌든, 다음과 같이 실행할 수 있습니다:
- sudo mysql_upgrade -h localhost -u user_id -p
만약 위 명령이 간혹 이상한 오류를 발생할 수 있으며, 아래와 같이 동일한 명령을 입력해 보십시오:
- sudo mysql_upgrade --host=localhost --user=user_id --password=user_passwd
Automatic Backup
다른 분이 만든 스크립트를 가져왔습니다. 원본 링크
#!/bin/bash
# Database credentials
user=""
password=""
host=""
db_name=""
# Other options
backup_path="/path/to/your/home/_backup/mysql"
date=$(date +"%d-%b-%Y")
# Set default file permissions
umask 177
# Dump database into SQL file
mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql
# Delete files older than 30 days
find $backup_path/* -mtime +30 -exec rm {} \;
실행 권한을 수정합니다:
- chmod 100 mysql_backup.sh
Cron daemon
하루에 1번씩 백업 파일을 생성하도록 /etc/cron.daily/mysql-backup 파일을 만듭니다:
#!/bin/sh
#
test -x /path/to/mysql_backup.sh || exit 0
/path/to/mysql_backup.sh >/dev/null 2>&1
- sudo chmod +x /etc/cron.daily/mysql-backup
Crontab
같은 방법을 다르게 적용할 수도 있습니다. 매일 정각에 백업하도록 sude crontab -e를 실행해서 다음을 입력합니다.
00 00 * * * /path/to/mysql_backup.sh
크론 데몬을 재시작합니다:
- sudo systemctl restart cron
Setting up MariaDB Repository
개발자 정보 페이지에서 서버의 버전별 정보를 확인할 수 있습니다.
데비안
MariaDB 다운로드 페이지로 접근합니다.
- Choose a Distro: Debian
- Choose a Release: Debian 11 "bullseye"
- Choose a Version: 10.6 [Stable]
- Choose a Mirror: DigitalOcean
아래의 나오는 내용 중에 다음 부분을 수행합니다:
- sudo apt-get install software-properties-common dirmngr
- sudo curl -LsSO https://mariadb.org/mariadb_release_signing_key.asc
- sudo chmod -c 644 mariadb_release_signing_key.asc
- sudo mv -vi mariadb_release_signing_key.asc /etc/apt/trusted.gpg.d/
- sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.6/debian bullseye main'
- sudo apt update
- sudo apt install mariadb-server
우분투
MariaDB 다운로드 페이지로 접근합니다.
- Choose a Distro: Ubuntu
- Choose a Release: 18.04 LTS "bionic"
- Choose a Version: 10.4 [Stable]
- Choose a Mirror: DigitalOcean
아래의 나오는 내용 중에 다음 부분을 수행합니다:
Here are the commands to run to install MariaDB 10.4 from the MariaDB repository on your Ubuntu system:
- sudo apt-get install software-properties-common
- sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
- sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main'
- sudo apt update
- sudo apt install mariadb-server
만약 이전 버전의 mariadb-server가 설치되어 있을 때, 주의 사항은 이 문서를 참고하시기 바랍니다.
Performance tuning
이 문서에 나오는 스크립트를 받았습니다.
스크립트 perl mysqltunner.pl을 실행하면 다음과 같이 출력됩니다.
General recommendations:
Control warning line(s) into /var/log/mysql/error.log file
Control error line(s) into /var/log/mysql/error.log file
Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
MySQL started within last 24 hours - recommendations may be inaccurate
Reduce or eliminate unclosed connections and network issues
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
Performance should be activated for better diagnostics
Consider installing Sys schema from https://github.com/mysql/mysql-sys
Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: http://bit.ly/2wgkDvS
Variables to adjust:
query_cache_size (=0)
query_cache_type (=0)
query_cache_limit (> 1M, or use smaller result sets)
performance_schema = ON enable PFS
innodb_buffer_pool_size (>= 270M) if possible.
innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
innodb_buffer_pool_instances (=1)
하단부에 일반적인 추천 사항이 있습니다. 설정 /etc/mysql/mariadb.conf.d/50-server.conf을 수정해서 적용합니다.
# this is only for the mysqld standalone daemon
[mysqld]
# mariadb server에 정보 보내기..
# feedback=ON
performance_schema=ON
query_cache_size = 1000000
query_cache_type = 1
query_cache_limit = 2M
innodb_buffer_pool_size = 512M
innodb_log_file_size = 64M
innodb_buffer_pool_instances = 1
Convert MyISAM to InnoDB
덤프 파일에서 MyISAM을 InnoDB로 바꾸고 데이터베이스를 제거한 후에, 새로 만들고 덤프 파일을 삽입했습니다.
mysql-sys
이 내용을 받아서 5.7으로 적용했습니다.
External resources
- MariaDB official documentation
- MariaDB VS MySQL features
- MariaDB VS MySQL compatibility
- Moving from MySQL
- https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost
- http://www.mysqlkorea.com/sub.html?mcode=manual&scode=01_1&m_no=22545&cat1=827&cat2=966&cat3=1007&lang=k
- https://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa