745685 ランダム
 ホーム | 日記 | プロフィール 【フォローする】 【ログイン】

読書と技術となんか色々のログ

読書と技術となんか色々のログ

【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! --/--
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

PR

カレンダー

カテゴリ

2010年05月04日
XML
カテゴリ:[DB] MySQL
自宅サーバー構築メモ(その7) tritonn(MySQL)をインストール(その2)

my.cnfが無いので、テンプレートファイルからmy.cnfを用意します。

テンプレートは/usr/share/mysql下にあります。
# ls -laF /usr/share/mysql/my*.cnf
-rwxr-xr-x 1 root root 4972 Nov 26 18:39 /usr/share/mysql/my-huge.cnf*
-rwxr-xr-x 1 root root 20970 Nov 26 18:39 /usr/share/mysql/my-innodb-heavy-4G.cnf*
-rwxr-xr-x 1 root root 4948 Nov 26 18:39 /usr/share/mysql/my-large.cnf*
-rwxr-xr-x 1 root root 4955 Nov 26 18:39 /usr/share/mysql/my-medium.cnf*
-rwxr-xr-x 1 root root 2526 Nov 26 18:39 /usr/share/mysql/my-small.cnf*

今回は、my-medium.cnfからmy.cnfを作ります。
# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

メモリの割当を若干変えたほか、青字の設定を追記しました。
# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /var/lib/mysql/mysql.sock

#1
default-character-set=utf8

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

#2
default-character-set=utf8

#3
skip-name-resolve

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Disable Federated by default
skip-federated

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id       = 1

# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir         = /tmp/
#log-update     = /path-to-dedicated-directory/hostname

#4
log-error=/var/log/mysql/mysql.err
log-warnings=1


#5
log-slow-queries=/var/log/mysql/mysql.slow
long_query_time=3


#6
log-queries-not-using-indexes
log-slow-admin-statements



# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

#7
innodb_file_per_table

#8
innodb_fast_shutdown = 0

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

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

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

[mysqlhotcopy]
interactive-timeout

*innodb_log_file_sizeの設定を変えたので、mysqlをシャットダウンした後に
古いログファイルを削除しておきます。
my.cnfと実際のログファイルのサイズが異なるとエラーログに下記のメッセージが出力されます。
InnoDB: Error: log file /var/lib/mysql/ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 67108864 bytes!


#1
default-character-set=utf8
文字コードをUTF8にする

#2
default-character-set=utf8
文字コードをUTF8にする

#3
skip-name-resolve
DNS逆引きを無効にする

#4
log-error=/var/log/mysql/mysql.err
エラーログの出力先、ファイル名を明示する。
log-warnings=1
警告メッセージも出力する(0:出力しない)

#5
log-slow-queries=/var/log/mysql/mysql.slow
スロークエリログの出力先、ファイル名を明示する。
long_query_time=3
スロークエリログに出力するクエリの実行時間の閾値を指定する。
単位は秒。

#6
log-queries-not-using-indexes
インデックスを使用しないクエリをスロークエリログに出力する
log-slow-admin-statements
OPTIMIZE TABLE、ANALYZE TABLE、ALTER TABLEなど、時間がかかる管理ステートメントをログに出力する

#7
innodb_file_per_table
テーブルごとにデータファイル(tbl_name.idb)を作成する。

#8
innodb_fast_shutdown = 0
mysqlシャットダウン時にトランザクションログに書かれていて、まだデータファイルに反映されていない更新内容をデータファイルに反映する。

*13.5.4. InnoDB 起動オプションとシステム変数

ログファイルの出力先を/var/log/mysqlに変えたのでディレクトリを作成します。
# mkdir -p /var/log/mysql
# chown mysql:mysql /var/log/mysql


その3へ続く





お気に入りの記事を「いいね!」で応援しよう

最終更新日  2010年05月16日 00時38分17秒
コメント(0) | コメントを書く



© Rakuten Group, Inc.