更改数据目录后 NextCloud SNAP 无法启动

更改数据目录后 NextCloud SNAP 无法启动

我已经在我的 Ubuntu 18.04 服务器上安装了 NextCloud snap。

安装成功后,我通过命令行创建了一个用户,然后将数据目录更改为一个新的媒体驱动器,该驱动器通过符号软链接链接到目录 /cloud-data。

具体来说,我经历了以下步骤:

  1. 我已经连接了可移动媒体插头:

    sudo snap connect nextcloud:removable-media
    
  2. 禁用快照:

    sudo snap disable nextcloud
    
  3. 我已经更改了datadirectory/var/snap/nextcloud/current/nextcloud/config/config.php新的配置是:

    $CONFIG = array (
    'apps_paths' =>
      array (
    0 =>
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
      ),
      'supportedDatabases' =>
      array (
        0 => 'mysql',
      ),
      'memcache.locking' => '\\OC\\Memcache\\Redis',
      'memcache.local' => '\\OC\\Memcache\\Redis',
      'redis' =>
      array (
        'host' => '/tmp/sockets/redis.sock',
        'port' => 0,
      ),
      'passwordsalt' => '<<char-sequence>>',
      'secret' => '<<char-sequence>>',
      'trusted_domains' =>
      array (
        0 => 'localhost',
        1 => '192.168.1.30',
      ),
      // 'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
      'datadirectory' => '/cloud-data/data',
      'overwrite.cli.url' => 'http://localhost',
      'dbtype' => 'mysql',
      'version' => '13.0.7.2',
      'dbname' => 'nextcloud',
      'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
      'dbport' => '',
      'dbtableprefix' => 'oc_',
      'mysql.utf8mb4' => true,
      'dbuser' => 'nextcloud',
      'dbpassword' => '<<char-sequence>>',
      'installed' => true,
      'instanceid' => 'oczhujw1qh25',
    );
    
  4. 将数据目录移至新目录:

    sudo mv /var/snap/nextcloud/common/nextcloud/data /cloud-data
    
  5. 启用快照:

     sudo snap enable nextcloud.
    

然后,如果我浏览到192.168.1.30,我会看到一个错误页面:

服务器遇到内部错误,无法完成您的请求。

查看日志,我发现以下错误:

{"reqId":"JQPdFyDWw7il9i9imtwS","level":3,"time":"2018-11-03T21:50:29+00:00","remoteAddr":"192.168.1.81","user":"myadminuser","app":"index","method":"GET","url":"\/index.php\/settings\/apps\/categories","message":"Exception:
{\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\
UniqueConstraintViolationException\",\"Message\":\"An exception occurred while executing 'INSERT INTO `oc_filecache` 
(`mimepart`,`mimetype`,`mtime`,`size`,`etag`,`storage_mtime`,`permissions`,`parent`,`checksum`,`path_hash`,`path`,`name`,`storage`) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM `oc_filecache` WHERE `storage` = ? AND `path_hash` = ? HAVING COUNT(*) = 0' with params [\\\"3\\\", \\\"19\\\", 1541281829, 0, \\\"8b012c172b627b19e3868612eda23a78\\\", 1541281829, 27, 137, \\\"\\\", \\\"c1139e3e0630754d022ce4372e608e19\\\", \\\"appdata_oczhujw1qh25\\\\\\\/appstore\\\\\\\/apps.json\\\", \\\"apps.json\\\", 2, 2, \\\"c1139e3e0630754d022ce4372e608e19\\\"]:\\n\\n
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-c1139e3e0630754d022ce4372e608e19' for key 'fs_storage_path_hash'\",\"Code\":0,\"Trace\":\"#0 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/
DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(1015): Doctrine\\\\DBAL\\\\
DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'INSERT INTO `oc...', Array)\\n#2 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Connection.php(216): 
Doctrine\\\\DBAL\\\\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)\\n#3 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Adapter.php(114): OC\\\\DB\\\\Connection->executeUpdate('INSERT INTO `oc...', Array)\\n#4 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Connection.php(254): OC\\\\DB\\\\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#5 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(273): OC\\\\DB\\\\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#6 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(230): OC\\\\Files\\\\Cache\\\\Cache->insert('appdata_oczhujw...', Array)\\n#7 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(292): OC\\\\Files\\\\Cache\\\\Cache->put('appdata_oczhujw...', Array)\\n#8 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(221): OC\\\\Files\\\\Cache\\\\Scanner->addToCache('appdata_oczhujw...', Array, -1)\\n#9 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(336): OC\\\\Files\\\\Cache\\\\Scanner->scanFile('appdata_oczhujw...', 3, 137, false, true)\\n#10 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/View.php(1326): OC\\\\Files\\\\Cache\\\\Scanner->scan('appdata_oczhujw...', false)\\n#11 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/View.php(1369): OC\\\\Files\\\\View->getCacheEntry(Object(OCA\\\\Files_Trashbin\\\\Storage), 'appdata_oczhujw...', '\\\/appdata_oczhuj...')\\n#12 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Node\\\/Root.php(198): OC\\\\Files\\\\View->getFileInfo('\\\/appdata_oczhuj...')\\n#13 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Node\\\/Folder.php(133): OC\\\\Files\\\\Node\\\\Root->get('\\\/appdata_oczhuj...')\\n#14 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/SimpleFS\\\/SimpleFolder.php(73): OC\\\\Files\\\\Node\\\\Folder->get('apps.json')\\n#15 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/App\\\/AppStore\\\/Fetcher\\\/Fetcher.php(145): OC\\\\Files\\\\SimpleFS\\\\SimpleFolder->getFile('apps.json')\\n#16 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Installer.php(401): OC\\\\App\\\\AppStore\\\\Fetcher\\\\Fetcher->get()\\n#17 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(292): OC\\\\Installer->isUpdateAvailable('activity')\\n#18 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(144): OC\\\\Settings\\\\Controller\\\\AppSettingsController->getAppsWithUpdates()\\n#19 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(170): OC\\\\Settings\\\\Controller\\\\AppSettingsController->getAllCategories()\\n#20 [internal function]: OC\\\\Settings\\\\Controller\\\\AppSettingsController->listCategories()\\n#21 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#22 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Settings\\\\Controller\\\\AppSettingsController), 'listCategories')\\n#23 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Settings\\\\Controller\\\\AppSettingsController), 'listCategories')\\n#24 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Settings\\\\\\\\Con...', 'listCategories', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#25 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#26 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#27 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/base.php(999): OC\\\\Route\\\\Router->match('\\\/settings\\\/apps\\\/...')\\n#28 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/index.php(42): OC::handleRequest()\\n#29 {main}\",\"File\":\"\\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":66}","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.77 Safari\/537.36","version":"13.0.7.2"}

我试图截断表格oc_filecache,希望再生后一切顺利,但什么都没有改变。

我已按照官方网站上的说明进行操作,但我认为缺少了一些东西。也许我需要在数据库中更改某些内容?或者可能是chown针对特定用户?

答案1

发现问题:

我无法使用软链接在配置文件中。

插入后真实路径/media/sdb/data)一切顺利

相关内容