Load To Technical Architect
[Linux] Mysql 5.7.20 Compile 본문
Mysql 5.7.20 컴파일
- Server Spec -
CPU - 2 Core
MEMORY - 4GB
OS - CentOS 7
0. 유저 mysql 생성
$ useradd mysql
$ passwd mysql
password
password
1. Compile을 위한 패키지 설치
$ yum -y install wget, cmake, gcc, gcc-c++, pcre-devel openssl-devel expat-devel, ncurses, ncurses-devel
2. Mysql Source file 설치
$ wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.20.tar.gz
$ tar -xzf mysql-5.7.20.tar.gz
3. Library Boost 1.59.0 설치
$ wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
$ tar -xzf boost_1_59_0.tar.gz
4. Compile
$ cd mysql-5.7.20
$ cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/mysql_data \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=../boost_1_59_0 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all
$ make
$ make install
5. my.cnf 수정
[client]
port = 3306
socket = /tmp/mysqld.sock
default-character-set=utf8
[mysqld_safe]
socket = /tmp/mysqld.sock
[mysqld]
# Character Set
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server=utf8
skip-character-set-client-handshake
collation-server = utf8_general_ci
# Basic Settings
user = mysql
pid-file = /tmp/mysqld.pid
socket = /tmp/mysqld.sock
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/mysql_data
tmpdir = /tmp
skip-external-locking
transaction_isolation = READ-COMMITTED
# Engine
default-storage-engine = InnoDB
# Listening IP
bind-address = 0.0.0.0
# Safety
max-connect-errors = 1000000
max_allowed_packet = 64M
skip-name-resolve
sysdate-is-now = 1
innodb-strict-mode = 1
wait_timeout = 60
interactive_timeout = 60
# Buffers
sort_buffer_size = 4M
read_buffer_size = 2M
join_buffer_size = 8M
read_rnd_buffer_size = 16M
# MyISAM
key-buffer-size = 32M
myisam_sort_buffer_size = 64M
# CACHES AND LIMITS #
tmp-table-size = 128M
max-heap-table-size = 128M
query-cache-type = 0
query-cache-size = 0
query_cache_limit = 1M
max-connections = 214
thread-cache-size = 50
thread_stack = 192K
open-files-limit = 1024
table-definition-cache = 1024
table-open-cache = 400
# Bin logs
binlog-format = ROW
log-bin = /usr/local/mysql/mysql_data/mysql-bin
log-slave-updates = 1
expire-logs-days = 5
sync-binlog = 1
max_binlog_size = 100M
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/mysql_data/mysql-slow.log
long_query_time = 5
server-id = 1 # randomize it incase of multiple servers
# InnoDB
innodb-buffer-pool-size = 2048M
innodb_buffer_pool_instances = 8
innodb_log_buffer_size = 8M
innodb-log-files-in-group = 2
innodb-log-file-size = 256M
innodb-file-per-table = 1
innodb-flush-log-at-trx-commit = 1
innodb-flush-method = O_DIRECT
# With virtual synchrony redundancy, make write queries faster
innodb_doublewrite = 1
# LOGGING
general_log_file = /usr/local/mysql/mysql_data/mysql.log
log-error = /usr/local/mysql/mysql_data/mysql-error.log
log-queries-not-using-indexes = 1
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[isamchk]
key_buffer = 16M
6. mysql 실행
$ /usr/local/mysql/bin/mysqld --initialize --user=mysql
$ /usr/local/mysql/bin/mysql_ssl_rsa_setup
$ /usr/local/mysql/bin/mysqld_safe --user=mysql
7. 임시 root 비밀번호 확인
$ cat /usr/local/mysql/mysql_data/mysql-error.log | grep generated | awk '{print $NF}' // my.cnf에서 지정한 error-log 파일명
8. 임시 root 비밀번호로 DB 접속
$ /usr/local/mysql/bin/mysql -u root -p
Enter password: 임시비밀번호
9. 임시 root 비밀번호 바꾸기
$ alter user ‘root’@’localhost’ identified by 'NEW PASSWORD';
'DB > mysql' 카테고리의 다른 글
[Linux] Mysql Replication (2) | 2020.06.16 |
---|---|
[Linux] Mysql Federated (0) | 2020.06.16 |
[Linux] Mysql Tomcat 연동 (2) | 2020.06.15 |
[Linux] Mysql Service 등록 (0) | 2020.06.11 |