Post List

2016년 11월 3일 목요일

CentOS7 에서 MariaDB 10.0 설치 하기.

1. yum repository 에 mariadb 저장소 추가

[root@binrang-db yum.repos.d]# pwd
/etc/yum.repos.d
[root@binrang-db yum.repos.d]# vi MariaDB.repo
# MariaDB 10.0 CentOS repository list - created 2016-11-03 04:33 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1



2. yum을 이용하여 아래와 같이 설치한다.

[root@binrang-db ~]# yum install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror, langpacks
mariadb                                                                                              | 2.9 kB  00:00:00     
mariadb/primary_db                                                                                   |  21 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.oasis.onnetcorp.com
 * extras: mirror.oasis.onnetcorp.com
 * updates: mirror.oasis.onnetcorp.com
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.0.28-1.el7.centos will be installed
--> Processing Dependency: MariaDB-common for package: MariaDB-client-10.0.28-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.0.28-1.el7.centos will be installed
--> Running transaction check
---> Package MariaDB-common.x86_64 0:10.0.28-1.el7.centos will be installed
--> Processing Conflict: MariaDB-common-10.0.28-1.el7.centos.x86_64 conflicts mariadb-libs < 1:10.0.28-1.el7.centos
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package MariaDB-shared.x86_64 0:10.0.28-1.el7.centos will be obsoleting
---> Package mariadb-libs.x86_64 1:5.5.50-1.el7_2 will be obsoleted
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================
 Package                        Arch                   Version                                Repository               Size
============================================================================================================================
Installing:
 MariaDB-client                 x86_64                 10.0.28-1.el7.centos                   mariadb                  10 M
 MariaDB-server                 x86_64                 10.0.28-1.el7.centos                   mariadb                  55 M
 MariaDB-shared                 x86_64                 10.0.28-1.el7.centos                   mariadb                 1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.50-1.el7_2
Installing for dependencies:
 MariaDB-common                 x86_64                 10.0.28-1.el7.centos                   mariadb                  43 k
Transaction Summary
============================================================================================================================
Install  3 Packages (+1 Dependent package)
Total download size: 66 M
Is this ok [y/d/N]: y
Downloading packages:
경고: /var/cache/yum/x86_64/7/mariadb/packages/MariaDB-10.0.28-centos7-x86_64-common.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
Public key for MariaDB-10.0.28-centos7-x86_64-common.rpm is not installed
(1/4): MariaDB-10.0.28-centos7-x86_64-common.rpm                                                     |  43 kB  00:00:01     
(2/4): MariaDB-10.0.28-centos7-x86_64-client.rpm                                                     |  10 MB  00:00:08     
(3/4): MariaDB-10.0.28-centos7-x86_64-shared.rpm                                                     | 1.2 MB  00:00:01     
(4/4): MariaDB-10.0.28-centos7-x86_64-server.rpm                                                     |  55 MB  00:00:24     
----------------------------------------------------------------------------------------------------------------------------
Total                                                                                       2.6 MB/s |  66 MB  00:00:25     
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid     : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
 From       : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]:  y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : MariaDB-common-10.0.28-1.el7.centos.x86_64                                                               1/5 
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  Installing : MariaDB-client-10.0.28-1.el7.centos.x86_64                                                               2/5 
  Installing : MariaDB-server-10.0.28-1.el7.centos.x86_64                                                               3/5 
  Installing : MariaDB-shared-10.0.28-1.el7.centos.x86_64                                                               4/5 
  Erasing    : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                                                                     5/5 
  Verifying  : MariaDB-common-10.0.28-1.el7.centos.x86_64                                                               1/5 
  Verifying  : MariaDB-shared-10.0.28-1.el7.centos.x86_64                                                               2/5 
  Verifying  : MariaDB-server-10.0.28-1.el7.centos.x86_64                                                               3/5 
  Verifying  : MariaDB-client-10.0.28-1.el7.centos.x86_64                                                               4/5 
  Verifying  : 1:mariadb-libs-5.5.50-1.el7_2.x86_64                                                                     5/5 
Installed:
  MariaDB-client.x86_64 0:10.0.28-1.el7.centos                 MariaDB-server.x86_64 0:10.0.28-1.el7.centos                
  MariaDB-shared.x86_64 0:10.0.28-1.el7.centos                
Dependency Installed:
  MariaDB-common.x86_64 0:10.0.28-1.el7.centos                                                                              
Replaced:
  mariadb-libs.x86_64 1:5.5.50-1.el7_2                                                                                      
Complete!
[root@binrang-db ~]# 

3. 환경설정 파일을 Copy 한다

[root@binrang-db ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@binrang-db ~]# 

4. 언어설정 부분을 my.cnf에 추가한다.

[root@binrang-db ~]# vi /etc/my.cnf
# Example MariaDB config file for medium systems.
#
.....
[mysqld]
# 여기 언어 설정 부분을 추가한다.
character-set-server=utf8
collation-server=utf8_general_ci
port            = 3306
......

5. mariadb 를 실행한다.

[root@binrang-db ~]# service mysql start
Starting MySQL. SUCCESS! 
[root@binrang-db ~]# 

6. mariadb 를 서비스에 등록한다.

[root@binrang-db ~]# chkconfig mysql on
[root@binrang-db ~]# 
[root@binrang-db ~]# chkconfig --list
알림: 이 출력 결과에서는 SysV 서비스만을 보여주며 기존의 systemd 서비스는 
포함되어 있지 않습니다. SysV 설정 데이터는 기존의 systemd  설정에 의해 
덮어쓰기될 수 있습니다. 
      'systemctl list-unit-files'를 사용하여 systemd 서비스를 나열합니다.
       특정 대상에 활성화된 서비스를 확인하려면
       'systemctl list-dependencies [target]'을 사용합니다.
mysql              0:해제    1:해제    2:활성    3:활성    4:활성    5:활성    6:해제
network            0:해제    1:해제    2:활성    3:활성    4:활성    5:활성    6:해제
[root@binrang-db ~]# 

7. mariadb security 설정을 한다.

[root@binrang-db ~]# 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.
You already have a root password set, so you can safely answer 'n'.
Change the 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!
[root@binrang-db ~]# 


8. mariadb 재시작을 하자.

[root@binrang-db ~]# service mysql restart
Shutting down MySQL... SUCCESS! 
Starting MySQL. SUCCESS! 
[root@binrang-db ~]# 

9. 계정 생성 및 권한 을 부여 해 보자.

[root@binrang-db ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.28-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create user 'binrang'@'%' identified by '*******'; 
ERROR 1396 (HY000): Operation CREATE USER failed for 'binrang'@'%'
MariaDB [(none)]> 

헐.. 에러다.. 이유는 기존에 5. 대 버전 설치 때 남겨진 찌거기가 남은 것이다.
제거 후 명령을 다시 입력하면 된다. 다시 해보자.

[root@binrang-db ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.0.28-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create user 'binrang'@'%' identified by '******'; 
ERROR 1396 (HY000): Operation CREATE USER failed for 'binrang'@'%'
MariaDB [(none)]> 
MariaDB [(none)]> drop user 'binrang'@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create user 'binrang'@'%' identified by '******'; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 
MariaDB [(none)]> drop user 'binrang'@'localhost';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create user 'binrang'@'localhost' identified by '******'; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 

DB 생성은 5. 대 버전 것 참고하시길....


댓글 없음:

댓글 쓰기