레드햇 리눅스에 MariaDB 서버 설치하기 (feat. 오라클 무료서버)

이용규·2023년 11월 23일
0
post-thumbnail
(같은 redhat 기반인, CentOS에 대해서 작성한 https://servermon.tistory.com/166 을 참고해서 진행 및 작성했습니다.)

Oracle 무료 서버를 이용해 mariadb 서버를 구축해보겠습니다.

현재 무료 적격인 Oracle Linux는 레드햇 계열인 RHEL 기반인데, RHEL 중에서도 몇 버전인지를 먼저 확인하는 것이 필요합니다.
터미널에 cat /etc/redhat-release 를 입력하면 버전을 확인할 수 있습니다.
제 경우 Red Hat Enterprise Linux release 8.8 (Ootpa) 이라고 뜨네요.

데비안 계열인 Ubuntu에서 apt install 로 패키지를 설치하듯이,
레드햇 계열인 RHEL에서는 dnf / yum 을 이용해서 패키지를 설치합니다.
여기서 사용할 패키지 관리자는 yum 입니다.

https://mariadb.org/download/?t=repo-config 에 들어가서 자신에게 맞는 배포판(계열), 버전, 미러를 선택하면 됩니다.

distribution은 Red Hat Enterprise Linux 8,
서버 버전은 RC 직전 버전인 11.2, 그리고 미러는 적당히 지리적으로 가까운 곳인 일본의 미러인 xTom GmbH - Osaka 를 선택하겠습니다.
그러면 사진의 아래 부분처럼 설정파일이 자동생성되는데, 텍스트 복사 버튼을 이용해서 /etc/yum.repos.d 디렉터리에서 sudo vi MariaDB.repo ( nano가 익숙하다면 sudo nano MariaDB.repo )를 입력해서 복사한 텍스트를 붙여넣고 저장합니다.

그 후에 sudo yum install MariaDB-server MariaDB-client 를 입력해서 mariadb 서버와 클라이언트를 설치합니다.
몇 번 "Is this ok [y/N]: " 프롬프트로 동의를 요구하니까, y를 입력해서 진행합시다.

그러다보면 "Complete!"라고 뜨며 설치가 완료되지만,
조금 위로 올려보면 mariadb 계정에 대한 설명이 있었을 겁니다.

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 mysql@localhost, it has no password either, but
you need to be the system 'mysql' 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

요약하면,
"
두 개의 모든 권한을 가진 계정이 생성됐다.
root@localhost 계정이 만들어졌는데, 비밀번호는 없지만 이거로 접속하려면 루트 권한이 있어야 한다. 예를 들면 sudo mysql 로 접근해라.
두 번째는 mysql@localhost 이다. 이것도 비밀번호는 없지만 시스템의 mysql 유저여야 접근할 수 있다.
연결 후에는 비밀번호를 설정할 수 있고, 만약에 이 계정들에 비밀번호나 sudo 없이 사용하고 싶다면 https://mariadb.com/kb 에 가서 살펴봐라.
"
라고 하는데, 두 번째는 mysql이라는 계정을 따로 만들어야 되는 건지?
어쨌든 복잡하니까 루트 권한을 가졌다는 전제 하에 첫 번째 방식으로 합시다.

그러면 당황스러운 에러가 우릴 맞이합니다.

[opc@instance yum.repos.d]$ sudo mysql
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
ERROR 2002 (HY000): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2)

저 Can't connect 어쩌구 하는 에러는 원래는 여러 가지 원인이 있다고 하지만, 다행히도 이 경우에는 원인이 명확합니다.
mariadb 서비스가 정상적으로 실행되지 않았습니다.
systemctl start mariadb 를 입력해서 서비스를 실행합시다. (혹시 에러가 나면 sudo를 앞에 붙여서)

[opc@instance yum.repos.d]$ systemctl start mariadb
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'mariadb.service'.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ====

참고로, root 비밀번호를 설정하지 않으신 경우에는 sudo passwd로 설정할 수 있습니다.

[opc@instance yum.repos.d]$ sudo passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

그러고 나면 이제 sudo mysql을 입력하면 MariaDB 프롬프트가 뜹니다. (mysql Deprecated 라고 하니까 이제 sudo mariadb 로 접근합시다 😅)

[opc@instance yum.repos.d]$ sudo mysql
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 11.2.2-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)]>

이상으로 레드햇 계열 리눅스에서의 MariaDB 설치 방법 설명을 마치겠습니다.

감사합니다.

profile
Next.js 개발자 https://twitter.com/YG1ee

0개의 댓글