Detailed analysis of MongoDB's GridFS

WBOY
Release: 2016-08-08 09:22:31
Original
952 people have browsed it
GridFSIntroductionGridFS is a built-in feature in MongoDB, which can be used to store a large number of small files. http://www.mongodb.org/display/DOCS/GridFShttp://www.mongodb.org/display/DOCS/GridFS+Specification
GridFSUse MongoDB A command line tool mongofiles is provided to process GridFS, in the bin directory. List all files: mongofiles listUpload a file: mongofiles put xxx.txtDownload a file: mongofiles get xxx.txtSearch for files: mongofiles search xxx // will find all files whose file names contain "xxx" mongofiles list xxx // will find all files whose file names are prefixed with "xxx" Parameter description: –d Specify database, the default is fs, Mongofiles list –d testGridfs-u –p Specify user name, password -h Specify host -port Specify host port -c Specify the collection name, the default is fs-t Specify the MIME type of the file, the default will ignore Use MongoVUE to view and manage GridFSMongoVUEAddress: http://www.mongovue.com/MongoVUE is a free software, but its functions are limited after 15. You can remove the restriction by deleting the following registry key: [HKEY_CURRENT_USERSoftwareClassesCLSID{B1159E65-821C3-21C5-CE21-34A484D54444}4FF78130]Just delete all the values ​​under this key.
nginx-gridfs module installation and useProject homepage: https://github.com/mdirolf/nginx-gridfsThrough nginx-gridfs, you can directly use http to access the files in GridFS . 1. InstallInstall various dependency packages: zlib, pcre, openssl Under ubuntu the following command may be: sudo apt-get install zlib1g- dev                 //It seems that sudo apt-get install zlib-dev cannot be installedsudo apt-get install libpcre3 libpcre3-devsudo apt-get install openssl libssl-devinstallgit (omitted) git下载nginx-gridfs的代码:git clone git://github.com/mdirolf/nginx-gridfs.git    cd nginx-gridfs    git submodule init    git submodule update
Downloadnginx: wget http://nginx.org/download/nginx-1.0.12.ziptar zxvf nginx-1.0.12.zipcd nginx-1.0.12 ./configure --add-module=>makesudo make installIf there is a compilation error, add -- when configure with-cc-opt=-Wno-error parameter.
2. Configuration nginxAdd the following to the configuration of server location /pics/ { “ gridfs pics                  field=filename               type=string;                   type=string;               mongo 127.0.0.1:27017;                                                                       type=string;                                                             , access the file through the file name filename, filename The type is stringCurrently only supports accessing files through id and filename. Start nginx: /usr/local/nginx/sbin/nginxUse MongoVUE to upload a picture 001.jpg to pics In the database. Open: http://localhost/pics/001.jpgIf successful, you can see the displayed picture. Notes1. GridFSdoes not automatically process md5identical files. For
md5identical files, if you want to have only one storage in GridFS, you need to user Handle it yourself. The calculation of the Md5 value is done by the client. 2. Because GridFS first saves the file data to fs.chunks during the file upload process, and finally saves the file information to fs.files, so if you are uploading If the file process fails, junk data may appear in fs.chunks. This junk data can be cleaned up regularly. The above introduces the detailed analysis of MongoDB's GridFS, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template