# cat /etc/my.cnf

[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8

[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root
password = rootpasswd

# The MySQL server
[mysqld1]
port = 13306
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/host.pid
datadir = /var/lib/mysql/
skip-locking
key_buffer = 96M
max_allowed_packet = 3M
table_cache = 128
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency = 8
default-character-set=utf8
character_set_server=utf8
skip-federated
log-bin=mysql-bin

[mysqld2]
port = 13307
socket = /var/lib/mysql2/mysql.sock2
pid-file = /var/lib/mysql2/host.pid2
datadir = /var/lib/mysql2/
skip-locking
key_buffer = 96M
max_allowed_packet = 3M
table_cache = 128
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency = 8
default-character-set=utf8
character_set_server=utf8
skip-federated
log-bin=mysql-bin

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

# mysqld_multi start
# mysqld_multi stop

phpアプリのconfig.phpでの設定例

‘hostspec’ => ‘localhost:13306’,
 標準socketでない場合には
‘hostspec’ => ‘localhost:/var/lib/mysql2/mysql.sock2’,

デフォルトはバックアップ等も考慮してclients他3306で運用

起動用に /etc/init.d/に以下のscriptを配置

# cat /etc/init.d/mysqld_multi
#!/bin/sh

# Mysql daemon start/stop script.
#

# Usually this is put in /etc/init.d (at least on machines SYSV R4
# based systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/S01mysql.
# When this is done the mysql server will be started when the machine is started
# and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description: A very fast and reliable SQL database engine.

# The following variables are only set for letting mysql.server find things
# if you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf or other configuration files

MYSQLDIR=/usr
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:$MYSQLDIR/bin
export PATH

# See how we were called.
case “$1” in
start)
echo -n “Starting mysqld: ”
$MYSQLDIR/bin/mysqld_multi start 1,2
echo
;;
stop)
echo -n “Shutting down mysqld: ”
$MYSQLDIR/bin/mysqld_multi stop 1,2
echo
;;
status)
$MYSQLDIR/bin/mysqld_multi report 1,2
;;
restart)
$0 stop
$0 start
;;
*)
echo “Usage: $0 {start|stop|restart|status}”
exit 1
esac

exit 0

起動時の設定を追加
元々のmysqldはオフに、mysqld_multiをオンに

# checkconfig mysqld off
# checkconfig mysqld_multi on

#ntsysv で確認

,
とりあえず付けておく無駄ではなかったなまぁまぁ読めたちょっと役に立ったかなかなり良かったかも (1 投票, 平均値/最大値: 4.00 / 5)
Loading...
Trackback

no comment untill now

Sorry, comments closed.