Real MariaDB (2017년)
설치 0 0 39,948

by 구루비스터디 MariaDB MariaDB설치 [2018.06.10]


2.1 다운로드

  • URL : https://downloads.mariadb.org/
  • 10.1.22가 최신 Stable 버전이다.(교재집필 당시에 5.5가 최신버전)
  • 지원OS : 윈도우, 리눅스 플랫폼 지원(x86 : 32비트, amd64: 64비트)


2.2 설치

2.2.1 윈도우 버전 설치

  • 윈도우 버전에서는 XtraDB 스토리지 엔진을 지원하지 않는다고 하니, 공부를 하는 경우 리눅스 버전 설치를 권장한다.
  • MSI 인스톨러 버전을 디폴트 설정으로 "다음"만 잘 눌러주면 설치가 끝난다.
  • zip 압축버전의 경우 압축만 풀고, my.cnf 환경설정만 하면 설치가 완료된다.


2.2.2 리눅스 버전 설치

  • RPM 버전과 tar.gz 압축버전 제공되며, 레드햇이나 CentOS의 경우 YUM이라는 자동화 패키지 툴로 설치가능하다.


2.2.2.1 RPM을 이용한 설치
RPM을 이용한 설치 방법

shell> rpm -Uvn MariaDB-10.1.22-centos7-x86_64-client.rpm
shell> rpm -Uvn MariaDB-10.1.22-centos7-x86_64-devel.rpm 
shell> rpm -Uvn MariaDB-10.1.22-centos7-x86_64-server.rpm
shell> rpm -Uvn MariaDB-10.1.22-centos7-x86_64-shared.rpm


Centos7에 YUM을 이용한 설치방법

## 설치여부 확인
[root@localhost ~]# rpm -qa|grep MariaDB
[root@localhost ~]# 

## 저장소 확인
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.oasis.onnetcorp.com
 * extras: mirror.oasis.onnetcorp.com
 * updates: mirror.oasis.onnetcorp.com
repo id                             repo name                             status
base/7/x86_64                       CentOS-7 - Base                       9,363
extras/7/x86_64                     CentOS-7 - Extras                       311
updates/7/x86_64                    CentOS-7 - Updates                    1,111
repolist: 10,785


## 저장소 추가
[root@localhost ~]# vi /etc/yum.repos.d/MariaDB.repo

## baseurl은 OS에 맞게 세팅이 필요함(http://yum.mariadb.org 에서 확인 가능함)
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1


## 추가된 저장소 확인
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.oasis.onnetcorp.com
 * extras: mirror.oasis.onnetcorp.com
 * updates: mirror.oasis.onnetcorp.com
repo id                                              repo name                                              status
base/7/x86_64                                        CentOS-7 - Base                                        9,363
extras/7/x86_64                                      CentOS-7 - Extras                                        311
mariadb                                              MariaDB                                                   15
updates/7/x86_64                                     CentOS-7 - Updates                                     1,126
repolist: 10,815



## 설치
[root@localhost ~]# yum install -y MariaDB MariaDB-server MariaDB-client

==================================================================================================================
 Package                         Arch              Version                               Repository          Size
==================================================================================================================
Installing:
 MariaDB-client                  x86_64            10.1.22-1.el7.centos                  mariadb             39 M
 MariaDB-server                  x86_64            10.1.22-1.el7.centos                  mariadb            101 M
Updating:
 dracut                          x86_64            033-463.el7                           base               317 k
 initscripts                     x86_64            9.49.37-1.el7                         base               431 k
Installing for dependencies:
 MariaDB-common                  x86_64            10.1.22-1.el7.centos                  mariadb            123 k
 galera                          x86_64            25.3.19-1.rhel7.el7.centos            mariadb            8.0 M
 jemalloc                        x86_64            3.6.0-1.el7                           mariadb            104 k
Updating for dependencies:
 dracut-config-rescue            x86_64            033-463.el7                           base                54 k
 dracut-network                  x86_64            033-463.el7                           base                96 k
 glib2                           x86_64            2.46.2-4.el7                          base               2.3 M
 glib2-devel                     x86_64            2.46.2-4.el7                          base               459 k
 kmod                            x86_64            20-9.el7                              base               115 k
 libgudev1                       x86_64            219-30.el7_3.7                        updates             76 k
 libgudev1-devel                 x86_64            219-30.el7_3.7                        updates             88 k
 systemd                         x86_64            219-30.el7_3.7                        updates            5.2 M
 systemd-devel                   x86_64            219-30.el7_3.7                        updates            179 k
 systemd-libs                    x86_64            219-30.el7_3.7                        updates            369 k
 systemd-python                  x86_64            219-30.el7_3.7                        updates            109 k
 systemd-sysv                    x86_64            219-30.el7_3.7                        updates             63 k

Transaction Summary
==================================================================================================================
Install  2 Packages (+ 3 Dependent packages)
Upgrade  2 Packages (+12 Dependent packages)

...............  중 략 ..............


Installed:
  MariaDB-client.x86_64 0:10.1.22-1.el7.centos            MariaDB-server.x86_64 0:10.1.22-1.el7.centos           

Dependency Installed:
  MariaDB-common.x86_64 0:10.1.22-1.el7.centos             galera.x86_64 0:25.3.19-1.rhel7.el7.centos            
  jemalloc.x86_64 0:3.6.0-1.el7                           

Updated:
  dracut.x86_64 0:033-463.el7                          initscripts.x86_64 0:9.49.37-1.el7                         

Dependency Updated:
  dracut-config-rescue.x86_64 0:033-463.el7                  dracut-network.x86_64 0:033-463.el7                  
  glib2.x86_64 0:2.46.2-4.el7                                glib2-devel.x86_64 0:2.46.2-4.el7                    
  kmod.x86_64 0:20-9.el7                                     libgudev1.x86_64 0:219-30.el7_3.7                    
  libgudev1-devel.x86_64 0:219-30.el7_3.7                    systemd.x86_64 0:219-30.el7_3.7                      
  systemd-devel.x86_64 0:219-30.el7_3.7                      systemd-libs.x86_64 0:219-30.el7_3.7                 
  systemd-python.x86_64 0:219-30.el7_3.7                     systemd-sysv.x86_64 0:219-30.el7_3.7   

## 마리아 디비 실행
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# ps -ef|grep mysql
mysql     7759     1  1 18:06 ?        00:00:00 /usr/sbin/mysqld
root      7874  5300  0 18:06 pts/0    00:00:00 grep --color=auto mysql



## 루트 패스워드 설정
[root@localhost ~]# mysql_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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
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
 ... 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] n
 ... skipping.

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
 - 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!

## 서비스에 등록하기(설정하면 부팅시 자동 기동된다.)
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# systemctl is-enabled mariadb
enabled



2.2.2.2 압축(tar.gz)된 MariaDB설치
  • 압축을 풀고 my.cnf만 설정하면 설치 완료


2.3 업그레이드

2.3.1 MySQL -> MariaDB로 업그레이드할 때 주의사항

  • 임시 테이블 스토리지 엔진이 MySQL은 MyISAM, MariaDB는 Aria 를 사용하므로 아래와 같이 설정이 필요
aria-pagecache-buffer-size = 64M
  • 마스터와 슬레이브 MySQL 서버를 각각 업그레이드 할 경우, MariaDB의 바이너리 로그를 MySQL서버에서 인식못하는 경우가 있으므로 슬레이브를 먼저 업그레이드 하도록 하자.


2.3.2 버전과 관계없이 가장 안전한 방법

  • mysqldump와 같은 백업툴을 이용한다.(ANSI 쿼리문을 생성해주므로, 모든 버전으로 마이그레이션 가능)

1. shell > mysqldump -u root -p --all-database > backup.dump
2. MariaDB설치
3. shell > mysql -u root -p < backup.dump
4. shell > mysql_upgrade --verbose   (딕셔너리 테이블 구조를 MariaDB에 맞게 업그레이드 해주는 작업)


2.3.3 MySQL 5.1 -> MariaDB 5.5 업그레이드

  • 데이터 포맷의 변화가 거의 없으므로 데이터 파일을 그대로 둔채, MySQL를 삭제하고 MariaDB 설치, mysql_upgrade를 실행한다.


2.3.4 MySQL 5.5 -> MariaDB 5.5 업그레이드

  • 데이터 포맷 및 딕셔너리 정보도 동일하므로 데이터 파일은 그대로 둔채, MySQL만 삭제하고 MariaDB만 설치한다.
"구루비 데이터베이스 스터디모임" 에서 2017년에 "Real MariaDB" 도서를 스터디하면서 정리한 내용 입니다.

- 강좌 URL : http://www.gurubee.net/lecture/3768

- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^

- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입