Tag Archives: CentOS

1台のサーバに複数のMySQLをインストールしてみた。

前回はApacheだったが、今回は1台のサーバに複数のMySQL5.0をインストールするメモ。

Source downloads」から「Compressed GNU TAR archive」をダウンロード。



■今回の環境

以下の環境を想定して解説する。

サーバ:CentOS 5
ビット:64bit
MySQLインストールディレクトリ:/home/hoge/mysql
ポート番号:1235



■MySQLインストール

# su - hoge
# wget http://hoge.hoge.hoge/hoge/mysql-5.0.51a.tar.gz
# tar -xvzf mysql-5.0.51a.tar.gz
# cd mysql-5.0.51a
# ./configure --prefix=/home/hoge/mysql \
--with-mysqld-user=hoge \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-tcp-port=1235
...
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found

上記のようなエラーが発生。

どうやらcursesとかいうものが指定されていないっぽい。これも64bitだからか?



configureのhelpを見たら「with-named-curses-libs」なるものが。

試しにオプションつけて再度実行。

# ./configure --prefix=/home/hoge/mysql \
--with-mysqld-user=hoge \
--with-charset=utf8 \
--with-extra-charsets=all \
--with-tcp-port=1235 \
--with-named-curses-libs=/usr/lib64/libncurses.so.5
# make
# make install

正常にいった。



my-medium.cnfをコピーする。

# cp /home/hoge/mysql-5.0.51a/support-files/my-medium.cnf /home/hoge/mysql/my.cnf

my.cnfを編集する。まずmysql.sockのパスが重複しそうなので変更する。

(修正前) socket = /tmp/mysql.sock
(修正後) socket = /home/hoge/mysql/mysql.sock

ポート番号もconfigure時に設定した値になっているか確認する。



■mysql_install_db

データベースの初期化を行なう。

# cd /home/hoge/mysql-5.0.51a/scripts
# ./mysql_install_db --user=hoge --datadir=/home/hoge/mysql/data



■MySQL起動、動作チェック

デフォルトのmy.cnfを読み込まないようmysqld_safeのオプションで指定する。

# ./mysqld_safe --defaults-file=/home/hoge/mysql/my.cnf \
--pid-file=/home/hoge/mysql/mysqld.pid \
--log-error=/home/hoge/mysql/log/mysqld.log &



ポート番号とmysql.sockを指定してログインする。

念のため、/home/hoge/mysql/bin以下のmysqlを使用した方がよいかもね。

# /home/hoge/mysql/bin/mysql -u root -P1235 --socket=/home/hoge/mysql/mysql.sock

64bit環境のサーバに複数のApacheを入れてみた。

1台のサーバに複数のApacheを入れる機会があったので、そのメモ。

すでに1個Apacheがインストールされていてポートはデフォルトの「80」だった。

通常通りインストールすると競合してしまうので、いろいろ設定した。



■今回の環境

今回は以下の環境を想定して解説する。

サーバ:CentOS 5
ビット:64bit
Apacheインストールディレクトリ:/home/hoge/apache2
ポート番号:1234



■Apacheインストール

# su - hoge
# wget http://hogehoge.hoge/hoge/httpd-2.0.63.tar.gz
# tar -xvzf httpd-2.0.63.tar.gz
# cd httpd-2.0.63
# ./configure --prefix=/home/hoge/apache2
# make
/usr/lib/libexpat.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [htpasswd] エラー 1
make[2]: ディレクトリ `/home/hoge/httpd-2.0.63/support' から出ます
make[1]: *** [all-recursive] エラー 1
make[1]: ディレクトリ `/home/hoge/httpd-2.0.63/support' から出ます
make: *** [all-recursive] エラー 1

上記のようなエラーが発生。

libexpat.soの場所がダメっぽい。64bit版libexpat.soを使用しなくてはいけないらしい。



以下のオプションをつけて再度実行。正常にインストールできた様子。

# ./configure --prefix=/home/hoge/apache2 --with-expat=builtin
# make
# make install

Apacheのconfigureオプションは、helpを見ても存在しない奴があるから困る。



■ポート設定、起動チェック

デフォルトのままだと、既存のApacheと重複してしまうのでポートを変更する。

# vi /home/hoge/apache2/conf/httpd.conf

219行目辺りのListenをコメントアウトにし、新たに1234を定義。そして保存。

 219 #Listen 80
 220 # mikuriya 2008/03/25
 221 Listen 1234

Apacheを起動する。

# /home/hoge/apache2/bin/apachectl start

特にエラーなく起動されたので、ブラウザで確認する。

http://hoge.hoge.hoge:1234/

正常に見れた。既存のApacheも動作してるか見てみる。

http://hoge.hoge.hoge/

こちらも正常に動作している様子。





参考:http://hirokawa.netflowers.jp/entry/4969/