nginx + mongodb
4420 단어 mongodb
/ mongodb git
// nginx-gridfs
: nginx-gridfs
// nginx
/usr/local/pcre-8.38
pcre:
tar -xzvf pcre-8.21.tar.gz
cd pcre-8.21
./configure && make && make install
tar -zxvf nginx-xxx.tar.gz
cd nginx-xxx
./configure --add-module=/usr/local/nginx-gridfs --with-http_stub_status_module --with-pcre=/usr/local/pcre-8.38
make
make install
nginx -V
nginx: nginx version: nginx/1.0.1
nginx: built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
nginx: configure arguments: --add-module=/usr/local/nginx-gridfs --with-http_stub_status_module --with-pcre=/usr/local/pcre-8.38
【/usr/local/nginx-gridfs/ nginx-gridfs 】
// nginx
/usr/local/nginx/conf/nginx.conf 。
: ,nginx nginx.conf , ;
nginx.conf server :
location /pics/ {
gridfs pics field=filename type=string;
mongo 114.35.2.17:27017;
}
【my_app mongodb 】
// nginx
// :http://192.168.1.109:28118/gridfs/6b6e567cjw1dmea3323e1j.jpg。
mongofiles put weixin_qrcode_EsYe.jpg -h127.0.0.1 -db pics -t jpg
connected to: 127.0.0.1
added file: { _id: ObjectId('56a86cc854e10ebac7c9c5e2'), filename: "weixin_qrcode_EsYe.jpg", chunkSize: 262144, uploadDate: new Date(1453878472772), md5: "138b8a395ee91dddaea9b913334ca2a7", length: 37555, contentType: "jpg" }
done
filename')
-t [ --type ] arg MIME type for put (default is to omit)
use tt
, , . :
db.usr.insert({'name':'tompig'});
db.usr.insert({'name':'tompig1','id':1});
> use tt
switched to db tt
> db.usr.insert({'name':'tompig'});
> db.usr.insert({'name':'tompig1','id':1});
> db.getCollectionNames();
[ "system.indexes", "usr" ]
> db.userInfo.find();
> select * from user;
Wed Jan 27 14:44:18.923 SyntaxError: Unexpected identifier
> db.user.find();
> db.usr.find()
{ "_id" : ObjectId("56a867082830668c6cd6a8e5"), "name" : "tompig" }
{ "_id" : ObjectId("56a867092830668c6cd6a8e6"), "name" : "tompig1", "id" : 1 }
http://192.168.32.34/pics/weixin_qrcode_EsYe.jpg
[root@yytpxt ~]# mongofiles list -h114.55.5.57 -db pics
connected to: 114.55.5.57
weixin_qrcode_b_YH.jpg 38916
Mongo connection dropped, could not reconnect,
11. :
sudo mongofiles put --host localhost --port 27017 --db img --local ~/photo.jpg --type jpg
Error: need a filename , --local ~/photo.jpg xxxname.jpg (http://hi.baidu.com/manbuzhiwu/item/9adbce5d45405811e6c4a59c)
mongofiles put --host localhost --port 27017 --db img --local ~/photo.jpg --type jpg
redis01:/root# mongofiles put --host 192.168.32.34 --port 27017 --db pics 1.gif --type gif
connected to: 192.168.32.34:27017
added file: { _id: ObjectId('56a972f55f55d2eb2ae1de18'), filename: "1.gif", chunkSize: 262144, uploadDate: new Date(1453945589610), md5: "5752b38d6c10dd9b9a15792b86b46947", length: 22718, contentType: "gif" }
done!
redis01:/root# mongofiles -h 192.168.32.34 list -db pics
connected to: 192.168.32.34
q.jpg 79398
test6.jpg 6759
1.gif 22718
mongdb :
redis01:/root# /usr/local/mongodb/bin/mongod --bind_ip 192.168.32.34 -f /usr/local/mongodb/bin/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1403
all output going to: /usr/local/mongodb/logs/mongodb.log
mongdb :
redis01:/root# mongofiles put q.jpg -h192.168.32.34 -db pics -t jpg
connected to: 192.168.32.34
added file: { _id: ObjectId('56a87ec80004fad5d9bdae4a'), filename: "q.jpg", chunkSize: 262144, uploadDate: new Date(1453883081024), md5: "196fea5be1558e28067d7e1e2c1ebc0d", length: 79398, contentType: "jpg" }
done!
redis01:/root#
redis01:/root# cat /usr/local/mongodb/bin/mongodb.conf
dbpath=/usr/local/mongodb/db
logpath=/usr/local/mongodb/logs/mongodb.log
port=27017
fork=true
nohttpinterface=true
redis01:/root#
}
location /pics/ {
gridfs pics field=filename type=string;
mongo 192.168.32.34:27017;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
레코드를 업데이트하고 업데이트 전에 동일한 레코드를 삭제하는 방법(nest js & mongoDB)ID로 레코드를 업데이트하고 싶지만 업데이트 전에 동일한 레코드에 이전에 저장된 데이터를 삭제하고 싶습니다. 프로세스는 무엇입니까? 컨트롤러.ts 서비스.ts 나는 이것을 해결하기 위해 이런 식으로 노력하고 있습니다...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.