CentOS6.9 MariaDB 소스 설치
ETCMariaDB
MySQL과 설치 과정이 같다.
여기서는 MySQL 설치 후 MariaDB도 설치하는 상황이다.
0. 유틸 설치
# yum install -y cmake ncurses ncurses-devel bison gcc gcc-c++
1. 다운로드 및 설치
src]# wget https://downloads.mariadb.org/interstitial/mariadb-10.1.32/source/mariadb-10.1.32.tar.gz
src]# tar zxvf mariadb-10.1.32.tar.gz
src]# cd mariadb-10.1.32
mariadb-10.1.3]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/usr/local/mariadb/data -DMYSQL_TCP_PORT=53306 -DMYSQL_UNIX_ADDR=/tmp/mariadb.sock
mariadb-10.1.3]# make && make install
-- Build files have been written to: /usr/local/src/mariadb-10.1.32 // cmake
[100%] Built target mariadb-pp // make
-- Installing: /usr/local/mariadb/support-files/mysql.server // make install
- -DCMAKE_INSTALL_PREFIX : MySQL 설치 경로
- -DMYSQL_DATADIR : data 폴더 설치 경로
- -DMYSQL_TCP_PORT : MySQL 포트 번호. default 3306
- -DMYSQL_UNIX_ADDR : MySQL 소켓 폴더. default tmp/mysql.sock
2. DB 생성
# cd /usr/local/mariadb
mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data
Installing MariaDB/MySQL system tables in './data' ...
(...)
‘/usr/local/mariadb/bin/mysql_secure_installation’
which will also give you the option of removing the test
databases and anonymous user created my 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/local/mariadb’ ; /usr/local/mariadb/bin/mysqld_safe --datadir=’/usr/local/mariadb/data’
You can test the MariaDB daemon with mysql-test-run.pl
cd ‘/usr/local/mariadb/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
Confider joining MariaDB’s strong and vibrant community:
http://mariadb.org/get-involved/
3. 설정 파일 복사
# rm /etc/my.cnf
rm: remove regular file ‘/etc/my.cnf’? y
# cd /usr/local/mariadb/support-files
support-files]# cp my-huge.cnf /usr/local/mariadb/my.cnf
# vi /usr/local/mariadb/my.cnf
[client]
port = 53306
socket = /tmp/mariadb.sock
[mysqld]
port = 53306
socket = /tmp/mariadb.sock
datadir = /usr/local/mariadb/data
pid-file = /usr/local/mariadb/data/mariadb.pid
log-bin = /usr/local/mariadb/log/bin
server-id = 5
MySQL이 실행될 때 my.cnf를 참조하는 데,
/etc/ 위치에 my.cnf가 없을 경우, 해당 디렉토리 안에 있는 my.cnf를 참조한다.
이는 모든 MySQL/MariaDB에 적용해야 참조 오류가 발생하지 않는 다.
4. 데몬 복사 및 수정
MariaDB는 MySQL과의 호환성을 위해 프로토콜, 프로세스명, 명령어 등이 동일하게 설정되어 있다.
따라서 다른 서버에 설치한다.
mariadb]# cd support-files
support-files]# cp mysql.server /etc/rc.d/init.d/mariadb
support-files]# vi /etc/rc.d/init.d/mariadb
(...)
basedir=/usr/local/mariadb
datadir=/usr/local/mariadb/data // /tmp/mariadb.sock 위치
(...)
# chkconfig --add mariadb // 서비스 등록
5. 권한 설정
# chmod 755 /etc/rc.d/init.d/mariadb
# ll /etc/rc.d/init.d/mariadb // 해당 파일 확인
-rwxr-xr-x. 1 root root 12292 Mar 31 06:40 /etc/rc.d/init.d/mariadb
5-1. mysql 계정 mariadb 권한 설정
# mkdir -p /usr/local/mariadb/lnnoDB/redoLogs
# mkdir -p /usr/local/mariadb/lnnoDB/undLogs
# mkdir /usr/local/mariadb/logs /usr/local/mariadb/tmp
# chown -R mysql:mysql /usr/local/mariadb
6. 라이브러리 추가
# rm /etc/ld.so.conf.d/mysql-x86_64.conf
# echo "/usr/local/mariadb/lib" > /etc/ld.so.conf.d/mysql.conf
mariadb]# ln -s lib lib64
7. 구동 시작
# cd /usr/local/mariadb/bin
bin]# service mariadb start
Starting MariaDB.. SUCCESS!
8. 기본 보안 적용 (구동 먼저해야 실행됨)
bin]# ./mysql_secure_installation -S /tmp/mariadb.sock
MySQL과 동일
9. 접속
# mysql -u root -p -S /tmp/mariadb.sock
- -S : 소켓파일의 위치와 이름을 지정하는 옵션
10. 데이터베이스 및 테이블 생성
mysql> create database maria;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| maria |
| mysql |
| performance_schema |
+-----------------------+
4 rows in set (0.0 sec)
mysql> use maria;
Database changed
mysql> create table test (no int, name varchar(20));
Query OK, 0 rows affected (0.10 sec)
mysql> show tables;
+-----------------------+
| Tables_in_test |
+-----------------------+
| test |
+-----------------------+
1 rows in set (0.0 sec)
mysql> insert into test (no, name) values (1, ‘test’);
Query OK, 1 row affected (0.04 sec)
mysql> select * from test;
+----------+----------+
| no | name |
+----------+----------+
| 1 | test |
+----------+----------+
1 rows in set (0.0 sec)
mysql> \q
Bye
#. 서비스 없이 start, stop
# cd /usr/local/mariadb/support-files/mysql.server start
# cd /usr/local/mariadb/support-files/mysql.server stop