环境:阿里云 CentOS6.5 512M内存
执行:RAILS_ENV=production bundle exec rake db:migrate
报错:
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
/var/www/redmine/app/models/issue_relation.rb:73:in `<class:IssueRelation>'
/var/www/redmine/app/models/issue_relation.rb:18:in `<top (required)>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:28:in `<class:Gantt>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:21:in `<module:Helpers>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:19:in `<module:Redmine>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:18:in `<top (required)>'
/var/www/redmine/lib/redmine.rb:56:in `<top (required)>'
/var/www/redmine/config/initializers/30-redmine.rb:4:in `<top (required)>'
/var/www/redmine/config/environment.rb:14:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
然后Mysql就挂了。
RAILS_ENV=production bundle exec rake --trace db:migrate
详细日志:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2/client.rb:70:in `connect'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2/client.rb:70:in `initialize'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/usr/local/ruby/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/usr/local/ruby/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/model_schema.rb:224:in `table_exists?'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_methods/primary_key.rb:75:in `get_primary_key'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_methods/primary_key.rb:60:in `reset_primary_key'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_methods/primary_key.rb:49:in `primary_key'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activerecord-3.2.19/lib/active_record/attribute_assignment.rb:13:in `attributes_protected_by_default'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:216:in `block in protected_attributes_configs'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:188:in `yield'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:188:in `protected_attributes'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:118:in `block in attr_protected'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:117:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activemodel-3.2.19/lib/active_model/mass_assignment_security.rb:117:in `attr_protected'
/var/www/redmine/app/models/issue_relation.rb:73:in `<class:IssueRelation>'
/var/www/redmine/app/models/issue_relation.rb:18:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:359:in `require_or_load'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:502:in `load_missing_constant'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:192:in `block in const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:514:in `load_missing_constant'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:192:in `block in const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:514:in `load_missing_constant'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:192:in `block in const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:514:in `load_missing_constant'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:192:in `block in const_missing'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:190:in `const_missing'
/var/www/redmine/lib/redmine/helpers/gantt.rb:28:in `<class:Gantt>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:21:in `<module:Helpers>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:19:in `<module:Redmine>'
/var/www/redmine/lib/redmine/helpers/gantt.rb:18:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/var/www/redmine/lib/redmine.rb:56:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/var/www/redmine/config/initializers/30-redmine.rb:4:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:245:in `load'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:245:in `block in load'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:245:in `load'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/engine.rb:592:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/engine.rb:592:in `block in <class:Engine>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `run'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/application.rb:136:in `initialize!'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/redmine/config/environment.rb:14:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/application.rb:103:in `require_environment!'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/railties-3.2.19/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/usr/local/ruby/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:197:in `block in invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:195:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
/usr/local/ruby/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/ruby/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/usr/local/bin/rake:33:in `<main>'
Tasks: TOP => db:migrate => environment
MySQL日志
140926 22:23:37 mysqld_safe mysqld from pid file /usr/local/mysql/data/zebenGL.pid ended
140926 22:25:45 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2014-09-26 22:25:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-26 22:25:46 17825 [Note] Plugin 'FEDERATED' is disabled.
2014-09-26 22:25:46 17825 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-09-26 22:25:46 17825 [Note] InnoDB: The InnoDB memory heap is disabled
2014-09-26 22:25:46 17825 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-09-26 22:25:46 17825 [Note] InnoDB: Memory barrier is not used
2014-09-26 22:25:46 17825 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-09-26 22:25:46 17825 [Note] InnoDB: Using Linux native AIO
2014-09-26 22:25:46 17825 [Note] InnoDB: Using CPU crc32 instructions
2014-09-26 22:25:46 17825 [Note] InnoDB: Initializing buffer pool, size = 8.0M
2014-09-26 22:25:46 17825 [Note] InnoDB: Completed initialization of buffer pool
2014-09-26 22:25:46 17825 [Note] InnoDB: Highest supported file format is Barracuda.
2014-09-26 22:25:46 17825 [Note] InnoDB: The log sequence numbers 1626646 and 1626646 in ibdata files do not match the log sequence number 1626686 in the ib_logfiles!
2014-09-26 22:25:46 17825 [Note] InnoDB: Database was not shutdown normally!
2014-09-26 22:25:46 17825 [Note] InnoDB: Starting crash recovery.
2014-09-26 22:25:46 17825 [Note] InnoDB: Reading tablespace information from the .ibd files...
2014-09-26 22:25:46 17825 [Note] InnoDB: Restoring possible half-written data pages
2014-09-26 22:25:46 17825 [Note] InnoDB: from the doublewrite buffer...
2014-09-26 22:25:46 17825 [Note] InnoDB: 128 rollback segment(s) are active.
2014-09-26 22:25:46 17825 [Note] InnoDB: Waiting for purge to start
2014-09-26 22:25:46 17825 [Note] InnoDB: 5.6.20 started; log sequence number 1626686
2014-09-26 22:25:46 17825 [Note] Server hostname (bind-address): '*'; port: 3306
2014-09-26 22:25:46 17825 [Note] IPv6 is not available.
2014-09-26 22:25:46 17825 [Note] - '0.0.0.0' resolves to '0.0.0.0';
2014-09-26 22:25:46 17825 [Note] Server socket created on IP: '0.0.0.0'.
2014-09-26 22:25:47 17825 [Note] Event Scheduler: Loaded 0 events
2014-09-26 22:25:47 17825 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.20' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
140926 22:27:14 mysqld_safe Number of processes running now: 0
140926 22:27:14 mysqld_safe mysqld restarted
2014-09-26 22:27:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
140926 22:27:17 mysqld_safe mysqld from pid file /usr/local/mysql/data/zebenGL.pid ended
如果你确认mysql启动的话,看看是不是 '/tmp/mysql.sock'啊!!!
怎么看呢??