MySQL随机与Magento 2停止

我有一个Ubuntu的14.04滴2GB的内存和DigitalOcean上的2个CPU,一个LAMP堆栈与我创build的Ubuntu的可靠图像的Docker容器。

在这个问题之后,我创build了1GB的交换(不是docker容器),我在[mysqld]部分的innodb_buffer_pool_size=64M设置了innodb_buffer_pool_size=64M

我以这种方式安装了MySQL(从我的Dockerfile):

 # Install MySQL RUN echo mysql-server-5.6 mysql-server/root_password password $mysql_root_password | debconf-set-selections;\ echo mysql-server-5.6 mysql-server/root_password_again password $mysql_root_password | debconf-set-selections;\ apt-get install -y mysql-server-5.6 

我用这个bash脚本创build了交换($ 1是接受脚本的第一个参数):

 #!/usr/bin/env bash # Disable case sensitivity shopt -s nocasematch if [[ ! -z $1 && ! $1 =~ false && $1 =~ ^[0-9]*$ ]]; then echo ">>> Setting up Swap ($1 MB)" # Create the Swap file sudo fallocate -l $1M /swapfile # Set the correct Swap permissions sudo chmod 600 /swapfile # Setup Swap space sudo mkswap /swapfile # Enable Swap space sudo swapon /swapfile # Make the Swap file permanent sudo echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab # Add some swap settings: # vm.swappiness=10: Means that there wont be a Swap file until memory hits 90% useage # vm.vfs_cache_pressure=50: read http://rudd-o.com/linux-and-free-software/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that sudo printf "vm.swappiness=10\nvm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.conf && sudo sysctl -p fi 

这是my.cnf文件:

 # # The MySQL database server configuration file. # # You can copy this to one of: # - "/etc/mysql/my.cnf" to set global options, # - "~/.my.cnf" to set user-specific options. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html # This will be passed to all mysql clients # It has been reported that passwords should be enclosed with ticks/quotes # escpecially if they contain "#" chars... # Remember to edit /etc/mysql/debian.cnf when changing the socket location. [client] port = 3306 socket = /var/run/mysqld/mysqld.sock # Here is entries for some specific programs # The following values assume you have at least 32M ram # This was formally known as [safe_mysqld]. Both versions are currently parsed. [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] innodb_buffer_pool_size=64M # # * 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 lc-messages-dir = /usr/share/mysql skip-external-locking # # 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 log - should be very few entries. # log_error = /var/log/mysql/error.log # # 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 # # * InnoDB # # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # Read the manual for more InnoDB related options. There are many! # # * Security Features # # Read the manual, too, if you want chroot! # chroot = /var/lib/mysql/ # # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". # # ssl-ca=/etc/mysql/cacert.pem # ssl-cert=/etc/mysql/server-cert.pem # ssl-key=/etc/mysql/server-key.pem [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] #no-auto-rehash # faster start of mysql but no tab completition [isamchk] key_buffer = 16M # # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ 

这是来自/var/log/mysql/error.log的MySQL错误日志:

 160719 10:57:36 mysqld_safe Number of processes running now: 0 160719 10:57:36 mysqld_safe mysqld restarted 2016-07-19 10:57:41 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. 2016-07-19 10:57:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-07-19 10:57:41 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 15342 ... 2016-07-19 10:57:41 15342 [Warning] Buffered warning: Performance schema disabled (reason: init failed). 2016-07-19 10:57:41 15342 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 2016-07-19 10:57:41 15342 [Note] Plugin 'FEDERATED' is disabled. 2016-07-19 10:57:42 15342 [ERROR] Function 'innodb' already exists 2016-07-19 10:57:42 15342 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'. 2016-07-19 10:57:42 15342 [ERROR] Function 'federated' already exists 2016-07-19 10:57:42 15342 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'. 2016-07-19 10:57:42 15342 [ERROR] Function 'blackhole' already exists 2016-07-19 10:57:42 15342 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'. 2016-07-19 10:57:42 15342 [ERROR] Function 'archive' already exists 2016-07-19 10:57:42 15342 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'. 2016-07-19 10:57:42 15342 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-07-19 10:57:42 15342 [Note] InnoDB: The InnoDB memory heap is disabled 2016-07-19 10:57:42 15342 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-07-19 10:57:42 15342 [Note] InnoDB: Memory barrier is not used 2016-07-19 10:57:42 15342 [Note] InnoDB: Compressed tables use zlib 1.2.8 2016-07-19 10:57:42 15342 [Note] InnoDB: Using Linux native AIO 2016-07-19 10:57:42 15342 [Note] InnoDB: Using CPU crc32 instructions 2016-07-19 10:57:43 15342 [Note] InnoDB: Initializing buffer pool, size = 64.0M 2016-07-19 10:57:44 15342 [Note] InnoDB: Completed initialization of buffer pool 2016-07-19 10:57:50 15342 [Note] InnoDB: Highest supported file format is Barracuda. 2016-07-19 10:57:50 15342 [Note] InnoDB: Log scan progressed past the checkpoint lsn 10499122273 2016-07-19 10:57:50 15342 [Note] InnoDB: Database was not shutdown normally! 2016-07-19 10:57:50 15342 [Note] InnoDB: Starting crash recovery. 2016-07-19 10:57:50 15342 [Note] InnoDB: Reading tablespace information from the .ibd files... 2016-07-19 10:59:45 15342 [Note] InnoDB: Restoring possible half-written data pages 2016-07-19 10:59:45 15342 [Note] InnoDB: from the doublewrite buffer... Killed 160719 11:00:02 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 160719 14:26:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2016-07-19 14:26:40 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. 2016-07-19 14:26:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-07-19 14:26:40 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 18656 ... 2016-07-19 14:26:40 18656 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 2016-07-19 14:26:40 18656 [Note] Plugin 'FEDERATED' is disabled. 2016-07-19 14:26:40 18656 [ERROR] Function 'innodb' already exists 2016-07-19 14:26:40 18656 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'. 2016-07-19 14:26:40 18656 [ERROR] Function 'federated' already exists 2016-07-19 14:26:40 18656 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'. 2016-07-19 14:26:40 18656 [ERROR] Function 'blackhole' already exists 2016-07-19 14:26:40 18656 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'. 2016-07-19 14:26:40 18656 [ERROR] Function 'archive' already exists 2016-07-19 14:26:40 18656 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'. 2016-07-19 14:26:40 18656 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-07-19 14:26:40 18656 [Note] InnoDB: The InnoDB memory heap is disabled 2016-07-19 14:26:40 18656 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-07-19 14:26:40 18656 [Note] InnoDB: Memory barrier is not used 2016-07-19 14:26:40 18656 [Note] InnoDB: Compressed tables use zlib 1.2.8 2016-07-19 14:26:40 18656 [Note] InnoDB: Using Linux native AIO 2016-07-19 14:26:40 18656 [Note] InnoDB: Using CPU crc32 instructions 2016-07-19 14:26:40 18656 [Note] InnoDB: Initializing buffer pool, size = 64.0M 2016-07-19 14:26:40 18656 [Note] InnoDB: Completed initialization of buffer pool 2016-07-19 14:26:40 18656 [Note] InnoDB: Highest supported file format is Barracuda. 2016-07-19 14:26:40 18656 [Note] InnoDB: Log scan progressed past the checkpoint lsn 10499122273 2016-07-19 14:26:40 18656 [Note] InnoDB: Database was not shutdown normally! 2016-07-19 14:26:40 18656 [Note] InnoDB: Starting crash recovery. 2016-07-19 14:26:40 18656 [Note] InnoDB: Reading tablespace information from the .ibd files... 2016-07-19 14:26:41 18656 [Note] InnoDB: Restoring possible half-written data pages 2016-07-19 14:26:41 18656 [Note] InnoDB: from the doublewrite buffer... InnoDB: Doing recovery: scanned up to log sequence number 10499122881 2016-07-19 14:26:41 18656 [Note] InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percent: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 InnoDB: Apply batch completed 2016-07-19 14:26:42 18656 [Note] InnoDB: 128 rollback segment(s) are active. 2016-07-19 14:26:42 18656 [Note] InnoDB: Waiting for purge to start 2016-07-19 14:26:42 18656 [Note] InnoDB: 5.6.30 started; log sequence number 10499122881 2016-07-19 14:26:42 18656 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306 2016-07-19 14:26:42 18656 [Note] - '127.0.0.1' resolves to '127.0.0.1'; 2016-07-19 14:26:42 18656 [Note] Server socket created on IP: '127.0.0.1'. 2016-07-19 14:26:42 18656 [Note] Event Scheduler: Loaded 0 events 2016-07-19 14:26:42 18656 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.6.30-0ubuntu0.14.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu) 

交换工作正常,我用cat /proc/swaps swaps和free -m命令进行检查,看到MySQL错误日志,似乎innodb_buffer_pool_size参数工作正常。

我究竟做错了什么?

谢谢。