OrientDB,OrientDB-PHP和Restler - 无法打开存储

时间:2014-01-13 05:01:51

标签: php restler orientdb

我在打开OrientDB数据库时遇到问题(orientdb-community-1.6.3)。

我可以使用$db = new OrientDB(...)访问服务器。

我可以使用$dbConnected = $db->connect(...)与我的用户管理员联系。

但是打开我的数据库或检查它是否存在会给我一个错误:com.orientechnologies.orient.core.exception.OStorageException: Cannot open the storage 'mydb' because it does not exist in path: /Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases//../databases/mydb

更多详情:

从OrientDB控制台,工作正常:

orientdb> connect plocal:../databases/mydb admin admin
Connecting to database [plocal:../databases/mydb] with user 'admin'...OK
orientDB>

PHP代码段:

$dbInfo = array (
    'datasource' => 'Database/OrientDB',
    'persistent' => true,
    'host' => 'localhost',
    'port' => 2424,
    'timeout' => 60,
    'serverUsername' => 'admin',
    'serverPassword' => 'admin',
    'database' => 'plocal:../databases/mydb',
    'databaseUsername' => 'admin',
    'databasePassword' => 'admin'
);

// New OrientDB instance
try {
    $db = new OrientDB ( $dbInfo ['host'], $dbInfo ['port'], $dbInfo ['timeout'] );
    error_log ( "dbUtil.php:dbOpen: new Orient:db:" . print_r ( $db, true ) );
} catch ( Exception $e ) {
    // Report error connecting to server
    $exception = 404;
    $message .= 'Database server ' . $dbInfo ['host'] . ':' . $dbInfo ['port'] . ' did not respond. ' . $e->getMessage ();
}

if ($db) {
    // Made the connection to the server, connect as user $dbInfo ['serverUsername']
    try {
        $dbConnected = $db->connect ( $dbInfo ['serverUsername'], $dbInfo ['serverPassword'] );
        error_log ( "dbUtil.php:dbOpen:dbConnected:" . $dbConnected );
    } catch ( OrientDBException $e ) {
        // Report error on $db->connect
        $exception = 400;
        $message .= 'Unable to connect to ' . $dbInfo ['datasource'] . ' as user ' . $dbInfo ['serverUsername'] . '. ' . $e->getMessage ();
    }

    // Open the database
    if ($dbConnected) {
        try {
            $dbExists = $db->DBExists ( $dbInfo ['database'] );
            error_log ( "dbUtil.php:dbOpen(" . $dbInfo ['database'] . "):dbExists:" . $dbExists );
            if (! $dbExists) {
                // Report database does not exist
                $exception = 404;
                $message .= "Database " . $dbInfo ['database'] . ' does not exist.';
            }
        } catch ( OrientDBException $e ) {
            // Report err on $db->DBExists
            $exception = 404;
            $message .= "Error checking the existence of database " . $dbInfo ['database'] . ". " . $e->getMessage ();
        }
        if ($dbExists) {
            try {
                $dbClusters = $db->DBOpen ( $dbInfo ['database'], $dbInfo ['databaseUsername'], $dbInfo ['databasePassword'] );
                error_log ( "dbUtil.php:dbOpen:DBOpen:dbClusters:" . print_r ( $dbClusters, true ) );
            } catch ( OrientDBException $e ) {
                // Report error opening database
                $exception = 400;
                $message .= "Error opening database " . $dbInfo ['datasource'] . ' as user ' . $dbInfo ['databaseUsername'] . '. ' . $e->getMessage ();
            }
        }
    }
}

// Any problems?
if ($exception != 200) {
    throw new RestException ( $exception, $message );
}

错误日志:

[13-Jan-2014 04:33:22 UTC] dbUtil.php:dbOpen: new Orient:db:OrientDB Object
(
[host:OrientDB:private] => localhost
[port:OrientDB:private] => 2424
[socket] => OrientDBSocket Object
    (
        [socket:OrientDBSocket:private] => Resource id #2
        [bufferLen:OrientDBSocket:private] => 16384
        [debug] => 
    )

[debug:OrientDB:private] => 
[clientVersion] => 15
[protocolVersion] => 
[connected:protected] => 
[DBOpen:protected] => 
[active:protected] => 1
[sessionIDServer:OrientDB:private] => 
[sessionIDDB:OrientDB:private] => 
[cachedRecords] => Array
    (
    )

)

[13-Jan-2014 04:33:22 UTC] dbUtil.php:dbOpen:dbConnected:1
[13-Jan-2014 04:33:22 UTC] dbUtil.php:dbOpen(plocal:../databases/mydb):dbExists:

错误消息中的ls路径:

$ ls -la /Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases//../databases/mydb
total 5984
drwxr-xr-x  58 kent  staff    1972 Jan 12 20:47 .
drwxr-xr-x   4 kent  staff     136 Jan 12 16:43 ..
-rw-r--r--   1 kent  staff   66560 Jan 12 20:47 ORole.name.sbt
-rw-r--r--   1 kent  staff   66560 Jan 12 20:47 OUser.name.sbt
..

有什么想法吗?

谢谢

**更新2014-01-19 ** 将FINEST日志添加到服务器。

 2014-01-19 19:06:11:597 FINE [OMMapManagerNew] flushing pages in memory... [OMMapManagerNew]
 2014-01-19 19:06:11:597 FINE [OMMapManagerNew] flushed 0/0 blocks [OMMapManagerNew]
 2014-01-19 19:06:13:731 CONF Remote client connected from: OClientConnection [id=34, source=?, since=1390187173731] [OClientConnectionManager]
 2014-01-19 19:06:13:733 CONF Remote client connected from: OClientConnection [id=35, source=/127.0.0.1:60842, since=1390187173732] [OClientConnectionManager]
 2014-01-19 19:06:13:736 FINE Disconnecting connection OClientConnection [id=35, source=/127.0.0.1:60842, since=1390187173732]... [OClientConnectionManager]
 2014-01-19 19:06:13:736 FINE Disconnected connection OClientConnection [id=35, source=/127.0.0.1:60842, since=1390187173732] found 1 channels [OClientConnectionManager]
 2014-01-19 19:06:14:080 FINE [OClientConnectionManager] found and removed pending closed channel 34 (Socket[addr=/127.0.0.1,port=60842,localport=2424]) [OClientConnectionManager$1]
 2014-01-19 19:06:41:597 FINE [OMMapManagerNew] flushing pages in memory... [OMMapManagerNew]
 2014-01-19 19:06:41:597 FINE [OMMapManagerNew] flushed 0/0 blocks [OMMapManagerNew]

连接到服务器后添加error_log ( "dbUtil.php.dbOpen:list of databases:" . print_r($db->DBList(), true));

 [20-Jan-2014 03:06:13 UTC] dbUtil.php.dbOpen:list of databases:Array
 (
   [docitt] => plocal:/Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases/docitt
   [GratefulDeadConcerts] => plocal:/Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases/GratefulDeadConcerts
 )

然后使用plocal:/Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases/docitt作为数据库名称。同样的错误:Database plocal:/Users/kent/dev/Database/releases/orientdb-community-1.6.3/databases/docitt does not exist.

1 个答案:

答案 0 :(得分:1)

我尝试打开plocal:../databases/mydb的数据库是plocalgraph数据库类型(orientdb-community-1.6.3的当前默认值)。 OrientDB-PHP尚不支持graph数据库类型document :(