Rocky Linux 9에 MariaDB 10.11 설치하기

Rocky Linux 9에 MariaDB 10.18을 설치하고 설정하는 방법에 대해 알아보고, 실습을 통해 쉽게 따라할 수 있습니다. MariaDB의 특징과 장점, 필요한 패키지와 명령어, 보안 설정과 테스트 방법 등을 자세히 설명합니다.
인프라코디
Rocky Linux 9에 MariaDB 10.11 설치하기

MariaDB는 오픈 소스의 관계형 데이터베이스 관리 시스템(RDBMS)으로, MySQL과 같은 소스 코드를 기반으로 빠르고 안정적인 오픈 소스 관계형 데이터베이스 관리 시스템입니다. MariaDB는 오라클의 상업적인 정책에 반발하여 MySQL의 창업자 중 한 명인 몬티 와이드니어스가 만든 프로젝트입니다. MariaDB는 MySQL과 높은 호환성을 유지하면서도 독자적인 개선과 혁신을 이루고 있습니다.

2023년 9월 7일 현재 최신 버전은 MariaDB 10.11 버전이며, 2028년 2월까지 지원됩니다.

Rocky Linux 9 환경에서 MariaDB 10.11 버전을 설치하고 설정하는 방법에 대해 알아보고, 아래 실습 내용을 통해 쉽게 설치하여 사용할 수 있습니다.

실습 환경

  • 작업일 : 2023년 09월 07일
  • 하드웨어 : 2 CPUs, 4GB Memory, 40GB Disk
  • 운영 체제 : Rocky Linux 9.2
  • 실행 계정 : root
  • SSH 접속 및 외부 인터넷이 가능한 네트워크 구성
  • MariaDB 버전 : MariaDB-server-10.11.5-1.el9

MariaDB 10.11 저장소 추가하기

Rocky Linux 9.2에서 DNF 패키지 관리자를 사용해서 MariaDB를 설치하게 되면 10.5 버전을 설치하게 됩니다.

그래서 MariaDB 최신 버전인 10.11을 설치하기 위해서는 MariaDB 공식 저장소를 수동으로 추가해야 합니다.

dnf info mariadb-server
실행 결과
Last metadata expiration check: 1:20:26 ago on Thu 07 Sep 2023 10:08:25 AM KST. Available Packages Name : mariadb-server Epoch : 3 Version : 10.5.16 Release : 2.el9_0 Architecture : x86_64 Size : 9.4 M Source : mariadb-10.5.16-2.el9_0.src.rpm Repository : appstream Summary : The MariaDB server and related files URL : http://mariadb.org License : GPLv2 and LGPLv2 Description : MariaDB is a multi-user, multi-threaded SQL database server. It is a : client/server implementation consisting of a server daemon (mariadbd) : and many different client programs and libraries. This package contains : the MariaDB server and some accompanying files and directories. : MariaDB is a community developed fork from MySQL.

MariaDB 10.11 버전의 공식 저장소를 추가합니다. vi 에디터를 실행하여 MariaDB.repo 파일을 생성합니다.

vi /etc/yum.repos.d/MariaDB.repo

아래 내용을 입력하여 MariaDB 공식 저장소를 추가합니다.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.11/rhel9-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

DNF 패키지 관리자에서 사용할 수 있는 저장소의 목록을 출력하고, MariDB 저장소를 확인합니다.

dnf repolist
실행 결과
repo id repo name appstream Rocky Linux 9 - AppStream baseos Rocky Linux 9 - BaseOS crb Rocky Linux 9 - CRB epel Extra Packages for Enterprise Linux 9 - x86_64 epel-cisco-openh264 Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64 epel-next Extra Packages for Enterprise Linux 9 - Next - x86_64 extras Rocky Linux 9 - Extras mariadb MariaDB

MariaDB 설치하기

MariaDB 10.11 버전의 공식 저장소를 추가했으면, 다음 명령어를 실행하여 설치합니다.

dnf -y install MariaDB-server MariaDB-client
실행 결과
Last metadata expiration check: 0:06:26 ago on Thu 07 Sep 2023 11:54:03 AM KST. Dependencies resolved. =============================================================================================== Package Architecture Version Repository Size =============================================================================================== Installing: MariaDB-client x86_64 10.11.5-1.el9 mariadb 9.2 M MariaDB-server x86_64 10.11.5-1.el9 mariadb 18 M Installing dependencies: MariaDB-common x86_64 10.11.5-1.el9 mariadb 88 k MariaDB-shared x86_64 10.11.5-1.el9 mariadb 130 k boost-program-options x86_64 1.75.0-8.el9 appstream 106 k daxctl-libs x86_64 71.1-8.el9 baseos 41 k galera-4 x86_64 26.4.14-1.el9 mariadb 1.3 M libpmem x86_64 1.12.1-1.el9 appstream 111 k ndctl-libs x86_64 71.1-8.el9 baseos 88 k perl-DBI x86_64 1.643-9.el9 appstream 700 k socat x86_64 1.7.4.1-5.el9 appstream 300 k Installing weak dependencies: pv x86_64 1.6.20-1.el9 epel 65 k Transaction Summary =============================================================================================== Install 12 Packages Total download size: 30 M Installed size: 235 M ... (중략) Installed: MariaDB-client-10.11.5-1.el9.x86_64 MariaDB-common-10.11.5-1.el9.x86_64 MariaDB-server-10.11.5-1.el9.x86_64 MariaDB-shared-10.11.5-1.el9.x86_64 boost-program-options-1.75.0-8.el9.x86_64 daxctl-libs-71.1-8.el9.x86_64 galera-4-26.4.14-1.el9.x86_64 libpmem-1.12.1-1.el9.x86_64 ndctl-libs-71.1-8.el9.x86_64 perl-DBI-1.643-9.el9.x86_64 pv-1.6.20-1.el9.x86_64 socat-1.7.4.1-5.el9.x86_64 Complete!

설치가 완료되면, 다음 명령을 실행하여 MariaDB 서비스를 시작합니다.

systemctl start mariadb

MariaDB 서비스 설정하기

MariaDB 서비스가 정상적으로 시작되었는지 확인하려면, 다음 명령을 실행합니다.

systemctl status mariadb
실행 결과
● mariadb.service - MariaDB 10.11.5 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled) Drop-In: /etc/systemd/system/mariadb.service.d └─migrated-from-my.cnf-settings.conf Active: active (running) since Thu 2023-09-07 13:05:29 KST; 1min 27s ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 31027 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 31028 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS) Process: 31051 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Main PID: 31036 (mariadbd) Status: "Taking your SQL requests now..." Tasks: 9 (limit: 24648) Memory: 180.7M CPU: 235ms CGroup: /system.slice/mariadb.service └─31036 /usr/sbin/mariadbd Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] InnoDB: Fil…MiB. Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] InnoDB: log…d 14 Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] InnoDB: Loa…pool Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] Plugin 'FEE…led. Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] Server sock….0'. Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Warning] Failed t… 97. Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] /usr/sbin/m…ons. Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: Version: '10.11.5-MariaDB' socket: '/va…rver Sep 07 13:05:29 RockyLinux9 mariadbd[31036]: 2023-09-07 13:05:29 0 [Note] InnoDB: Buf…5:29 Sep 07 13:05:29 RockyLinux9 systemd[1]: Started MariaDB 10.11.5 database server. Hint: Some lines were ellipsized, use -l to show in full.

MariaDB 서비스가 정상적으로 시작되었다면, 다음 명령을 실행하여 부팅 시 자동으로 시작하도록 설정합니다.

systemctl enable mariadb
실행 결과
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

MariaDB 보안 설정하기

MariaDB 보안 설정 스크립트를 실행하여 root 비밀번호 설정, 익명 사용자 제거, 원격 root 로그인 비활성화 등의 작업을 진행합니다.

이전 버전의 MariaDB에서는 /usr/bin/mariadb-secure-installation 파일의 링크를 생성해서 mysql_secure_installation 명령을 사용할 수 있었으나, MariaDB 10.11 버전에서는 해당 링크 파일을 생성하지 않기 때문에 mariadb-secure-installation 명령을 실행합니다.

mariadb-secure-installation
실행 결과
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): Enter # root 비밀번호를 설정하지 않았으므로, 그냥 Enter 누르면 됩니다. OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody 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] y # root 비밀번호를 설정합니다. New password: 비밀번호 입력 Re-enter new password: 비밀번호 재입력 Password updated successfully! Reloading privilege tables.. ... Success! 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 # Anonymous 계정을 삭제합니다. ... 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 # 원격에서 root 로그인을 비활성화합니다. ... 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 # test 데이터베이스를 삭제합니다. - 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!

MariaDB 접속하기

MariaDB 보안 스크립트에서 설정한 root 비밀번호로 접속합니다.

mysql -u root -p
실행 결과
Enter password: 비밀번호 입력 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 11 Server version: 10.11.5-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)]>

마치며

Rocky Linux 9 서버에 MariaDB 10.11을 설치하는 방법에 대해 알아보았습니다. 이제 Rocky Linux 서버에서 MariaDB를 사용하여 데이터베이스 관리 작업을 수행할 수 있습니다.

이 글이 도움이 되셨길 바랍니다. 질문이 있으시면 언제든지 알려주세요.

인프라코디
서버, 네트워크, 보안 등 IT 인프라 관리를 하는 시스템 엔지니어로 일하고 있으며, IT 기술 정보 및 일상 정보를 기록하는 블로그를 운영하고 있습니다. 글을 복사하거나 공유 시 게시하신 글에 출처를 남겨주세요.

- 블로그 : www.infracody.com

이 글이 유익했나요? 댓글로 소중한 의견을 남겨주시거나 커피 한 잔의 선물은 큰 힘이 됩니다.
댓글