9.2 MariaDB 설치
이 책에서 데이터소스 테스트에 MariaDB 데이터베이스를 사용한다. MariaDB는 MySQL의 후속 데이터베이스로 오라클 소유의 불확실한 MySQL의 라이선스 상태에 반발하여 MySQL과 같은 소스코드를 기반으로 만들어졌다. MySQL 핵심 개발자들이 설립한 MariaDB Foundation에서 개발하고 있다.
Maria라는 이름은 핵심 개발자인 Michael Widenius의 둘째 딸 이름에서 따온 것이라고 한다. 재미있게도 My는 첫째 딸 이름이다. 부모가 같은 소스를 기반으로 하므로 MySQL과 MariaDB는 자매 관계라고 부를 수 있다.
MariaDB는 MySQL과 소스코드가 같아서 5.5버전까지는 사용 방법과 구조가 같다. 차이점이 있다면, 성능이다. MariaDB는 MySQL과 비교해 복제 속도가 약 4~5천 배 빠르며, 성능도 최고 70% 정도 향상되었다.
새롭게 추가된 기능들도 많다. MariaDB에는 새로운 저장 엔진인 Aira 뿐만 아니라 InnoDB를 교체할 수 있는 XtraDB 저장 엔진을 포함하고 있다. 스레드 풀이나 샤딩 기술도 제공한다.
MariaDB의 사용 방법은 이 책에서 설명하지 않는다. 자세한 사용 방법은 http://www.mariadb.org를 참고하라.
JBoss EAP 6의 데이터소스 서브시스템 설정을 위해, 먼저 RHEL(CentOS) 6.x에 MariaDB를 설치하자.
따라해보기
- MariaDB 레파지토리 설정
- MariaDB 설치
- MariaDB 시작
- 암호 설정
- 데이터베이스 연결 확인
-
MariaDB 레파지토리 설정
먼저 MariaDB의 YUM 레파지토리를 설정한다.
$ **sudo vi /etc/yum.repo/mariadb.repo**
mariadb.repo의 파일 내용은 다음과 같다.
# MariaDB 5.5 CentOS repository list - created 2013-12-15 04:12 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
-
MariaDB 설치
다음 명령을 입력하여 MariaDB 서버를 설치한다.
$ sudo yum install MariaDB-server MariaDB-client
-
MariaDB 시작
MariaDB를 시작 한다. 5.5버전까지는 MySQL과 사용방법이 같다.
$ sudo /etc/init.d/mysql start
-
암호 설정
MariaDB root 패스워드와 원격 접속 등을 설정한다.
$ sudo mysql_secure_installation
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] [엔터]
New password: [password 입력]
Re-enter new password: [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] [엔터]
... 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] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] [엔터]
... 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!
-
데이터베이스 연결 확인
MariaDB 클라이언트로 MariaDB 서버에 연결하여 테스트한다.
$ mysql -u root -pEnter password: [패스워드 입력]Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 14Server version: 5.5.34-MariaDB MariaDB ServerCopyright (c) 2000, 2013, Oracle, Monty Program Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> use test;Database changedMariaDB [test]> show tables;Empty set (0.00 sec)MariaDB [test]>