Mariadb 10.4.13 Source install on CentOS 8

Mariadb 10.4.13 을 CentOS 8 에 source install 을 진행해 보았습니다.

Enviroment
OS : CentOS 8.1
Mariadb : 10.4.13

1. Default Enviroment Setting

$sudo dnf install tar wget
$sudo mkdir -p /usr/local/IDC/Src
$sudo mkdir -p /usr/local/IDC/Download
$sudo mkdir -p /usr/local/IDC/Service
$sudo mkdir -p /usr/local/IDC/Data

일반적인 설치는 centos 8 부터 적용된 dnf 를 사용하며 각 폴더의 용도는 다음과 같습니다.
Download – Source File 위치
Src – Source compile prefix 위치 ( 서비스명 + 버전명 표시 )
Service – Symbolic Src 위치 ( 서비스명 표시 )

2. Install Mariadb Default Environment Setting

$sudo dnf install cmake gcc-c++ guntls-devel ncurses-devel libxml2-devel libaio-devel libevent bison make
$sudo groupadd --system mariadb
$sudo useradd --system -g mariadb -d /usr/local/IDC/Data/mariadb -s /sbin/nologin -C "Maria Database" mariadb

3. Download Mariadb 10.4.13 & Install

$sudo cd /usr/local/IDC/Download
$sudo wget https://downloads.mariadb.org/interstitial/mariadb-10.4.13/source/mariadb-10.4.13.tar.gz
$sudo tar xfpvz mariadb-10.4.13.tar.gz
$sudo cd mariadb-10.4.13
$sudo cmake \
-DWITH_READLINE=1 \
-DWITH_SSL=bundled \
-DWITH_ZLIB=system \
-DWITH_JEMALLOC=no \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_ARIA_STORAGE_ENGINE=1 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATEDX_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_SAFEMALLOC=1 \
-DWITH_QUERY_CACHE_INFO=1 \
-DWITH_QUERY_RESPONSE_TIME=1 \
-DINSTALL_SYSCONFDIR=/usr/local/IDC/Src/mariadb-10.4.13/etc \
-DINSTALL_SYSCONF2DIR=/usr/local/IDC/Src/mariadb-10.4.13/etc/my.cnf.d \
-DCMAKE_INSTALL_PREFIX=/usr/local/IDC/Src/mariadb-10.4.13 \
-DMYSQL_DATADIR=/usr/local/IDC/Data/mariadb \
-DMYSQL_UNIX_ADDR=/usr/local/IDC/Src/mariadb-10.4.13/socket/mysql.socket
$sudo make -j$(nproc)
$sudo make install
$sudo mkdir -p /usr/local/IDC/Src/mariadb-10.4.13/tmp
$sudo mkdir -p /usr/local/IDC/Src/mariadb-10.4.13/logs

4. Symbloic directory & mysql / mysqldump

$sudo cd /usr/local/IDC/Service
$sudo ln -s /usr/local/IDC/Src/mariadb-10.4.13 /usr/local/IDC/Service/mariadb
$sudo ln -s /usr/local/IDC/Service/mariadb/bin/mysql /usr/bin/
$sudo ln -s /usr/local/IDC/Service/mariadb/bin/mysqldump /usr/bin/

5. Change my.cnf

$sudo vi /usr/local/IDC/Service/mariadb/etc/my.cnf

# 32G Ram Setting

[client]
port    = 3306
socket  = /usr/local/IDC/Service/mariadb/mysql.sock

[mysqld]
user = mariadb
port = 3306
extra_port = 13306
extra_max_connections = 5
bind-address = 0.0.0.0

socket   = /usr/local/IDC/Service/mariadb/mysql.sock
pid-file = /usr/local/IDC/Service/mariadb/mysqld.pid
tmpdir   = /usr/local/IDC/Service/mariadb/tmp

log_warnings = 2
log-error    = /usr/local/IDC/Service/mariadb/logs/mysqld.log

slow_query_log      = 1
long_query_time     = 3
slow_query_log_file = /usr/local/IDC/Service/mariadb/logs/mysqld-slow.log

# replication setting
server-id        = 1
log-bin          = mariadb-bin
log-bin-index    = mariadb-bin.index
expire_logs_days = 7
max_binlog_size  = 1024M
binlog_format    = row
gtid_strict_mode = 1

event_scheduler  = ON
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-bin-trust-function-creators = 1

max_allowed_packet      = 16M
default_storage_engine  = InnoDB
character-set-server    = utf8
collation_server        = utf8_general_ci

character-set-client-handshake = FALSE
skip-character-set-client-handshake

init_connect         = set names utf8
init_connect         = set collation_connection=utf8_general_ci

skip-name-resolve
back_log             = 1500
max_connections      = 2500
max_user_connections = 0
thread_cache_size    = 64
wait_timeout         = 120
interactive_timeout  = 350

thread_pool_size         = 4
thread_handling          = pool-of-threads
thread_pool_max_threads  = 1024
thread_pool_idle_timeout = 120

tmp_table_size             = 256M
table_open_cache           = 70000
myisam_sort_buffer_size    = 64M
max_heap_table_size        = 64M

innodb_data_home_dir      = /usr/local/IDC/Data/mariadb/
innodb_log_group_home_dir = /usr/local/IDC/Data/mariadb/
innodb_data_file_path     = ibdata1:5G;ibdata2:5G;ibdata3:5G;ibdata4:5G:autoextend

# files
innodb_file_per_table
innodb_log_file_size      = 832M
innodb_log_files_in_group = 2
innodb_open_files         = 4000
innodb_undo_tablespaces   = 4

# buffers
key_buffer_size                     = 32M
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup  = 1
innodb_buffer_pool_size             = 20G
innodb_buffer_pool_instances        = 16
innodb_log_buffer_size              = 64M

# tune
innodb_doublewrite             = 1
# Try number of CPU's*2 for thread_concurrency
innodb_thread_concurrency      = 20
innodb_flush_log_at_trx_commit = 1
innodb_flush_method            = O_DIRECT_NO_FSYNC
innodb_max_dirty_pages_pct     = 30
innodb_max_dirty_pages_pct_lwm = 3
innodb_lru_scan_depth          = 2048
join_buffer_size               = 4M
sort_buffer_size               = 5M
read_buffer_size               = 4M
read_rnd_buffer_size           = 16M
innodb_use_native_aio          = 1
innodb_stats_persistent        = 1
innodb_adaptive_flushing       = 1
innodb_flush_neighbors         = 0
innodb_read_io_threads         = 16
innodb_write_io_threads        = 16
innodb_io_capacity             = 1500
innodb_io_capacity_max         = 2500
innodb_purge_threads           = 4
innodb_adaptive_hash_index     = 0
max_prepared_stmt_count        = 500000
innodb_monitor_enable = '%'
performance_schema = ON


[mysql]
no_auto_rehash
default-character-set=utf8

[myisamchk]
aria_pagecache_buffer_size = 64M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqldump]
quick
max_allowed_packet = 16M

[mysqld_safe]
open_files_limit = 8000
user = mariadb

6.  Reset database file by my.cnf & Setting privilege

$sudo cd /usr/local/IDC/Service/mariadb/scripts
$sudo chown -R mariadb.mariadb /usr/local/IDC/Src/mariadb-10.4.13
$sudo chown -R mariadb.mariadb /usr/local/IDC/Data/mariadb
$sudo ./mysql_install_db --user=mariadb --basedir=/usr/local/IDC/Src/mariadb-10.4.13/ --datadir=/usr/local/IDC/Data/mariadb

7. Create mariadb systemd

$sudo vi /etc/systemd/system/mariadb.service

[Unit]
Description=MariaDB Database Server
After=syslog.target
After=network.target

[Service]
KillMode=process
KillSignal=SIGTERM
SendSIGKILL=no

User=mariadb
Group=mariadb

LimitNOFILE=infinity
LimitNPROC=4096
LimitCORE=infinity
PermissionsStartOnly=true
PrivateTmp=true
OOMScoreAdjust=-1000
ExecStartPre=sync
ExecStartPre=sysctl -q -w vm.drop_caches=3
ExecStart=/usr/local/IDC/Service/mariadb/bin/mysqld --defaults-file=/usr/local/IDC/Service/mariadb/etc/my.cnf --plugin-dir=/usr/local/IDC/Service/mariadb/lib/plugin --pid-file=/usr/local/IDC/Service/mariadb/mysqld.pid
Restart=always
RestartSec=1
TimeoutSec=300

[Install]
WantedBy=multi-user.target

8. Mariadb Secure installation

$sudo systemctl enable mariadb.service
$sudo systemctl start mariadb.service
$sudo /usr/local/IDC/Service/mariadb/bin/mariadb-secure-installation -S /usr/local/IDC/Service/mariadb/mysql.sock

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x