2017년 6월 19일 월요일

Expert Cube Development with SSAS - 3장

3장 Designing More Complex Dimensions

. Grouping
차원 중에서 속성도 별로 없으면서 키값이 엄청 많은 차원들에 사용하면 유용

DiscretizationMethod와 DiscretizationBucketCount 속성을 사용하면 자동으로 Grouping을 지원하며 아래와 같은 모양이 나온다.

적당하게 그룹핑을 해주는데 사실 이게 맘에 안들면 걍 SQL을 이용해서 별도 속성을 만들면 원하는대로 만들 수 있다.

CASE WHEN Weight IS NULL OR Weight<0 THEN 'N/A'
WHEN Weight<10 THEN '0-10Kg'
WHEN Weight<20 THEN '10-20Kg'
ELSE '20Kg or more'
END

이런 식으로...

. Banding
Grouping은 차원에서의 그룹화라면 Banding은 Fact를 건드려서 만들어내는 그룹화 방법이다. 그래서 자연스럽게 Grouping은 차원의 키의 개수나 값은 변화가 없지만 Banding은 변화가 온다.

Banding은 Band를 묶는 조건을 고객이 바꾸길 원할때 팩트 테이블을 전부 다시 말아야 하는 불상사가 생길 수 있는데 다음과 같은 경우다.


왼쪽이 팩트고 오른 쪽이 디멘전인데 OR값을 그냥 Surrogate키로 의미없이 땄을때 만약 9815값이 MEDIUM이었다가 LOW라고 정의를 바꾸려면 팩트테이블의 OR컬럼을 모두 2에서 1로 UPDATE가 들어간다.





이 때 디멘전의 Surrogate키를 만약 의미를 가지고 따게 되면 (가령 Order Value/100) 대리키 RANGE정의가 바뀌더라도 차원만 UPDATE하게 되므로 간편하다!


. Modeling Slowly Changing Dimension
차원의 속성이 변하지 않는다면 좋겠지만... 그런일은 일어나지 않는다. 속성이 변하는 차원을 관리하기 위한 대표적인 모델링 기법을 SCD I~III 이라고 부른다. 실제로는 한 차원안에서도 속성 별로 1~3유형이 달라지도록 모델링해야 할 수 있다.

. Type I SCDs
가장 흔하고 가장 간단하고 별로 할일이 없다. 속성이 변하면 그냥 단순히 과거의 값을 UPDATE하고 끝난다. RDB의 집계테이블이라면 모든 집계테이블을 재집계해야겠지만 Analysis Services는 그럴 필요가 없이 차원만 UPDATE해주면 된다.
항상 현재기준의 속성값으로 과거 팩트가 제공된다.
(다만 집계디자인을 사용하는 경우에는 집계테이블과 마찬가지 원리로 집계값들이 DROP된다.)

만약 해당 팩트가 발생한 시점의 차원의 속성값을 알고 싶다면 Type I을 사용해선 안된다.
가장 흔한 예로 주문한 "고객의 주소 별 주문액" 값이라면 고객차원의 주소는 항상 현재 주소를 가지고 있으므로 주문 당시의 주소별 주문액은 Type I으로는 알수가 없는 것이다.

Type I의 속성값들은 MDX쿼리에서 함부로 사용해서는 안된다. 값이 변경되면 무의미해질 수 있다.

. Type II SCDs
차원의 속성이 변하는 이력을 모두 관리하는 모델링 기법이다. Surrogate키가 필수적으로 요구되고 다음 3가지 컬럼이 일반적으로 항상 요구된다.

1. Current/Pervious 여부컬럼
2. 유효시작일시
3. 유효종료일시

Surrogate키는 고객이 보기에는 의미없는 컬럼이므로 AttributeHierarchyVisibleState속성은 False로 둔다. 그리고 특성관계에서 실제 의미를 가지는 키값으로 집계구조를 생성한다.


그리고 시점별로 달라지는 속성들을 위해서 또 고객에게 노출되지 않는 중간집계컬럼을 둬서 쿼리 속도를 향상시킬 수 있다.




. Type III SCDs
현재 속성 값과 직전(또는 최초) 속성 값 2가지만을 가지는 차원인데 실제로는 쓸일이 거의 없다. 특성관계만 보고 넘어가자



. Modeling junk dimension
속성이 달랑 1개이고 속성값도 몇개가 안되는 자잘한 차원들이 설계하다보면 많이 나오는데 이를 모두 별도의 차원으로 할 경우... 성능에도 안좋고 고객도 사용하기 어렵다.
이런 차원들을 모아서 1개의 차원으로 만드는 것을 junk dimension이라고 한다.

보통 팩트테이블을 가지고 가능한 조합을 추출해내고 Surrogate키를 따서 하나의 차원테이블을 만들어서 구현한다. Surrogate키는 역시 고객에게는 Visible False이다.

junk 차원에서 일부 차원이 분리되어 나가거나 할때는 기존 팩트값에 꽂힌 Surrogate키가 충돌이나거나 하지 않게 세심하게 작업해야 한다.

. Modeling ragged hierarchies
레벨깊이가 일정하지 않은 부모/자식구조를 갖는 차원을 말한다.
재귀적으로 부모/자식 관계를 갖는 테이블이 대표적인데 정해진 level depth가 정해져 있지 않기 때문에 골치 덩어리다.


- Usage 속성값이 Parent인 컬럼이 부모컬럼이다.
- NamingTempate속성값으로 레벨이름을 명명할 수 있다. (예: 대;중;소;세)

사용자계층에 대해서 HideMemberIf 속성을 사용하면 재귀테이블이 아니더라도 Ragged hierarchies를 표현할 수 있는데 테이블 구조는 다음과 같다.

테이블 구조


특정 레벨 이하의 리프가 상위 값을 가진다.

생성된 계층

위와 같이 상위값이 다른 경우 Level이 하나씩 당겨지는 방식이다.

두번째 방법이 조금 낫긴 하지만 ragged hierarchies는 최대한 피해야 한다.
쿼리속도, 처리속도, 설계난이도, MDX개발 난이도 어느 것 하나 좋지 않다.
집계디자인도 필수적으로 IsAggregateable: False처리하라.

2017년 6월 17일 토요일

CentOS 7에서 postgresql 9.4 설치


1. rpm다운로드 
centos기본은 9.2 라서 rpm다운로드 받는다.
링크: https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/repoview/postgresqldbserver94.group.html

서버는 파일은 4개 모두 설치하고 클라이언트만 필요하면 다음 2개를 설치한다.
postgresql94 - PostgreSQL client programs and libraries
postgresql94-libs - The shared libraries required for any PostgreSQL clients

# mkdir rpms-postgres
[root@bidevdruidm2 data01]# cd rpms-postgres
[root@bidevdruidm2 rpms]# ls -al
total 5852
drwxr-xr-x 2 root root     226 2017-06-17 21:31 .
drwxrwxrwx 3 root root      18 2017-06-17 21:31 ..
-rw-r--r-- 1 root root 1099988 2017-06-17 21:29 postgresql94-9.4.12-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root  632648 2017-06-17 21:29 postgresql94-contrib-9.4.12-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root  217156 2017-06-17 21:29 postgresql94-libs-9.4.12-1PGDG.rhel7.x86_64.rpm
-rw-r--r-- 1 root root 4031756 2017-06-17 21:29 postgresql94-server-9.4.12-1PGDG.rhel7.x86_64.rpm
[root@bidevdruidm2 rpms]# rpm -ivh postgresql94*
warning: postgresql94-9.4.12-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql94-libs-9.4.12-1PGDG.rh################################# [ 25%]
   2:postgresql94-9.4.12-1PGDG.rhel7  ################################# [ 50%]
   3:postgresql94-contrib-9.4.12-1PGDG################################# [ 75%]
   4:postgresql94-server-9.4.12-1PGDG.################################# [100%]



2. data directory설정

# vi /usr/lib/systemd/system/postgresql-9.4.service
Environment=PGDATA=/data01/pgsql/data

3. data directory생성

# su postgres
bash-4.2$ mkdir -p /data01/pgsql/data
bash-4.2$ ls -al
total 0
drwxrwxrwx   4 root     root      31 Jun 17 22:01 .
dr-xr-xr-x. 18 root     root     258 Jun 15 17:41 ..
drwxr-xr-x   3 postgres postgres  18 Jun 17 22:01 pgsql

4. db생성

# find / -name post*setup

/usr/pgsql-9.4/bin/postgresql94-setup
# cd /usr/pgsql-9.4/bin/
# ./postgresql94-setup initdb
Initializing database ... OK

# cat /var/lib/pgsql/9.4/initdb.log
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data01/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /data01/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data/
or
    /usr/pgsql-9.4/bin/pg_ctl -D /data01/pgsql/data/ -l logfile start


5. 기동
# systemctl enable postgresql-9.4
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.4.service to /usr/lib/systemd/system/postgresql-9.4.service.
[root@bidevdruidm2 bin]# systemctl start postgresql-9.4
[root@bidevdruidm2 bin]# systemctl status postgresql-9.4
● postgresql-9.4.service - PostgreSQL 9.4 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-06-17 22:14:39 KST; 4s ago
  Process: 3255 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 3248 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/postgresql-9.4.service
           ├─3257 /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data
           ├─3259 postgres: logger process
           ├─3261 postgres: checkpointer process
           ├─3262 postgres: writer process
           ├─3263 postgres: wal writer process
           ├─3264 postgres: autovacuum launcher process
           └─3265 postgres: stats collector process

Jun 17 22:14:38 bidevdruidm2.bidevclust systemd[1]: Starting PostgreSQL 9.4 database server...
Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.235 KST >LOG:  could not bind IPv6 socket: Canno...dress
Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.235 KST >HINT:  Is another postmaster already ru...etry.
Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.247 KST >LOG:  redirecting log output to logging...ocess
Jun 17 22:14:38 bidevdruidm2.bidevclust pg_ctl[3255]: < 2017-06-17 22:14:38.247 KST >HINT:  Future log output will appear in...log".
Jun 17 22:14:39 bidevdruidm2.bidevclust systemd[1]: Started PostgreSQL 9.4 database server.
Hint: Some lines were ellipsized, use -l to show in full.
# su - postgres
Last login: Sat Apr 15 13:42:39 KST 2017 on pts/0
-bash-4.2$ psql
psql (9.2.18)
Type "help" for help.

postgres=#




6. 인증 방식 변경
# su postgres
bash-4.2$ psql
psql (9.4.12)
Type "help" for help.

postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
bash-4.2$ exit
exit


# vi /data01/pgsql/data/pg_hba.conf
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             0.0.0.0/0            md5
# IPv6 local connections:
host    all             all             ::1/128               md5



7. listen ip 설정
# cp /data01/pgsql/data/postgresql.conf /data01/pgsql/data/postgresql.conf.bak
# vi /data01/pgsql/data/postgresql.conf
listen_addresses = '*' 



8. 서버 기동
# systemctl restart postgresql-9.4
# systemctl status postgresql-9.4
● postgresql-9.4.service - PostgreSQL 9.4 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-06-17 22:21:48 KST; 3s ago
  Process: 3331 ExecStop=/usr/pgsql-9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast (code=exited, status=0/SUCCESS)
  Process: 3340 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 3333 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 3342 (postgres)
   CGroup: /system.slice/postgresql-9.4.service
           ├─3342 /usr/pgsql-9.4/bin/postgres -D /data01/pgsql/data
           ├─3343 postgres: logger process
           ├─3345 postgres: checkpointer process
           ├─3346 postgres: writer process
           ├─3347 postgres: wal writer process
           ├─3348 postgres: autovacuum launcher process
           └─3349 postgres: stats collector process

Jun 17 22:21:47 bidevdruidm2.bidevclust systemd[1]: Starting PostgreSQL 9.4 database server...
Jun 17 22:21:47 bidevdruidm2.bidevclust pg_ctl[3340]: < 2017-06-17 22:21:47.576 KST >LOG:  redirecting log output to logging...ocess
Jun 17 22:21:47 bidevdruidm2.bidevclust pg_ctl[3340]: < 2017-06-17 22:21:47.576 KST >HINT:  Future log output will appear in...log".
Jun 17 22:21:48 bidevdruidm2.bidevclust systemd[1]: Started PostgreSQL 9.4 database server.

Hint: Some lines were ellipsized, use -l to show in full.


2017년 6월 14일 수요일

CentOS 7 에 mariadb 10.2 설치

Bigdata환경에서 Hive, HCatalog, Oozie, Ambari 등의 콤포넌트들의 모두 metastore공간으로 db를 요구한다. 그때마다 모두 dbms를 따로 설치할 수는 없는 노릇이라 1개의 dbms를 공유하기로 했다.

mariadb 10.2 설치하기로 했다.
centos 7.3에는 기본으로 mariadb 5.5 yum으로 설치가능하지만 호환성 이슈로 mariadb 10이상으로 사용하려고 한다.

참조: https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.6.0/bk_support-matrices/content/ch_matrices-ambari.html#ambari_database

설치 참조는 아래 링크로 진행해본다.
https://mariadb.com/kb/en/mariadb/yum/
https://mariadb.com/kb/en/mariadb/installing-mariadb-with-the-rpm-tool/

. yum repository 구축

rpm 파일 각각은 상호 dependency가 강하게 걸려 있어서 yum설치를 권장한다고 한다.
그래서 repository서버에 아래와 같이 구축하였다.


# tar xvf mariadb-10.2.6-rhel-7-x86_64-rpms.tar
mariadb-10.2.6-rhel-7-x86_64-rpms/

mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-compat.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-gssapi-server.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-connect-engine.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-client.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-oqgraph-engine.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-devel.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-rocksdb-engine.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-tokudb-engine.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-shared.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-common.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-aws-key-management.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-server.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/jemalloc-3.6.0-1.el7.x86_64.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/jemalloc-devel-3.6.0-1.el7.x86_64.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/galera-25.3.20-1.rhel7.el7.centos.x86_64.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/MariaDB-10.2.6-centos7-x86_64-cracklib-password-check.rpm
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/c1f44a52d7d023900020554941585e7b8c5335f956a7d8e4a46d7e3491284f9e-primary.xml.gz
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/b5a1f4d073313dfa8d33c0f0814df18fecca52fb6987671ca37ae5ea35cb3e4b-filelists.xml.gz
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/be5067c14da550275f26f13e0289b745ff0d4641c9528c8068b9f67d5a5194e9-other.xml.gz
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/repomd.xml
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/8ba0e9ad51e831a3ddfb021e50285ac06c0abd82fb1b1cd6a930e96f20dbcf78-other.sqlite.bz2
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/d0993a2fc77a0387a369912f674f38fc0ed2384d1ffe447f28f466b74b3168ab-filelists.sqlite.bz2
mariadb-10.2.6-rhel-7-x86_64-rpms/repodata/f86661565f4fcb19eb63d74c4d8417f8e85e9db4e33a38c5052b45fef59ae699-primary.sqlite.bz2
mariadb-10.2.6-rhel-7-x86_64-rpms/README
mariadb-10.2.6-rhel-7-x86_64-rpms/setup_repository

# ./setup_repository
Repository file successfully created! Please install MariaDB Server with this command:

   yum install MariaDB-server

# cd /var/www/html
# ln -s /data01/mariadb-10.2.6-rhel-7-x86_64-rpms mariadb-10.2.6-rhel-7-x86_64-rpms
# cat /etc/yum.repos.d/mariadb.repo
[MariaDB]
name = MariaDB
baseurl = file:///data01/mariadb-10.2.6-rhel-7-x86_64-rpms
gpgkey = https://downloads.mariadb.com/MariaDB/yum/RPM-GPG-KEY-MariaDB

. gpgkey파일 생성

인터넷이 끊긴 서버를 가정하여 설치하고 있다. gpgkey는 다운로드하여 내용을 복붙하여 생성한다.

# cd /var/www/html/mariadb-10.2.6-rhel-7-x86_64-rpms
# mkdir RPM-GPG-KEY
# cd RPM-GPG-KEY/
# vi RPM-GPG-KEY-MariaDB
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)

mQGiBEtohJARBACxvZpWSIMTp/e7BUzSW+WDL7Pl0JDg6v7ZJFGJk9qo+5JXIiis
....

. 설치할 서버에 repo 정보 세팅

위의 repository서버의 mariadb.repo정보를 참조하여 설정한다.
gpgkey는 다운로드하여 복사하여 붙여넣어 파일을 생성한다.

# vi /etc/yum.repos.d/mariadb.repo
[MariaDB]
name = MariaDB
baseurl = http://x.x.x.x/mariadb-10.2.6-rhel-7-x86_64-rpms
gpgkey = http://x.x.x.x/mariadb-10.2.6-rhel-7-x86_64-rpms/RPM-GPG-KEY/RPM-GPG-KEY-MariaDB

# yum list 'MariaDB*' --disablerepo=* --enablerepo=MariaDB
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
mariadb-libs.x86_64                             1:5.5.52-1.el7                @anaconda
Available Packages
MariaDB-aws-key-management.x86_64               10.2.6-1.el7.centos           MariaDB
MariaDB-client.x86_64                           10.2.6-1.el7.centos           MariaDB
MariaDB-common.x86_64                           10.2.6-1.el7.centos           MariaDB
MariaDB-compat.x86_64                           10.2.6-1.el7.centos           MariaDB
MariaDB-connect-engine.x86_64                   10.2.6-1.el7.centos           MariaDB
MariaDB-cracklib-password-check.x86_64          10.2.6-1.el7.centos           MariaDB
MariaDB-devel.x86_64                            10.2.6-1.el7.centos           MariaDB
MariaDB-gssapi-server.x86_64                    10.2.6-1.el7.centos           MariaDB
MariaDB-oqgraph-engine.x86_64                   10.2.6-1.el7.centos           MariaDB
MariaDB-rocksdb-engine.x86_64                   10.2.6-1.el7.centos           MariaDB
MariaDB-server.x86_64                           10.2.6-1.el7.centos           MariaDB
MariaDB-shared.x86_64                           10.2.6-1.el7.centos           MariaDB
MariaDB-tokudb-engine.x86_64                    10.2.6-1.el7.centos           MariaDB

. yum으로 설치

dependency에서 perf, rsync 관련 패키지가 추가로 설치된다.

# yum install MariaDB-server MariaDB-client
...
Dependencies Resolved

=====================================================================================================================================================
 Package                                    Arch                      Version                                       Repository                  Size
=====================================================================================================================================================
Installing:
 MariaDB-client                             x86_64                    10.2.6-1.el7.centos                           MariaDB                     48 M
 MariaDB-compat                             x86_64                    10.2.6-1.el7.centos                           MariaDB                    2.8 M
     replacing  mariadb-libs.x86_64 1:5.5.52-1.el7
 MariaDB-server                             x86_64                    10.2.6-1.el7.centos                           MariaDB                    108 M
Installing for dependencies:
 MariaDB-common                             x86_64                    10.2.6-1.el7.centos                           MariaDB                    197 k
 boost-program-options                      x86_64                    1.53.0-26.el7                                 birepos                    156 k
 galera                                     x86_64                    25.3.20-1.rhel7.el7.centos                    MariaDB                    8.0 M
 lsof                                       x86_64                    4.87-4.el7                                    birepos                    331 k
 perl-Compress-Raw-Bzip2                    x86_64                    2.061-3.el7                                   birepos                     32 k
 perl-Compress-Raw-Zlib                     x86_64                    1:2.061-4.el7                                 birepos                     57 k
 perl-DBI                                   x86_64                    1.627-4.el7                                   birepos                    802 k
 perl-Data-Dumper                           x86_64                    2.145-3.el7                                   birepos                     47 k
 perl-IO-Compress                           noarch                    2.061-2.el7                                   birepos                    260 k
 perl-Net-Daemon                            noarch                    0.48-5.el7                                    birepos                     51 k
 perl-PlRPC                                 noarch                    0.2020-14.el7                                 birepos                     36 k
 rsync                                      x86_64                    3.0.9-17.el7                                  birepos                    360 k

Transaction Summary
=====================================================================================================================================================
Install  3 Packages (+12 Dependent packages)
...
...
chown: invalid user: ‘mysql’

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h bidevdruidm2.bidevclust password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

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

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  Erasing    : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                              16/16
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                       1/16
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                2/16
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                              3/16
  Verifying  : lsof-4.87-4.el7.x86_64                                                                                                           4/16
  Verifying  : MariaDB-client-10.2.6-1.el7.centos.x86_64                                                                                        5/16
  Verifying  : MariaDB-compat-10.2.6-1.el7.centos.x86_64                                                                                        6/16
  Verifying  : boost-program-options-1.53.0-26.el7.x86_64                                                                                       7/16
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                  8/16
  Verifying  : galera-25.3.20-1.rhel7.el7.centos.x86_64                                                                                         9/16
  Verifying  : MariaDB-common-10.2.6-1.el7.centos.x86_64                                                                                       10/16
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                     11/16
  Verifying  : MariaDB-server-10.2.6-1.el7.centos.x86_64                                                                                       12/16
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                     13/16
  Verifying  : rsync-3.0.9-17.el7.x86_64                                                                                                       14/16
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                             15/16
  Verifying  : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                              16/16

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

Dependency Installed:
  MariaDB-common.x86_64 0:10.2.6-1.el7.centos      boost-program-options.x86_64 0:1.53.0-26.el7      galera.x86_64 0:25.3.20-1.rhel7.el7.centos
  lsof.x86_64 0:4.87-4.el7                         perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7      perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7                    perl-Data-Dumper.x86_64 0:2.145-3.el7             perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7              perl-PlRPC.noarch 0:0.2020-14.el7                 rsync.x86_64 0:3.0.9-17.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.52-1.el7

. data폴더 변경하여 설치하기

# mkdir -p /data01/mysql
# cd /data01/mysql
# chown mysql:mysql .

# cd /usr/bin
# ./mysql_install_db --datadir=/data01/mysql --user=mysql
Installing MariaDB/MySQL system tables in '/data01/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h bidevdruidm2.bidevclust password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/data01/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

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

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

. 기본 설정 파일 변경

# vi /etc/my.cnf.d/server.cnf
[mysqld]
...
datadir = /data01/mysql
character_set_server=utf8

. 초기 root 비밀번호 설정

# systemctl enable mariadb
# systemctl start mariadb
# ./mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      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] y
 ... 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
 - 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!

. 서버 설치 환경 확인

# mysql -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.2.6-MariaDB MariaDB Server

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 VARIABLES WHERE Variable_Name LIKE "%dir";
+---------------------------+----------------------------+
| Variable_name             | Value                      |
+---------------------------+----------------------------+
| aria_sync_log_dir         | NEWFILE                    |
| basedir                   | /usr/                      |
| character_sets_dir        | /usr/share/mysql/charsets/ |
| datadir                   | /data01/mysql/             |
| innodb_data_home_dir      |                            |
| innodb_log_arch_dir       |                            |
| innodb_log_group_home_dir | ./                         |
| innodb_tmpdir             |                            |
| lc_messages_dir           |                            |
| plugin_dir                | /usr/lib64/mysql/plugin/   |
| slave_load_tmpdir         | /tmp                       |
| tmpdir                    | /tmp                       |
| wsrep_data_home_dir       | /data01/mysql/             |
+---------------------------+----------------------------+
13 rows in set (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES WHERE Variable_Name LIKE "%character%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

. 원격접속 허용하기

원하는 경우 아래와 같이 root계정의 원격접속을 허용할 수 있다.
# mysql -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.2.6-MariaDB MariaDB Server

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)]> select host,user from mysql.user;
+---------------------------+------+
| host                      | user |
+---------------------------+------+
| 127.0.0.1                 | root |
| ::1                       | root |
| bidevkylint1.bikylinclust | root |
| localhost                 | root |
+---------------------------+------+

4 rows in set (0.00 sec)

MariaDB [(none)]> CREATE USER 'root'@'%' IDENTIFIED BY '비밀번호';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
MariaDB [(none)]> FLUSH PRIVILEGES;