現在、大きなデータセットをInnodbテーブルにインポートするためのPHPスクリプトを作成しました。このスクリプトは、ファイルからレコードを読み取り、複数のクエリを作成し(データは高度にリレーショナルです)、それらをデータベースに挿入します。このスクリプトは、1つのコアと2GBのメモリで構築された新しいDebianVMで作成しました。
明確にするために、新鮮とは、パッケージmysql-servermysql-clientとphp5のみがインストールされたクリーンなイメージであることを意味します。
VM 2でスクリプトを実行すると、データファイル(それぞれ60MB以上)が8秒以内に完了し、5,000を超えるレコードが挿入されました。
次に、このスクリプトを、現在データを保持し、データベースを保持するサーバーに移動しました。このサーバーには、28GBのRAMと2つのXEON(6core)プロセッサが搭載されています。これは、デフォルトのmysql-client、mysql-server、およびphp5-cliがインストールされたフレッシュインストールでもあります。明確にするために、スクリプトの開始時にデータベースは空であり、サーバーにはSSHと標準のシステムプロセス以外のプロセスが実行されていません。
このサーバーでスクリプトを実行すると、移動が非常に遅くなります(30秒で180レコードのみが挿入されます)。
my.cnfファイルでskip-name-resolveを試しましたが、何も実行されないようです。スクリプトの実行中にmysqlでプロセスリストを表示すると、挿入クエリが常に「アイテムの解放」状態になっていることがわかります。何が減速を引き起こす可能性があるかについてのアイデアはありますか?
これが問題を引き起こしているサーバー上のmy.cnfです::
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
skip-name-resolve
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name