再:さくらインターネットのVPSにサーバ構築 その2

今回は mysql のインストールと設定を行う。
最終的には、旧サーバで dump して、それを新しいサーバにインポートしないといけないのだけど、それは最終段階でやるってことで。
今やっても、その後に blog 更新したらやりなおしなので。

MySQLをインストールする

	#apt-get install mysql-server

root のパスワードを途中で聞かれるので、入力する

my.cnf の編集

方針としては以下

  • 基本InnoDBを使う
  • wordpress も MyISAM ではなく、InnoDBを使う
  • 一応、MyISAM も残しておく

検討もしてたCloudCore VPSのVCV02プランならメモリ6GBあるので、
MyISAM と InnoDB とを両方使い分けるぜーとかするんだけど。

今回はとりあえずという設定で、後は様子見ながらチューニングしていく予定

参考サイト

http://easyramble.com/example-of-mysql-options.html
http://www.karakaram.com/onamae-com-vps6-mysql#my-cnf

my.cnf

[mysqld]
# --------------------------------------------------
# Base
# --------------------------------------------------
basedir         = /usr
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
bind-address    = 127.0.0.1
user            = mysql
port            = 3306
datadir         = /var/lib/mysql
socket          = /var/run/mysqld/mysqld.sock
pid-file        = /var/run/mysqld/mysqld.pid
symbolic-links = 0
# sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
default-storage-engine = InnoDB
transaction-isolation = REPEATABLE-READ
character-set-server = utf8
collation-server = utf8_general_ci
skip-character-set-client-handshake

# --------------------------------------------------
# Replication
# --------------------------------------------------
# not use Replication for now
server-id              = 1
log-bin                        = /var/log/mysql/mysql-bin.log

# --------------------------------------------------
# Network
# --------------------------------------------------
# Global
skip-networking
skip-name-resolve
max_connections = 100
max_connect_errors = 10000
connect_timeout = 10
max_allowed_packet = 16M
# Global, Session
max_user_connections = 0
wait_timeout = 600	#28800
interactive_timeout = 600	#28800

# --------------------------------------------------
# Logging
# --------------------------------------------------
log_output = FILE
log_warnings = 1
general_log = 0
general_log_file = /var/lib/mysql/www.log
log-slow-admin-statements = 1
log-queries-not-using-indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/www-slow.log
long_query_time = 0.5  #10
expire_logs_days = 14

# --------------------------------------------------
# Cache & Memory
# --------------------------------------------------
# Global
thread_cache_size = 30   #8
table_open_cache = 400
query_cache_type = 1
query_cache_size = 16M
query_cache_limit = 1M
# Global, Session
max_heap_table_size = 16M
tmp_table_size = 16M
sort_buffer_size = 2M
read_buffer_size = 131072
join_buffer_size = 131072
read_rnd_buffer_size = 262144

# --------------------------------------------------
# MyISAM
# --------------------------------------------------
# Global
skip-external-locking
key_buffer_size = 8M	#key_buffer = 16M
myisam_max_sort_file_size = 2G  #9223372036853727232
myisam_recover_options = DEFAULT	#BACKUP
# Global, Session
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M

# --------------------------------------------------------------------
# InnoDB behavior
# --------------------------------------------------------------------
# Global
innodb_file_format = Barracuda	#Antelope
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_stats_on_metadata = 1
innodb_max_dirty_pages_pct = 90	#75
innodb_adaptive_hash_index = 1
innodb_adaptive_flushing = 1
#innodb_strict_mode = 1
innodb_io_capacity = 200
innodb_autoinc_lock_mode = 1
#innodb_change_buffering = inserts
innodb_old_blocks_time = 500	#0

# --------------------------------------------------------------------
# InnoDB base
# --------------------------------------------------------------------
# Global
innodb_buffer_pool_size = 256M	#128M
innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:50M:autoextend	#10M
innodb_file_per_table = 1	#0
innodb_autoextend_increment = 10M	#8
#innodb_log_group_home_dir = /var/lib/mysql
innodb_fast_shutdown = 0	#1
innodb_log_file_size = 64M	#50M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 8M
innodb_additional_mem_pool_size = 8M
innodb_thread_concurrency = 8	#0
innodb_flush_log_at_trx_commit = 1
innodb_force_recovery = 0
innodb_doublewrite = 1
innodb_sync_spin_loops = 20	#30
innodb_thread_sleep_delay = 1000	#10000
innodb_commit_concurrency = 0
innodb_concurrency_tickets = 500
# Global, Session
#innodb_support_xa = FALSE
innodb_lock_wait_timeout = 50
innodb_table_locks = 1

[mysqldump]
quote-names
default-character-set = utf8
quick
max_allowed_packet = 16M

[mysql]
default-character-set = utf8
no-auto-rehash
show-warnings
 
[client]
default-character-set = utf8
port   = 3306
socket = /var/run/mysqld/mysqld.sock
 
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0
#log-error = /var/log/mysql/error.log

# --------------------------------------------------------------------
# replication
# --------------------------------------------------------------------
#max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name

# --------------------------------------------------------------------
# No Useing
# --------------------------------------------------------------------
# chroot = /var/lib/mysql/
#thread_stack            = 192K
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

正直ちゃんと理解できてないところがある。
まぁ完全に理解できてたら、DBAとして生きていける気もする。

まぁこれで様子を見ながらログを確認しつつ今後もチューニングしていくつもり。

次は apache