내 목표는 동일한 Ubuntu 18.04 서버에 MariaDB 10.1과 MySQL 8을 설치하는 것입니다.
MySQL 8을 성공적으로 설정할 수 있었지만 이 가이드를 따라 MariaDB를 설정할 때 거의 마지막에 막히게 되었습니다.
https://mariadb.com/kb/en/library/installing-mariadb-alongside-mysql/
기본적으로 이것이 내가 한 일입니다.
- Linux용 mariadb 다운로드
- 추출된 폴더를 /opt/mariadb에 복사합니다.
- /opt/mariadb-data 폴더 생성
- mariadb 사용자가 chown'ed(새로 생성됨)
- my.cnf를 /opt/mariadb-data에 복사하고 포트 번호와 사용자, basedir 및 datadir을 편집합니다. mysql.service 파일을 /etc/init.d/mariadb에 복사하고 편집합니다.
- 설치 스크립트 실행
- 부팅을 시도했는데 다음 오류가 발생했습니다.
Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload
● mariadb.service - LSB: start and stop MySQL
Loaded: loaded (/etc/init.d/mariadb; generated)
Active: failed (Result: exit-code) since Thu 2019-08-29 23:27:12 EDT; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 35976 ExecStop=/etc/init.d/mariadb stop (code=exited, status=0/SUCCESS)
Process: 36610 ExecStart=/etc/init.d/mariadb start (code=exited, status=1/FAILURE)
Tasks: 28 (limit: 4563)
CGroup: /system.slice/mariadb.service
├─33699 /bin/sh /opt/mariadb/bin/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir=/opt/mariadb/data --pid-file=/o
└─33830 /opt/mariadb/bin/mysqld --defaults-file=/opt/mariadb-data/my.cnf --basedir=/opt/mariadb --datadir=/opt/mariadb/data --p
Aug 29 23:27:11 dev03.example.com systemd[1]: Starting LSB: start and stop MySQL...
Aug 29 23:27:11 dev03.example.com mariadb[36610]: Starting MySQL
Aug 29 23:27:11 dev03.example.com mariadb[36610]: .190829 23:27:11 mysqld_safe Logging to '/opt/mariadb-data/dev03.example.com.err'.
Aug 29 23:27:11 dev03.example.com mariadb[36610]: 190829 23:27:11 mysqld_safe A mysqld process already exists
Aug 29 23:27:12 dev03.example.com mariadb[36610]: *
Aug 29 23:27:12 dev03.example.com systemd[1]: mariadb.service: Control process exited, code=exited status=1
Aug 29 23:27:12 dev03.example.com systemd[1]: mariadb.service: Failed with result 'exit-code'.
Aug 29 23:27:12 dev03.example.com systemd[1]: Failed to start LSB: start and stop MySQL.
이는 튜토리얼 링크를 따라 my.cnf에 대해 설정한 구성의 중요한 부분입니다.
Create a new my.cnf in /opt/mariadb from support files:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/my-medium.cnf mariadb-data/my.cnf
[root@mariadb-near-mysql opt]# chown mariadb:mariadb mariadb-data/my.cnf
Edit the file /opt/mariadb-data/my.cnf and add custom paths, socket, port, user and the most important of all: data directory and base directory. Finally the file should have at least the following:
[client]
port = 3307
socket = /opt/mariadb-data/mariadb.sock
[mysqld]
datadir = /opt/mariadb-data
basedir = /opt/mariadb
port = 3307
socket = /opt/mariadb-data/mariadb.sock
user = mariadb
Copy the init.d script from support files in the right location:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/mysql.server /etc/init.d/mariadb
[root@mariadb-near-mysql opt]# chmod +x /etc/init.d/mariadb
Edit /etc/init.d/mariadb replacing mysql with mariadb as below:
- # Provides: mysql
+ # Provides: mariadb
- basedir=
+ basedir=/opt/mariadb
- datadir=
+ datadir=/opt/mariadb-data
- lock_file_path="$lockdir/mysql"
+ lock_file_path="$lockdir/mariadb"
The trickiest part will be the last changes to this file. You need to tell mariadb to use only one cnf file. In the start section after $bindir/mysqld_safe add --defaults-file=/opt/mariadb-data/my.cnf. Finally the lines should look like:
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
The same change needs to be made to the mysqladmin command below in the wait_for_ready() function so that the mariadb start command can properly listen for the server start. In the wait_for_ready() function, after $bindir/mysqladmin add --defaults-file=/opt/mariadb-data/my.cnf. The lines should look like:
MariaDB의 mysqld 프로세스 이름을 변경하기 위해 할 수 있는 일이 있습니까, 아니면 충돌을 피할 수 있는 다른 방법이 있습니까?