mysqldプロセスがすでに存在するエラーを解決するためにMariaSQLのmysqldをMySQL 8のmysqldプロセスから切り離す方法は?

mysqldプロセスがすでに存在するエラーを解決するためにMariaSQLのmysqldをMySQL 8のmysqldプロセスから切り離す方法は?

私の目標は、同じUbuntu 18.04サーバーにMariaDB 10.1とMySQL 8をインストールすることです。

MySQL 8を正常に設定できましたが、このガイドに従ってMariaDBを設定すると、ほとんど最後に詰まっていました。

https://mariadb.com/kb/en/library/installing-mariadb-alongside-mysql/

基本的にこれが私がしたことです。

  1. Linux 用 mariadb ダウンロード
  2. 抽出したフォルダを/opt/mariadbにコピーします。
  3. /opt/mariadb-data フォルダの作成
  4. mariadb ユーザーが chown'ed (新しく作成)
  5. my.cnf を /opt/mariadb-data にコピーし、ポート番号とユーザー、basedir、datadir を編集します。 mysql.service ファイルを /etc/init.d/mariadb にコピーして編集します。
  6. インストールスクリプトの実行
  7. 起動しようとしましたが、次のエラーが発生しました。
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プロセス名を変更するためにできることはありますか、それとも競合を回避する他の方法はありますか?

ベストアンサー1

おすすめ記事