码迷,mamicode.com
首页 > 数据库 > 详细

安装nginx和nginx-gridfs和mongodb

时间:2018-07-11 14:57:43      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:checkout   接收   system   tool   roo   tps   database   ever   define   

1.安装依赖包:

[root@mongo_rs1 ~]# yum -y install pcre-devel openssl-devel zlib-devel git gcc gcc-c++
[root@mongo_rs1 zhuyr]# git clone https://github.com/mdirolf/nginx-gridfs.git
[root@mongo_rs1 zhuyr]# cd nginx-gridfs/
[root@mongo_rs1 nginx-gridfs]# git checkout v0.8
[root@mongo_rs1 nginx-gridfs]# git branch
[root@mongo_rs1 nginx-gridfs]# git submodule init
#子模组 ‘mongo-c-driver‘ (git://github.com/mongodb/mongo-c-driver.git) 已为路径 ‘mongo-c-driver‘ 注册
[root@mongo_rs1 nginx-gridfs]# git submodule update
正克隆到 ‘mongo-c-driver‘...
remote: Counting objects: 101193, done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 101193 (delta 159), reused 195 (delta 127), pack-reused 100938
接收对象中: 100% (101193/101193), 49.45 MiB | 4.55 MiB/s, done.
处理 delta 中: 100% (88309/88309), done.
子模组路径 ‘mongo-c-driver‘:检出 ‘74cc0b8005fbbc84ec4a0003ff80c68f9e9cc7de‘

 

2.安装nginx

[root@mongo_rs1 zhuyr]#  wget http://nginx.org/download/nginx-1.7.9.tar.gz
[root@mongo_rs1 zhuyr]# tar -zxvf nginx-1.7.9.tar.gz
[root@mongo_rs1 zhuyr]# cd nginx-1.7.9/
[root@mongo_rs1 nginx-1.7.9]# ./configure --prefix=/usr/local/nginx   --with-openssl=/usr/include/openssl --add-module=/zhuyr/nginx-gridfs
[root@mongo_rs1 nginx-1.7.9]# make -j8 && make install -j8

  

#如果报错
[root@mongo_rs1 nginx-1.7.9]# ./configure --prefix=/usr/local/nginx   --with-openssl=/usr/include/openssl --add-module=/zhuyr/nginx-gridfs
#把第3行的-Werror错误去掉
[root@mongo_rs1 nginx-1.7.9]# vi objs/Makefile 
[root@mongo_rs1 nginx-1.7.9]# make && make install

3.修改配置文件

[root@mongo_rs1 nginx-1.7.9]# vi /usr/local/nginx/conf/nginx.conf
#添加以下内容

        location /girdfstest/ {
            gridfs pics
            field=_id
            type=objectid;
            mongo 127.0.0.1:27017;
        }
#gridfstest:访问地址

#pics:数据库

#mongo 127.0.0.1:10001 #mongo的服务器地址及端口
#启动nginx
[root@mongo_rs1 nginx-1.7.9]# /usr/local/nginx/sbin/nginx
#配置修改后重新加载
[root@mongo_rs1 nginx-1.7.9]# /usr/local/nginx/sbin/nginx -s reload

4.安装mongodb

vi /etc/yum.repos.d/mongodb-org-3.4.repo  
[mongodb-org-3.4]  
name=MongoDB Repository  
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/  
gpgcheck=0  
enabled=1  
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc  
$ yum -y install mongodb-org 
查看修改配置文件 : vim /etc/mongod.conf
启动mongodb :systemctl start mongod.service
停止mongodb :systemctl stop mongod.service

如果报错:

[root@ansible nginx-1.7.9]# journalctl -xe
7月 11 10:54:03 ansible.test yum[797]: Erased: mongodb-org-3.2.20-1.el7.x86_64
7月 11 10:54:04 ansible.test systemd[1]: Reloading.
7月 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple
7月 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl
7月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-server-3.2.20-1.el7.x86_64
7月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-shell-3.2.20-1.el7.x86_64
7月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-mongos-3.2.20-1.el7.x86_64
7月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-tools-3.2.20-1.el7.x86_64
7月 11 10:59:08 ansible.test systemd[1]: Reloading.
7月 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple
7月 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl
7月 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-server-3.2.20-1.el7.x86_64
7月 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-mongos-3.2.20-1.el7.x86_64
7月 11 10:59:12 ansible.test yum[928]: Installed: mongodb-org-tools-3.2.20-1.el7.x86_64
7月 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-shell-3.2.20-1.el7.x86_64
7月 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-3.2.20-1.el7.x86_64
7月 11 10:59:21 ansible.test polkitd[747]: Registered Authentication Agent for unix-process:961:41855579 (system bus name :1.1
7月 11 10:59:21 ansible.test systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
-- Subject: Unit mongod.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mongod.service has begun starting up.
7月 11 10:59:21 ansible.test mongod[966]: Error starting mongod. /var/run/mongodb/mongod.pid exists.
7月 11 10:59:21 ansible.test systemd[1]: mongod.service: control process exited, code=exited status=1
7月 11 10:59:21 ansible.test systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..

#解决方法: [root@ansible mongodb]# rm /var/run/mongodb/mongod.pid -f [root@ansible mongodb]# systemctl start mongod.service

5.使用mongofiles工具

[root@mongo_rs1 tmp]# mongofiles  put 1.JPG -d pics -t jpg 
2018-07-11T11:34:16.002+0800    connected to: localhost
added file: 1.JPG
[root@mongo_rs1 tmp]# mongofiles list -d pics
2018-07-11T11:34:33.037+0800    connected to: localhost
1.JPG   138424
[root@mongo_rs1 tmp]# 

6.http访问:

http://172.16.160.91/girdfstest/1.jpg

 

安装nginx和nginx-gridfs和mongodb

标签:checkout   接收   system   tool   roo   tps   database   ever   define   

原文地址:https://www.cnblogs.com/amoyzhu/p/9293609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!