본문 바로가기

리눅스

[리눅스] 바이너리(Generic Binaries)를 사용하여 Ubuntu에 MySQL 설치

728x90

바이너리(Generic Binaries)를 사용하여 Ubuntu에 MySQL 설치

요구사항

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

MySQL 설치

libaio 패키지 확인

dpkg -l | grep libaio
$ dpkg -l | grep libaio
ii  libaio1:amd64    0.3.112-13build1    amd64    Linux kernel AIO access library - shared library

libaio 패키지가 없으면 설치 진행

apt-cache search libaio
$ apt-cache search libaio
libaio-dev - Linux kernel AIO access library - development files
libaio1 - Linux kernel AIO access library - shared library
apt install -y libaio1

mysql 계정 생성(mysql 그룹 및 mysql 사용자 생성)

groupadd -g 999 mysql
useradd -r -g mysql -u 999 -s /bin/false -c "MySQL Server" mysql

바이너리 파일 다운로드

설치 경로 이동

cd /usr/local

바이너리 다운로드

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.30-linux-glibc2.12-x86_64.tar

압축 해제

tar xvf mysql-8.0.30-linux-glibc2.12-x86_64.tar
tar xvf mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz

심볼릭 링크 걸기

ln -s mysql-8.0.30-linux-glibc2.12-x86_64 mysql
cd mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files

DB 초기화

bin/mysqld --initialize --user=mysql
$ bin/mysqld --initialize --user=mysql
2022-10-20T10:36:50.759143Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.30-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 62230
2022-10-20T10:36:50.768094Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-20T10:36:51.797459Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-20T10:36:53.213663Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: y&j1di7st<Xa
bin/mysql_ssl_rsa_setup

DB 서버 구동(startup)

bin/mysqld_safe --user=mysql &
$ bin/mysqld_safe --user=mysql &
[1] 62282

mysqld 데몬 확인

ps -ef | grep -v grep | grep mysql
$ ps -ef | grep -v grep | grep mysql
root       62282   61830  0 19:38 pts/5    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql      62351   62282  0 19:38 pts/5    00:00:07 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=testdb.err --pid-file=testdb.pid
cp support-files/mysql.server /etc/init.d/mysql.server

패스(PATH) 설정

export PATH=$PATH:/usr/local/mysql/bin

 


mysql default my.cnf 파일 추출

wget https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.30.tar.gz
tar xfz mysql-boost-8.0.30.tar.gz

 


my.conf 파일 생성

vim /usr/local/mysql/my.cnf
[mysqld]
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
local-infile = 0
mysqlx = 0
bind-address = [IPs removed]
default-storage-engine = InnoDB
open_files_limit = 200000
max_allowed_packet = 256M
sql_mode = "STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"

innodb_dedicated_server = 1
innodb_buffer_pool_instances = 48
innodb_log_buffer_size = 64M
innodb_read_io_threads = 12
innodb_write_io_threads = 12
innodb_stats_on_metadata = 0
innodb_file_per_table = 1

max_connections = 500
thread_cache_size = 128
table_definition_cache = 65536
table_open_cache = 65536

wait_timeout = 10
connect_timeout = 5
interactive_timeout = 30

tmp_table_size = 128M
max_heap_table_size = 128M

read_buffer_size = 256K
join_buffer_size = 1M
sort_buffer_size = 512K
read_rnd_buffer_size = 512K

slow-query-log = 1
long_query_time = 2
slow_query_log_file = /usr/local/mysql/data/mysql_slow_query.log
log-error = /usr/local/mysql/data/testdb.err


DB 초기화

bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql
bin/mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql/my.cnf

 

DB 서버 구동(startup)

bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql &

mysqld 데몬 확인

ps -ef | grep -v grep | grep mysqld

 

참고URL

- https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html

- MySQL 8 sample config (my.cnf example) and tuning : https://haydenjames.io/mysql-8-sample-config-tuning/

- Installing the MySQL 5.7 Binary Package : https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-deployment-install.html

 

728x90