有没有办法在树莓派2中将mongodb从2.4更新到2.6?

时间:2019-04-03 09:33:42

标签: node.js mongodb raspbian raspberry-pi2

我正在尝试通过将Raspberry Pi 2与DietPi(DietPi v6.22.3),mongodb和nodejs结合使用,通过简单的mongo选择构建实时图表。

我想做的是使用类似的东西从数据库中获取数据:

var express = require('express');
var app = express();
var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://IP:PORT/DATABASE';
var str = "";

app.route('/page_A').get(function (req, res) {
    MongoClient.connect(url, function (err, db) {
        if (err) {
            console.log(err);
        } else {
            console.log("Connected to db");
            var cursor = db.collection('COLLECTION_X').find();
            //noinspection JSDeprecatedSymbols
            cursor.each(function (err, item) {

                if (item != null) {
                    str = str + "    DateTime  " + item.dt + " - Users:  " + item.users + " </br>";
                }
            });
            res.send(str);
            db.close();
        }
    });
});

var server = app.listen(8080, function () {});

运行节点app.js并访问指定的IP:8080 / page_A,出现以下错误:

(node:3920) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
{ MongoError: Server at IP:PORT reports maximum wire version 0, but this version of the Node.js Driver requires at least 2 (MongoDB 2.6)
    at checkSupportedServer (/PATH_Y/node_modules/mongodb-core/lib/connection/connect.js:100:10)
    at runCommand (/PATH_Y/node_modules/mongodb-core/lib/connection/connect.js:137:32)
    at Connection.messageHandler (/PATH_Y/node_modules/mongodb-core/lib/connection/connect.js:334:5)
    at Connection.emit (events.js:189:13)
    at processMessage (/PATH_Y/node_modules/mongodb-core/lib/connection/connection.js:364:10)
    at Socket.<anonymous> (/PATH_Y/node_modules/mongodb-core/lib/connection/connection.js:533:15)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10) name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} }

显然,我不能在此mongoDB版本上使用这些方法。 有什么办法可以将其更新到2.6?

以下是我的设置的一些详细信息:

mongod --version
db version v2.4.14

node --version
v10.15.3


cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

cat /etc/debian_version
9.8

uname -a
Linux DietPi 4.14.98+ #1200 Tue Feb 12 20:11:02 GMT 2019 armv6l GNU/Linux

cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2835
Revision        : 000e
Serial          : 00000000ce0ee037

(并且还尝试更新mongo失败)

sudo apt-get install mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mongodb-org

谢谢

eunito。

0 个答案:

没有答案