docker run -it -p 27017:27017 -v /data/source:/mnt daocloud.io/daocloud/dao-mongodb:master-43ead5d
以新的console连接到已经运行的docker中: docker exec -it 1320e51669e2 bash 然后运行进行数据库初始化:
./mongodump -d canbar -o canbar_dump_906
//There is a dir /mnt/lezuzu_api_data/canbar
// -drop 先删除db,再恢复
./mongorestore -d canbar /mnt/lezuzu_api_data/*
然后运行mongo可查看数据库记录。
修改mongodb的连接点信息: C:\DevOps\meanjs\config\env\development.js
docker run -v /data/source:/mnt --privileged=true -it -p 3000:3000 strongloop/node bash
访问此链接能成功,并能查询到数据: http://123.57.188.123:3000/explorer
git clone下meanjs项目,并cd 到该mean目录下: docker-compose up
docker run -it -p 5858:5858 -v /data/source:/mnt dudymas/meanjs bash
修改mongodb的连接点信息:
cd /mnt/meanjs
运行 node mobi_server.js
NODE_ENV is not defined! Using default development environment
module.js:356
Module._extensions[extension](this, filename);
^
Error: libcairo.so.2: cannot open shared object file: No such file or directory
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/mnt/meanjs/node_modules/qrcode/node_modules/canvas/lib/bindings.js:2:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
solution: 缺省一些系统的库文件,因为不是npm install的modules(暂时是拷贝的) 宿主机器上应该安装(Ubuntu): sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Rico:事实上应该在meanjs的container内安装,因为下来的image应该带着os。
下面的错误暂时忽略。
Get:97 http://archive.ubuntu.com/ubuntu/ trusty/main libx11-doc all 2:1.6.2-1ubuntu2 [1448 kB]
Fetched 25.9 MB in 2min 24s (179 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apparmor/dh-apparmor_2.8.95~2430-0ubuntu5.2_all.deb 404 Not Found [IP: 91.189.91.24 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
再运行,报同样错误 重新安装qrcode module: npm install canvas //npm install qrcode
发现新问题:
npm install canvas
npm http GET https://registry.npmjs.org/canvas
npm http 304 https://registry.npmjs.org/canvas
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan
> [email protected] install /mnt/meanjs/node_modules/canvas
> node-gyp rebuild
./util/has_cairo_freetype.sh: 4: ./util/has_cairo_freetype.sh: pkg-config: not found
gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-32-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /mnt/meanjs/node_modules/canvas
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! weird error 1
npm ERR! not ok code 0
search find / -name pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig /usr/share/pkgconfig
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
export PKG_CONFIG_PATH=/usr/bin/pkg-config (GZ_QQ)
pkg-config 和pkgconfig 的区别? which pkg-config /usr/bin/pkg-config
重新查找meanjs的image源: dao pull maccam912/meanjs:latest You can find it with 'docker images maccam912/meanjs:latest'
跟新node.js:
npm install n
n latest
install : node-v0.12.7
mkdir : /usr/local/n/versions/node/0.12.7
fetch : https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
Error: libjpeg.so.8: cannot open shared object file: No such file or directory
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
/usr/lib/x86_64-linux-gnu/libjpeg.so cd /usr/lib/x86_64-linux-gnu/ ln -s ./libjpeg.so.62.1.0 libjpeg.so.8
apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libcairo2-dev
E: Unable to locate package libjpeg8-dev
E: Unable to locate package libpango1.0-dev
E: Couldn't find any package by regex 'libpango1.0-dev'
E: Unable to locate package libgif-dev
更新软件源: apt-get update 然后再次安装所缺的库,成功!
启动mobi服务:
node mobi_server.js
NODE_ENV is not defined! Using default development environment
========================================================================================
= Please ensure that you set the default safe variable to one of the =
= allowed values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}] =
= the default value is false which means the driver receives does not =
= return the information of the success/error of the insert/update/remove =
= =
= ex: new Db(new Server('localhost', 27017), {safe:false}) =
= =
= http://www.mongodb.org/display/DOCS/getLastError+Command =
= =
= The default of false will change to true in the near future =
= =
= This message will disappear when the default safe is set on the driver Db =
========================================================================================
MEAN.JS application started on port 5858
/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:246
throw message;
^
TypeError: Cannot read property 'length' of undefined
at processResults (/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1581:31)
at /mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1619:20
at /mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1157:7
at /mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1890:9
at Server.Base._callHandler (/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:448:41)
at /mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:481:18
at MongoReply.parseBody (/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:439:20)
at EventEmitter.emit (events.js:95:17)
at null.<anonymous> (/mnt/meanjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
缺省sessions collection,还有system.indexes
db.sessions.findOne()
{
"_id" : "QuiGVN0W97w2WZ0Q_S3Q764lWbNZsXY1",
"session" : "{\"cookie\":{\"originalMaxAge\":null,\"expires\":null,\"secure\":false,\"httpOnly\":true,\"path\":\"/\"},\"passport\":{}}",
"expires" : ISODate("2015-07-29T02:56:09.359Z")
}
重新安装 npm install mongoose
root@e84947f9e0ca:/mnt/meanjs# node mobi_server.js
然后正常了!