34. MySQL Tuning
#
curl
-‐L
mysqltuner.pl
|
perl
%
Total
%
Received
%
Xferd
Average
Speed
Ti
Dload
Upload
To
100
44790
100
44790
0
0
26346
0
0:00
>>
MySQLTuner
1.3.0
-‐
Major
Hayden
<major@mhtx.ne
>>
Bug
reports,
feature
requests,
and
downloads
a
>>
Run
with
'-‐-‐help'
for
additional
options
and
o
[!!]
Successfully
authenticated
with
no
password
-‐
[OK]
Currently
running
supported
MySQL
version
5.5.
[OK]
Operating
on
64-‐bit
architecture
mysqltuner.pl
14年4月15日火曜日
35. MySQL Tuning
-‐-‐-‐-‐-‐-‐-‐-‐
Storage
Engine
Statistics
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
[-‐-‐]
Status:
+ARCHIVE
+BLACKHOLE
+CSV
-‐FEDERATED
+I
[-‐-‐]
Data
in
InnoDB
tables:
496K
(Tables:
12)
[-‐-‐]
Data
in
PERFORMANCE_SCHEMA
tables:
0B
(Tables:
[OK]
Total
fragmented
tables:
0
Storage Engine Statistics
14年4月15日火曜日
36. MySQL Tuning
-‐-‐-‐-‐-‐-‐-‐-‐
Security
Recommendations
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
[!!]
User
'@localhost'
has
no
password
set.
[!!]
User
'@v210-‐172-‐187-‐188.z0d1.static.cnode.jp'
[!!]
User
'root@127.0.0.1'
has
no
password
set.
[!!]
User
'root@::1'
has
no
password
set.
[!!]
User
'root@localhost'
has
no
password
set.
[!!]
User
'root@v210-‐172-‐187-‐188.z0d1.static.cnode.
Security Recommendations
14年4月15日火曜日
37. MySQL Tuning
-‐-‐-‐-‐-‐-‐-‐-‐
Performance
Metrics
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
[-‐-‐]
Up
for:
5h
5m
4s
(111
q
[0.006
qps],
8
conn,
T
[-‐-‐]
Reads
/
Writes:
96%
/
4%
[-‐-‐]
Total
buffers:
232.0M
global
+
1.5M
per
thread
[OK]
Maximum
possible
memory
usage:
424.0M
(2%
of
i
[OK]
Slow
queries:
0%
(0/111)
[OK]
Highest
usage
of
available
connections:
0%
(1/
[OK]
Key
buffer
size
/
total
MyISAM
indexes:
16.0M/
[OK]
Query
cache
efficiency:
41.3%
(38
cached
/
92
[OK]
Query
cache
prunes
per
day:
0
[OK]
Sorts
requiring
temporary
tables:
0%
(0
temp
s
[!!]
Temporary
tables
created
on
disk:
28%
(2
on
di
Performance Metrics
14年4月15日火曜日
38. MySQL Tuning
-‐-‐-‐-‐-‐-‐-‐-‐
Recommendations
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
General
recommendations:
MySQL
started
within
last
24
hours
-‐
recommenda
Enable
the
slow
query
log
to
troubleshoot
bad
q
When
making
adjustments,
make
tmp_table_size/ma
Reduce
your
SELECT
DISTINCT
queries
without
LIM
Variables
to
adjust:
tmp_table_size
(>
64M)
max_heap_table_size
(>
64M)
Performance Metrics
14年4月15日火曜日
41. Monit
#
monit
の監視間隔
set
daemon
30
with
start
delay
5
#
web
ステータスチェック
set
httpd
port
2812
and
use
address
localhost
allow
localhost
#
アラートメールの送信先
set
alert
root@localhost
set
alert
example@example.com
#
設定ファイルのインクルード
include
/etc/monit.d/*
/etc/monit.conf の例
14年4月15日火曜日
42. Monit
check
process
mysqld
with
pidfile
/var/run/mysqld/mysqld.pid
start
program
=
"/sbin/service
mysqld
start"
stop
program
=
"/sbin/service
mysqld
stop"
/etc/monit.d/mysqld の例
14年4月15日火曜日
43. Monit
check
process
php-‐fpm
with
pidfile
/var/run/php-‐fpm/php-‐fpm.pid
start
program
=
"/sbin/service
php-‐fpm
start"
stop
program
=
"/sbin/service
php-‐fpm
stop"
check
directory
php_tmp
with
path
"/var/tmp/php"
if
failed
uid
nginx
then
exec
"/bin/chown
-‐R
nginx:nginx
/var/tmp/php"
check
directory
php_session
with
path
"/var/tmp/php/session"
if
failed
uid
nginx
then
exec
"/bin/chown
-‐R
nginx:nginx
/var/tmp/php/ses
check
directory
php_log
with
path
"/var/log/php-‐fpm"
if
failed
uid
nginx
then
exec
"/bin/chown
-‐R
nginx:nginx
/var/log/php-‐fpm
/etc/monit.d/php-fpm の例
14年4月15日火曜日