Silverstripe失去与MySQL服务器的连接,需要重新启动

时间:2015-05-04 15:45:15

标签: mysql ubuntu silverstripe

首先请为这篇文章的含糊不清而道歉,但我完全不知道这里会发生什么。

我一直在为客户开发的网站遇到问题,因为客户似乎随机失去与MySQL服务器的连接,需要重新启动服务器才能使网站再次可用。我在我的投资组合中有很多其他的SS网站,而其他人之前没有经历过这种情况。

在发生此问题之前,该网站可能会运行几天或一小时或有时几周但我无法确定触发它的内容,尽管它似乎与某种相关使用CMS。客户端将报告在尝试上传照片或撰写博客文章时会失去连接。我已经在帖子的底部发布了错误,以免混乱。

认为这是服务器设置的一个问题,我设置了一个全新的数字海洋水滴并将网站迁移到那里,但问题仍然存在,这让我相信它在框架内的某些东西或者我的站点配置(旧服务器在CentOs上运行,新的服务器是Ubuntu)。

这是我使用composer设置的唯一网站。作为作曲家的新手,我按照SS网站上的说明来实现这一点。我的composer.json在下面。看起来我在这里有任何问题吗?:

{
    "name": "silverstripe/installer",
    "description": "The SilverStripe Framework Installer",
    "require": {
        "php": ">=5.3.2",
        "silverstripe/cms": "3.1.6",
        "silverstripe/framework": "3.1.6",
        "silverstripe-themes/simple": "*",
        "silverstripe/blog": "dev-master",
        "undefinedoffset/sortablegridfield": "dev-master"
    },
    "config": {
        "process-timeout": 600  
    },
    "minimum-stability": "dev"
}

我没有对核心进行任何更改。没有什么不寻常的,但我的_config.php是:

<?php

global $project;
$project = 'mysite';

global $databaseConfig;
$databaseConfig = array(
    "type" => 'MySQLDatabase',
    "server" => 'localhost',
    "username" => 'root',
    "password" => 'xxxxxx',
    "database" => 'mysite',
    "path" => '',
);

// Set the site locale
i18n::set_locale('en_US');
Director::set_environment_type('dev');
Security::setDefaultAdmin("fraser","xxxxxxx");

任何人都可以想到连接将丢弃到MySQL服务器的任何原因吗?还有什么我应该检查的吗?您还需要我的更多信息吗?

[Warning] mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '127.0.0.1' (111)

GET /

Line 68 in /var/www/mysite/framework/model/MySQLDatabase.php

Source

59   *  - password: The password to log on with
60   *  - database: The database to connect to
61   *  - timezone: (optional) The timezone offset. For example: +12:00, "Pacific/Auckland", or "SYSTEM"
62   */
63  public function __construct($parameters) {
64      if(!empty($parameters['port'])) {
65          $this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password'],
66              '', $parameters['port']);
67      } else {
68          $this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password']);
69      }
70 
71      if($this->dbConn->connect_error) {
72          $this->databaseError("Couldn't connect to MySQL database | " . $this->dbConn->connect_error);
73      }
74      
Trace

mysqli->mysqli(<filtered>,<filtered>,<filtered>) 
MySQLDatabase.php:68
MySQLDatabase->__construct(Array) 
DB.php:174
DB::connect(<filtered>) 
main.php:127
{closure}(ErrorControlChain) 
call_user_func(Closure,ErrorControlChain) 
ErrorControlChain.php:125
ErrorControlChain->step() 
ErrorControlChain.php:117
ErrorControlChain->execute() 
main.php:154
require_once(/var/www/mysite/framework/main.php) 
index.php:65
[User Error] Couldn't connect to MySQL database | Can't connect to MySQL server on '127.0.0.1' (111)

GET /

Line 598 in /var/www/mysite/framework/model/MySQLDatabase.php

Source

589     }
590 
591     public function databaseError($msg, $errorLevel = E_USER_ERROR) {
592         // try to extract and format query
593         if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
594             $formatter = new SQLFormatter();
595             $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
596         }
597 
598         user_error($msg, $errorLevel);
599     }
600 
601     /**
602      * Return a boolean type-formatted string
603      *
604      * @param array $values Contains a tokenised list of info about this data type
Trace

Couldn't connect to MySQL database | Can't connect to MySQL server on '127.0.0.1' (111) 
MySQLDatabase.php:598
MySQLDatabase->databaseError(Couldn't connect to MySQL database | Can't connect to MySQL server on '127.0.0.1' (111)) 
MySQLDatabase.php:72
MySQLDatabase->__construct(Array) 
DB.php:174
DB::connect(<filtered>) 
main.php:127
{closure}(ErrorControlChain) 
call_user_func(Closure,ErrorControlChain) 
ErrorControlChain.php:125
ErrorControlChain->step() 
ErrorControlChain.php:117
ErrorControlChain->execute() 
main.php:154
require_once(/var/www/mysite/framework/main.php) 
index.php:65

0 个答案:

没有答案