DB/MariaDB

MariaDB?

Dev.Congsik 2024. 8. 26. 15:16
728x90

  • 오픈 소스 데이터베이스 관리 시스템(DBMS)으로, MySQL을 기반으로 개발
  • 대규모 데이터베이스 환경에서 안정성과 성능을 제공하는 동시에 호환성과 사용 편의성을 유지
  • 다양한 플랫폼에서 사용할 수 있으며, 데이터베이스 관리 및 쿼리 작성을 위한 다양한 기능과 도구를 제공
  • 오픈 소스 커뮤니티에 의해 개발되고 유지
  • 커뮤니티의 참여와 기여를 통해 지속적으로 발전 중

 

MariaDB Install

  • 설치환경 : Centos 7.9
  • MariaDB-backup-10.4.22-1.el7.centos.x86_64.rpm으로 설치 진행

 

  • Pre-install
mkdir -p /var/tmp/

cp repo/.repo /etc/yum.repos.d/
cp package/.gz  /var/tmp/
cp rpm/* /var/tmp/

 

  • Install
yum --disablerepo=\* --enablerepo=offline-MariaDB install MariaDB -y //오프라인 설치

rpm -Uvh /var/tmp/MariaDB-backup-10.4.22-1.el7.centos.x86_64.rpm //rpm파일로 설치 진행

 

  • /data/mysql 폴더 생성 및 권한, 설치 경로 변경
mkdir /data/mysql //디렉토리 생성
chown -R mysql:mysql /data/mysql/ //디렉토리 그룹:사용자 권한 부여
mysql_install_db --user=mysql --datadir=/data/mysql //설치유저, 설치경로 설정 후 설치

 

  • server.cnf 설정
vi /etc/my.cnf.d/server.cnf

[mariadb-10.4] 항목에 아래 내용 추가
core_file
datadir = /data/mysql
socket = /data/mysql/mysql.sock
log_bin=/data/mysql/mysql_binary_log
log_error=/data/mysql/dbms01.err
wait_timeout = 2147483
transaction_isolation = READ-COMMITTED
character_set_client = utf8mb4
character_set_server = utf8mb4
collation_server = utf8mb4_general_ci
character-set-client-handshake = FALSE
group_concat_max_len = 1048576
thread_handling = pool-of-threads
thread_pool_stall_limit = 100
thread_pool_max_threads = 2000
max_connections = 16000
max_allowed_packet = 16M
low_priority_updates = on
query_cache_type = off
max_heap_table_size = 256M
tmp_table_size = 256M
bulk_insert_buffer_size = 64M
innodb_file_format = barracuda
innodb_buffer_pool_size = 12G               //할당 서버의 메모리 6~70% 수준으로 설정
innodb_buffer_pool_instances = 8            //버퍼 풀 인스턴스 수(트랜잭션 경합 감소)
innodb_log_file_size = 256M
innodb_log_files_in_group = 4
innodb_table_locks = off
innodb_flush_method = O_DIRECT

**그 외 파라미터
slow_query_log = on   //실행시간이 10초 이상인 쿼리만 기록
long_query_time = 10  //최대 쿼리 실행시간 10초

 

이후 설정값 적용을 위해 서버 재부팅

 

  • MariaDB 서비스 기동 및 설정
systemctl start mariadb  //서비스 기동
systemctl status mariadb  //서비스 상태확인
systemctl enable mariadb  //서비스 자동 실행 설정
  • MariaDB 심볼릭 설정 및 보안 설치
ln -sf /data/mysql/mysql.sock /var/lib/mysql/  //mysql.sock 파일 심볼릭 설정

/usr/bin/mysql_secure_installation  //보안 설치 진행

Enter current password for root (enter for none): **enter**
Switch to unix_socket authentication [Y/n]: **n**
Change the root password? [Y/n]: **y**
New password: **root 패스워드 입력**
Re-enter new password: **root 패스워드 입력**
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**

 

  • 설치 완료 후 root 접속 테스트
mysql -u root -p //root유저로 접속

 

728x90