반응형

* yum 을 통해 기본 MariaDB가 설치되어 있는 상태에서 추가로 MariaDB를 1개 더 설치하는 과정입니다.

 

설치버전 : MariaDB 10.5.13-GA

다운로드 URL :

https://mariadb.org/download/?t=mariadb&p=mariadb&r=10.5.13&os=Linux&cpu=x86_64&i=systemd&m=yongbok

 

 

1. basedir 생성 후 다운받은 tar.gz 파일을 압축을 풉니다.

# mkdir /opt/mysql-10.5  <-- 여기를 mariadb 기본 디렉터리로 쓸겁니다. (위치 및 파일명 내 맘대로 정함)

# chown mysql.mysql /opt/mysql-10.5

# cd /opt/mysql-10.5

# tar -xvzf mariadb-10.5.13-linux-systemd-x86_64.tar.gz

# mv mariadb-10.5.13-linux-systemd-x86_64/* .

# rm -rf mariadb-10.5.13-linux-systemd-x86_64*

 

2. datadir 생성 

# mkdir /var/lib/mysql-10.5 <-- 여기를 data 를 저장할 디렉터리로 쓸겁니다. (위치 및 파일명 내 맘대로 정함)

# chown mysql.mysql /var/lib/mysql-10.5

 

3. cnf 설정파일 생성

# vi /etc/my-10.5.cnf <-- 기본 설정파일과 분리된 신규 설정파일. (위치 및 파일명 내 맘대로 정함)

 

[mysqld]

init_connect=SET collation_connection=utf8_general_ci

init_connect=SET NAMES utf8

character-set-server=utf8

collation-server=utf8_general_ci

table_open_cache=1024

max_connections=2048

max_user_connections=500

max_connect_errors=10000

wait_timeout=300

query_cache_type=1

query_cache_size=128M

query_cache_limit=5M

slow_query_log

long_query_time=3

max_allowed_packet=16M

sort_buffer_size=2M

skip-name-resolve

symbolic-links=0

port=3307 <-- 기존 db가 3306 쓰고 있어서 3307 포트 사용

basedir=/opt/mysql-10.5

datadir=/var/lib/mysql-10.5

socket=/var/lib/mysql-10.5/mysql.sock

 

[mysql]

default-character-set=utf8

socket=/var/lib/mysql-10.5/mysql.sock

 

[client]
socket=/var/lib/mysql-10.5/mysql.sock
port=3307


[mysqld_safe]
socket=/var/lib/mysql-10.5/mysql.sock

 

4. mariadb install

[실행]

# cd /opt/mysql-10.5

# scripts/mysql_install_db --defaults-file=/etc/my-10.5.cnf --user=mysql

 

[결과]

Installing MariaDB/MySQL system tables in '/var/lib/mysql-10.5' ...

OK

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system



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 or the

MySQL manual for more instructions.

 

You can start the MariaDB daemon with:

cd '/opt/mysql-10.5' ; /opt/mysql-10.5/bin/mysqld_safe --datadir='/var/lib/mysql-10.5'

 

You can test the MariaDB daemon with mysql-test-run.pl

cd '/opt/mysql-10.5/mysql-test' ; perl mysql-test-run.pl

 

Please report any problems at https://mariadb.org/jira

 

The latest information about MariaDB is available at https://mariadb.org/.

You can find additional information about the MySQL part at:

https://dev.mysql.com

Consider joining MariaDB's strong and vibrant community:

https://mariadb.org/get-involved/



5. 시스템 재시작 시 자동 실행 되도록 서비스 등록.

# vi /etc/systemd/system/mariadbd-10.5.service

 

[Unit]

Description=MariaDB 10.5.13 database server

After=network.target

After=syslog.target

 

[Install]

WantedBy=multi-user.target

Alias=mariadbd-10.5.service

 

[Service]

 

User=mysql

Group=mysql

 

# Execute pre and post scripts as root

PermissionsStartOnly=true

 

# Needed to create system tables etc.

#ExecStartPre=

 

# Start main service

ExecStart=/opt/mysql-10.5/bin/mariadbd-safe --defaults-file=/etc/my-10.5.cnf

 

# Don't signal startup success before a ping works

#ExecStartPost=

 

# Give up if ping don't get an answer

TimeoutSec=300

PrivateTmp=false

 

6. 서비스 활성 화 및 재시작 그리고 상태 확인

]# systemctl list-unit-files|grep mari

]# systemctl enable mariadb-10.5

 

] # systemctl daemon-reload

] # systemctl status mariadb-10.5

 

7. root 암호 설정하기

] # mysqladmin --defaults-file=/etc/my-10.5.cnf -u root password 

 

** 유의사항.

- make 부터해서 새로 컴파일을 한게 아니라서..

- 새로 설치한 mariadb 관련 명령어 실행시 항상 "--defaults-file=/etc/my-10.5.cnf" 옵션을 넣어 주어야만 한다.

 

반응형

+ Recent posts