LegacyなMySQL(ver 5.0.xとか)で、別ポートで2つ目のサーバのセットアップのメモ(RedHat系Linux)

非常にいまさらなメモなので、誰の役にも立たないだろう。
root権限で作業。

まず、既存の/etc/my.cnfをベースに、my_new.cnfなどを作る

[root@mgrsite etc]# diff my.cnf my_new.cnf
< datadir=/var/lib/mysql
< socket=/var/lib/mysql/mysql.sock
---
> datadir=/var/lib/newmysqldata
> port=3307
> socket=/var/lib/mysql/mysql_new.sock


< log-error=/var/log/mysqld.log
< pid-file=/var/run/mysqld/mysqld.pid
---
> log-error=/var/log/mysqld_new.log
> pid-file=/var/run/mysqld/mysqld_new.pid

rcファイルがイマイチなので、いじる

注意すべきなのは、mysql_install_db の--datadir オプションがなかったこと、かな。

# diff mysqld mysqld_new
9c9
< # config: /etc/my.cnf
---
> # config: /etc/my_new.cnf
19c19
< prog="MySQL"
---
> prog="MySQL_CMS"
21c21
< # extract value of a MySQL option from /etc/my.cnf
---
> # extract value of a MySQL option from /etc/my_new.cnf
46c46
< get_mysql_option /etc/my.cnf datadir "/var/lib/mysql"
---
> get_mysql_option /etc/my_new.cnf datadir "/var/lib/mysql"
48c48
< get_mysql_option /etc/my.cnf socket "$datadir/mysql.sock"
---
> get_mysql_option /etc/my_new.cnf socket "$datadir/mysql_new.sock"
50c50
< get_mysql_option /etc/my.cnf log-error "/var/log/mysqld.log"
---
> get_mysql_option /etc/my_new.cnf log-error "/var/log/mysqld_new.log"
52c52
< get_mysql_option /etc/my.cnf pid-file "/var/run/mysqld/mysqld.pid"
---
> get_mysql_option /etc/my_new.cnf pid-file "/var/run/mysqld/mysqld_new.pid"
53a54,55
> get_mysql_option /etc/my_new.cnf port "3307"
> myport="$result"
61c63,65
<           action $"Initializing MySQL database: " /usr/bin/mysql_install_db
---
>           # action $"Initializing MySQL database: " /usr/bin/mysql_install_db
>           echo "Initializing MySQL database: "
>           /usr/bin/mysql_install_db --user=mysql --datadir=$datadir
71c75
<       # be no such entry in my.cnf, and the default behavior will be to not
---
>       # be no such entry in my_cms.cnf, and the default behavior will be to not
73,74c77,78
<       # was not an entry in my.cnf.
<       /usr/bin/mysqld_safe  --defaults-file=/etc/my.cnf --pid-file="$mypidfile" --log-error="$errlogfile" >/dev/null 2>&1 &
---
>       # was not an entry in my_cms.cnf.
>       /usr/bin/mysqld_safe  --defaults-file=/etc/my_new.cnf --port=$myport --pid-file="$mypidfile" --log-error="$errlogfile" >/dev/null 2>&1 &

起動設定とかをして、service起動

# mkdir /var/lib/newmysqldata
# chown mysql:mysql
# chkconfig --add mysqld_new
# chkconfig mysqld_new on
# service mysqld_new start