[MariaDB] ColumnStore Engine 설치하기

devvace ㅣ 2019. 2. 14. 10:17

## 설치 전 참고사항 : ColumnStore를 설치하려면 기존에 설치되어 있는 MariaDB를 삭제해야한다.

## 참고한 사이트 : 이 사이트를 참고해서 실제 설치 및 실행을 완료함

 

 

1. MariaDB ColumnStore 설치

https://downloads.mariadb.com/ColumnStore/

 

너무 최신 버전은 버그가 있을 수 있기 때문에, 한 두단계 낮은 버전을 선택했다.

이 글에서는 rpm파일을 다운받아서 설치한 과정을 포스팅하고 있다. bin파일 설치는 해보지 않았고 참고 사이트에서 했다고 한 부분을 가져만 왔다.

 

2. Configuration 및 설치

1. Set Locate

[root@localhost~]# localedef -i en_US -f UTF-8 en_US.UTF-8

 

※ 멀티서버로 구성할 경우, 각 서버는 Hostname, IP가 설정되어 있어야 하며 각 서버의 root 비밀번호와 사용하는 non-root유저의 비밀번호가 같아야 한다.

각 서버는 SSH 접속 시에 비밀번호가 없이 접속 가능하게 SSH Key 설정이 되어 있어야 한다.

ColumnStore는 root 또는 non-root 유저로 설치가 가능하다.

 

2. Set Port

ColumnStore 데몬이 사용하는 포트는 3306이다. 여기에 ColumnStore 소프트웨어를 위해서 8600~8622, 8700, 8800 포트를 확보해야 한다.

물론 해당 포트들은 방화벽에서 열려 있어야 한다. Firewalld 서비스를 내리면 간편하겠지만 보안에 취약해지기 때문에, 필요 포트를 허용하는 정책을 넣도록 한다.

 

 

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=8600-8622/tcp

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=8700/tcp

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=8800/tcp

[root@localhost ~]# firewall-cmd --reload

 

※ DBRoots는 ColumnStore Datafile이 저장될 디렉터리이다. 그 경로는 예를 들면 /usr/local/mariadb/columnstore/data{{N}}이다(N은 DBRoot Number).

 

3. Set Network

rc.local 파일 마지막 줄에 다음 값을 세팅한다.

[root@localhost ~]# vi /etc/rc.d/rc.local

# MariaDB ColumnStore Set

 

/sbin/ifconfig eth0 txqueuelen 10000

 

/etc/sysctl.conf에 다음을 추가한다.

[root@localhost ~]# vi /etc/sysctl.conf

# MariaDB ColumnStore Set

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

 

# increase Linux autotuning TCP buffer limits

# min, default, and max number of bytes to use

net.ipv4.tcp_rmem = 4096 87380 16777216

net.ipv4.tcp_wmem = 4096 65536 16777216

 

# don't cache ssthresh from previous connection

net.ipv4.tcp_no_metrics_save = 1

 

# recomended to increase this for 1000 BT or higher

net.core.netdev_max_backlog = 2500

 

# for 10 GigE, use this

 

#net.core.netdev_max_backlog = 30000

 

4. Set vfs_cache_pressure(For Read performance)

현재 값 확인 후 다음 Reboot까지 임시적으로 변경

[root@localhost ~]# cat /proc/sys/vm/vfs_cache_pressure

 

100

[root@localhost ~]# sysctl -w vm.vfs_cache_pressure=10

 

vm.vfs_cache_presssure = 10

 

Reboot 후에도 자동적용하기 위해 sysctl.conf 파일 수정

[root@localhost ~]# vi /etc/sysctl.conf

# Read performance

 

vm.vfs_cache_pressure = 10

 

5. Set umask

MariaDB 유저가 ColumnStore의 설정 파일인 Columnstore.xml 파일을 읽기 위해서 umask가 022로 설정되어 있어야 한다. 기본적으로 /etc/profile 안에 살펴보면 umask가 022로 설정되어 있다. 만약 022가 아닐 경우 설치 전에 022로 설정하고 설치를 진행해야 한다.

[root@localhost ~]# umask 022

[root@localhost ~]# umask

 

0022

 

6. Set SELinux

/etc/selinux/config 파일에 SELINUX 값을 disabled로 변경해야 한다.

[root@localhost ~]# vi /etc/selinux/config

 

SELINUX=disabled

 

7. Install package dependencies

[root@localhost ~]# yum -y install boost

[root@localhost ~]# yum -y install wget

[root@localhost ~]# wget https://downloads.mariadb.com/ColumnStore/1.0.9/centos/x86_64/centos6_boost_1_55.tar.gz

[root@localhost ~]# tar zxvf centos6_boost_1_55.tar.gz -C /usr/lib

 

[root@localhost ~]# ldconfig

 

8. Other packages

[root@localhost ~]# yum -y install expect perl perl-DBI openssl zlib file sudo libaio rsync snappy net-tools

 

 

9. Data Redundancy packages

[root@localhost ~]# yum -y install centos-release-gluster

[root@localhost ~]# yum -y install glusterfs glusterfs-fuse glusterfs-server

[root@localhost ~]# systemctl enable glusterd

 

[root@localhost ~]# systemctl start glusterd

 

10. System logging package

ColumnStore 로그를 남기기 위해서 다음 중 하나가 설치되어 있어야 한다.

syslog, rsyslog, syslog-ng

 

※ 대부분은 rsyslog가 설치되어 있을 것이기 때문에 따로 Syslog 서비스를 설치할 필요는 없다. 다른 프로젝트 때문에 syslog-ng가 설치되어있는 서버에 ColumnStore를 설치해봤는데, 원활하게 진행되지 않았다. 추후 이 부분에 대해 따로 연구 필요

 

11. Prepare ColumnStore by root user

다음 과정을 진행하면 /usr/local/mariadb/columnstore 디렉토리에 설치가 완료된다. 설치 방법은 RPM 설치 방법과 Binary 설치 방법 두가지가 있다.

 

 (1) RPM 설치

[root@localhost ~]# tar zxvf mariadb-columnstore-1.1.2-1-centos7.x86_64.rpm.tar.gz

mariadb-columnstore-1.1.2-1-x86_64-centos7-client.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-common.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-gssapi-server.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-libs.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-platform.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-rocksdb-engine.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-server.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-shared.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-storage-engine.rpm

 

mariadb-columnstore-1.1.2-1-x86_64-centos7-tokudb-engine.rpm

[root@localhost ~]# rpm -ivh mariadb-columnstore-1.1.2-1-x86_64-centos7*.rpm

mariadb-columnstore-1.1.2-1-x86_64-centos7-tokudb-engine.rpm

 

준비 중...                         ################################# [100%]

Updating / installing...

   1:mariadb-columnstore-common-1.1.2-################################# [ 10%]

   2:mariadb-columnstore-libs-1.1.2-1 ################################# [ 20%]

MariaDB ColumnStore RPM install completed

   3:mariadb-columnstore-clien

 

 

 

t-1.1.2-################################# [ 30%]

   4:mariadb-columnstore-server-1.1.2-################################# [ 40%]

   5:mariadb-columnstore-shared-1.1.2-################################# [ 50%]

   6:mariadb-columnstore-platform-1.1.################################# [ 60%]

The next step is:

 

If installing on a pm1 node:

 

/usr/local/mariadb/columnstore/bin/postConfigure

 

If installing on a non-pm1 using the non-distributed option:

 

/usr/local/mariadb/columnstore/bin/columnstore start

 

MariaDB ColumnStore RPM install completed

   7:mariadb-columnstore-gssapi-server################################# [ 70%]

   8:mariadb-columnstore-rocksdb-engin################################# [ 80%]

   9:mariadb-columnstore-tokudb-engine################################# [ 90%]

  10:mariadb-columnstore-storage-engin################################# [100%]

 

MariaDB ColumnStore RPM install completed

 

[root@localhost ~]# /usr/local/mariadb/columnstore/bin/post-install

The next step is:

 

If installing on a pm1 node:

 

/usr/local/mariadb/columnstore/bin/postConfigure

 

If installing on a non-pm1 using the non-distributed option:

 

 

/usr/local/mariadb/columnstore/bin/columnstore start

중간에 에러가 발생하면 안된다.

 

 (2) Binary 설치 - 직접 실행해보지는 않음

[root@localhost ~]# ln -s /mnt/mariadb /usr/local

[root@localhost ~]# cp /root/mariadb-columnstore-release#.x86_64.bin.tar.gz /usr/local/ mariadb-columnstore-release#.x86_64.bin.tar.gz

 

Unpack the tarball, which will generate the /usr/local/ directory.

[root@localhost ~]# tar -zxvf mariadb-columnstore-release#.x86_64.bin.tar.gz

 

Run the post-install script:

 

[root@localhost ~]# /usr/local/mariadb/columnstore/bin/post-install

 

12. Install ColumnStore by user(Single server)

 (1) root user의 경우

 다음의 ColumnStore 설정이 끝나면 자동으로 MariaDB가 설치된다.

[root@localhost ~]# /usr/local/mariadb/columnstore/bin/postConfigure

 

This is the MariaDB ColumnStore System Configuration and Installation tool.

It will Configure the MariaDB ColumnStore System and will perform a Package

Installation of all of the Servers within the System that is being configured.

 

IMPORTANT: This tool should only be run on the Parent OAM Module

           which is a Performance Module, preferred Module #1

 

Prompting instructions:

        Press 'enter' to accept a value in (), if available or

        Enter one of the options within [], if available, or

        Enter a new value

 

===== Setup System Server Type Configuration =====

There are 2 options when configuring the System Server Type: single and multi

 

  'single'  - Single-Server install is used when there will only be 1 server configured

              on the system. It can also be used for production systems, if the plan is

              to stay single-server.

  'multi'   - Multi-Server install is used when you want to configure multiple servers now               or in the future. With Multi-Server install, you can still configure just 1 server

now and add on addition servers/modules in the future.

 

Select the type of System Server install [1=single, 2=multi] (2) > 1

Performing the Single Server Install.

 

Enter System Name (columnstore-1) > [enter]

===== Setup Storage Configuration =====

 

----- Setup Performance Module DBRoot Data Storage Mount Configuration -----

 

There are 2 options when configuring the storage: internal or external

  'internal' -    This is specified when a local disk is used for the DBRoot storage.

                  High Availability Server Failover is not Supported in this mode

  'external' -    This is specified when the DBRoot directories are mounted.

                  High Availability Server Failover is Supported in this mode.

 

Select the type of Data Storage [1=internal, 2=external] (1) > [enter]

 

Enter the list (Nx,Ny,Nz) or range (Nx-Nz) of DBRoot IDs assigned to module 'pm1' (1) > [enter]

 

===== Performing Configuration Setup and MariaDB ColumnStore Startup =====

 

NOTE: Setting 'NumBlocksPct' to 50%

      Setting 'TotalUmMemory' to 25% of total memory.

 

Running the MariaDB ColumnStore setup scripts

post-mysqld-install Successfully Completed

post-mysql-install Successfully Completed

 

Starting MariaDB Columnstore Database Platform

 

MariaDB ColumnStore Database Platform Starting, please wait ...... DONE

 

System Catalog Successfull Created

 

MariaDB ColumnStore Install Successfully Completed, System is Active

 

Enter the following command to define MariaDB ColumnStore Alias Commands

 

. /usr/local/mariadb/columnstore/bin/columnstoreAlias

 

Enter 'mcsmysql' to access the MariaDB ColumnStore SQL console

Enter 'mcsadmin' to access the MariaDB ColumnStore Admin console

 

 

NOTE: The MariaDB ColumnStore Alias Commands are in /etc/profile.d/columnstoreAlias

 

열려야할 포트들이 열려있는지 확인

[root@localhost ~]# netstat -an | grep LISTEN

tcp        0      0 0.0.0.0:8620            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8622            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8630            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8601            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8603            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8700            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8604            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8800            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8612            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8614            0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:8616            0.0.0.0:*               LISTEN

 

tcp6       0      0 :::3306                 :::*                    LISTEN

 

※ 8630의 경우에는 방화벽에서 포트허용을 하지 않았는데, 일단은 관련 포트인지는 확실하지 않으니 생각만 해놓고 있다가 차후 문제가 있으면 방화벽 허용을 고려해야 할듯

 

 (2) non-root user의 경우

 https://mariadb.com/kb/en/library/installing-and-configuring-mariadb-columnstore/

 

 

.bash_profile 맨 밑줄에 다음과 같이 추가

[root@localhost ~]# vi .bash_profile

alias mcsmysql=’/usr/local/mariadb/columnstore/mysql/bin/mysql --defaults-file=/usr/local/mariadb/columnstore/mysql/my.cnf -u root’

 

alias mcsadmin=’/usr/local/mariadb/columnstore/bin/mcsadmin’

 

13. Configure ColumnStore Alias

다음 명령어를 사용하면 mcsadmin, mcsmysql 등 alias 설정된 명령어들을 사용할 수 있음

[root@localhost ~]# . /usr/local/mariadb/columnstore/bin/columnstoreAlias

 

 

 

MariaDB ColumnStore Management Console을 사용해서 MariaDB ColumnStore 시스템 및 서버를 구성, 모니터링 및 관리할 수 있다. 자세한 내용은 MariaDB ColumnStore Administrative Console을 참조

[root@localhost ~]# mcsadmin

MariaDB ColumnStore Admin Console

   enter 'help' for list of commands

   enter 'exit' to exit the MariaDB ColumnStore Command Console

   use up/down arrows to recall commands

 

Active Alarm Counts: Critical = 0, Major = 0, Minor = 0, Warning = 0, Info = 0

 

Critical Active Alarms:

mcsadmin> getsysteminfo

getsysteminfo   Tue Feb 12 14:09:43 2019

System columnstore-1

System and Module statuses

Component     Status                       Last Status Change

------------  --------------------------   ------------------------

System        ACTIVE                       Tue Feb 12 11:45:27 2019

Module pm1    ACTIVE                       Tue Feb 12 11:45:24 2019

 

MariaDB ColumnStore Process statuses

Process             Module    Status            Last Status Change        Process ID

------------------  ------    ---------------   ------------------------  ----------

ProcessMonitor      pm1       ACTIVE            Tue Feb 12 11:44:51 2019        6001

 

 

Active Alarm Counts: Critical = 0, Major = 0, Minor = 0, Warning = 0, Info = 0

 

mcsadmin> getsystemstatus

getsystemstatus   Tue Feb 12 14:10:06 2019

System columnstore-1

System and Module statuses

Component     Status                       Last Status Change

------------  --------------------------   ------------------------

System        ACTIVE                       Tue Feb 12 11:45:27 2019

 

Module pm1    ACTIVE                       Tue Feb 12 11:45:24 2019

 

기존의 MariaDB Client와 같이 쿼리를 수행할 수 있게 해주는 SQL툴 접속

[root@localhost ~]# mcsmysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 12

Server version: 10.2.10-MariaDB-log Columnstore 1.1.2-1

 

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> show engines;

+--------------------+---------+-------------------------------+--------------+------+------------+

| Engine           | Support | Comment                | Transactions | XA   | Savepoints |

+--------------------+---------+-------------------------------+--------------+------+------------+

| Columnstore      | YES    | Columnstore storage engine | YES     | NO     | NO       |

| InnoDB           | DEFAULT | Supports transactions, row-level locking, foreign keys and encryption for tables | YES          | YES  | YES        |

+--------------------+---------+-------------------------------+--------------+------+------------+

 

10 rows in set (0.00 sec)

 

※ 참고사항

1) Configure Files

환경 설정파일 경로는 다음과 같다.

# my.cnf

/usr/local/mariadb/columnstore/mysql/my.cnf

# Columnstore.xml

 

/usr/local/mariadb/columnstore/etc/Columnstore.xml

 

2) Extent 정보 조회

예제 테이블이 다음과 같을 때,

 

 

다음의 쿼리를 사용하면 컬럼별 Extent 정보를 조회할 수 있다.

 

MariaDB [(test)]> SELECT a.table_name, a.column_name, b.min_value, b.max_value, b.max_blocks, b.data_size, c.filename, c.file_size, c.compressed_data_size

FROM information_schema.columnstore_columns a, information_schema.columnstore_extents b, information_schema.columnstore_files c WHERE a.object_id = b.object_id AND a.object_id = c.object_id ORDER BY 1, 2;

 

 

그림이 작아서 잘 안보임...

 

 

MariaDB [(test)]> call columnstore_info.table_usage(NULL, NULL);

 

 

 

 

MariaDB [test]> call columnstore_info.compression_ratio();

 

compression_ratio 옵션은 모든 압축된 범위에서, 평균 압축비율을 나타낸다.