이 치료법을 시도해 보세요

이 치료법을 시도해 보세요

mysql을 사용하여 Linode의 우분투 VPS에 레일을 사용하여 애플리케이션을 실행하고 있습니다.

mysql 버전은 다음과 같습니다.

mysql  Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.2

일반적으로 모든 것이 잘 작동하지만 가끔 새 레일 콘솔을 열 때 다음 오류가 발생합니다.

/var/www/app/shared/bundle/ruby/2.0.0/gems/mysql2-0.3.14/lib/mysql2/client.rb:67:in `connect': Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) (Mysql2::Error)
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/mysql2-0.3.14/lib/mysql2/client.rb:67:in `initialize'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    from /home/user/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /var/www/app/shared/bundle/ruby/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    from /home/user/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'

콘솔에 들어가려는 모든 시도는 실패합니다. 애플리케이션이 여전히 잘 작동하고 데이터베이스를 계속 사용하고 있는 이유는 무엇입니까?

쉘에서 수행하는 경우:

$ sudo /etc/init.d/mysql status
 * MySQL is stopped.
$ sudo /etc/init.d/mysql stop
 * Stopping MySQL database server mysqld ... [ OK ] 
$ sudo /etc/init.d/mysql start
 * Starting MySQL database server mysqld ... [fail] 

하지만 응용 프로그램은 항상 잘 작동합니다.

이 세 가지 명령 이전에는 비어 있었고 /var/log/mysql/error.log그 후에는 다음을 읽었습니다.

140510 19:14:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140510 19:14:32 [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.
140510 19:14:32 [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.
140510 19:14:32 [Note] Plugin 'FEDERATED' is disabled.
140510 19:14:32 InnoDB: The InnoDB memory heap is disabled
140510 19:14:32 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140510 19:14:32 InnoDB: Compressed tables use zlib 1.2.8
140510 19:14:32 InnoDB: Using Linux native AIO
140510 19:14:32 InnoDB: Initializing buffer pool, size = 128.0M
140510 19:14:32 InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
140510 19:14:32  InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
..... several thousands of these lines... 
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
140510 19:16:12  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
140510 19:16:12  InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
140510 19:16:12 InnoDB: Could not open or create data files.
140510 19:16:12 InnoDB: If you tried to add new data files, and it failed here,
140510 19:16:12 InnoDB: you should now edit innodb_data_file_path in my.cnf back
140510 19:16:12 InnoDB: to what it was, and remove the new ibdata files InnoDB created
140510 19:16:12 InnoDB: in this failed attempt. InnoDB only wrote those files full of
140510 19:16:12 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
140510 19:16:12 InnoDB: remove old data files which contain your precious data!
140510 19:16:12 [ERROR] Plugin 'InnoDB' init function returned error.
140510 19:16:12 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140510 19:16:12 [ERROR] Unknown/unsupported storage engine: InnoDB
140510 19:16:12 [ERROR] Aborting

140510 19:16:12 [Note] /usr/sbin/mysqld: Shutdown complete

140510 19:16:12 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

VPS를 재부팅해야만 문제가 해결되는 것 같습니다. 이 문제는 한두 번의 콘솔 연결 후에 다시 발생합니다.

Mysql을 종료해도 init.d종료되지 않고 중지하려면 중지해야 한다고 생각한 kill다음 자동으로 다시 생성됩니다.

$ ps -ef | grep mysq[l]
mysql    31063     1  0 May19 ?        00:00:34 /usr/sbin/mysqld
$ sudo /etc/init.d/mysql stop
 * Stopping MySQL database server mysqld                                 [ OK ] 
$ ps -ef | grep mysq[l]
mysql    31063     1  0 May19 ?        00:00:34 /usr/sbin/mysqld
$ sudo kill -9 31063
$ ps -ef | grep mysq[l]
mysql     6052     1  3 09:23 ?        00:00:00 /usr/sbin/mysqld
$ 

어떤 단서라도 있나요?

답변1

이는 부팅하는 동안 mysql을 시작할 수 없기 때문일 수 있습니다.

이 치료법을 시도해 보세요

/etc/init.d/mysqld 다시 시작

아니면 이것을 시도해 보세요

/etc/my.cnf 파일에서 basedir 속성을 제거합니다.

왜?

basedir 지시문은 MySQL이 작동하는 데 필요한 모든 것(바이너리, 라이브러리, 데이터 등)을 찾을 수 있는 위치를 지시합니다. 따라서 basedir=/var/lib를 규정함으로써 MySQL은 기능을 수행하는 데 필요한 모든 것을 /var/lib에서 검색합니다.

RPM을 통한 일반적인 설치의 경우 이 지시어는 필요하지 않으며 사용해서는 안 됩니다. 이 지시어에 대한 더 자세한 설명을 보려면 MySQL 매뉴얼을 참조하세요.

메모

실제로 메모리 문제로 인해 이 문제에 직면한 적이 있습니다. 여유 메모리도 확인해보세요.

참조 URL

http://www.tech-recipes.com/rx/762/solve-cant-connect-to-local-mysql-server-through-socket-tmpmysqlsock/

관련 정보