简体   繁体   English

gridfs mongodb和php脚本

[英]gridfs mongodb and php script

I have a php script who inserts documents in gridfs. 我有一个php脚本,可在gridfs中插入文档。 in this DB i have 1346214 document. 在这个数据库中,我有1346214文档。 when i run this script for adding 10500 document i have this error 当我运行此脚本以添加10500文档时,出现此错误

 PHP Fatal error:  Uncaught exception 'MongoConnectionException' with message 'Failed to   connect to: 127.0.0.1:27017: Cannot assign requested address' in /root/upload.php:5
Stack trace:
#0 /root/upload.php(5): Mongo->__construct('127.0.0.1:27017')
#1 {main}
  thrown in /root/upload.php on line 5

in mongod.log i have this message 在mongod.log中,我有此消息

2014-05-08T12:24:13.537+0200 [initandlisten] connection accepted from 127.0.0.1:57221 #93806 (63 connections now open)
2014-05-08T12:24:13.538+0200 [conn93806]  authenticate db: uniform_server { authenticate: 1, user: "user", nonce: "xxx", key: "xxx" }
2014-05-08T12:24:13.538+0200 [conn93806] Failed to authenticate user@uniform_server with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user user@uniform_server
2014-05-08T12:24:13.538+0200 [conn93806] end connection 127.0.0.1:57221 (62 connections now open)

have you any idea about this problem? 您对这个问题有任何想法吗?

Thanks 谢谢

This is the content of the php script and i run it 10500 via this command for i in {1..10500..1}; 这是php脚本的内容,我在{1..10500..1}中通过此命令为我运行了10500; do php upload.php; 做php upload.php; done 完成

    <?php

    $conn = new Mongo("127.0.0.1:27017");         // Connect
    $db = $conn->uniform_server;                // Select DB
    $db->authenticate("user","passwd");        // Authenticate to MongoDB
    $grid = $db->getGridFS();                    // Initialize GridFS
    $tab_pj = array("document0.pdf",
                    "document1.tif",
                    "document2.doc",
                    "document3.png",
                    "document4.JPG",
                    "document5.xls",
                    "document6.rar", 
                    "document7.ppt",
                    "document8.rtf"
                    );
    $pj_id = rand(0,8);                 
    $name = $tab_pj[0];        // Get Uploaded file name
    $id = $grid->storeFile($name);    // Store uploaded file to GridFS

    $conn->close();  // Close connection

    exit(0);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM