zoukankan      html  css  js  c++  java
  • 远程连接ubuntu的MongoDB遇到的坑

    • 首先连接不上,先查看云服务器上的安全组是否添加了对应的端口
    • 如果打开了,那么久查看MongoDB是否允许远程连接
    # mongod.conf
    
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    
    # Where and how to store data.
    storage:
      dbPath: /var/lib/mongodb
      journal:
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:
    
    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path: /var/log/mongodb/mongod.log
    
    # network interfaces
    net:
      port: 27017
      bindIp: 0.0.0.0
    
    
    #processManagement:
    
    #security:
    
    #operationProfiling:
    
    #replication:
    
    #sharding:
    
    ## Enterprise-Only Options:
    
    #auditLog:
    
    #snmp:

    重点查看net下的bindIp,如果是127.0.0.1的话就改成0.0.0.0

    使用启动命令:
    sudo systemctl start mongod

    因为使用

    sudo service mongodb start

    会报错

    查看MongoDB的日志:
    cat /var/log/mongodb/mongod.log

    如果报错是:

    Detected unclean shutdown - /var/lib/mongodb/mongod.lock is not empty.

    那就直接删除掉那个文件

    rm -rf /var/lib/mongodb/mongod.lock

    如果报错为:

    Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted

    那就直接删除掉那个文件:

    rm -rf /tmp/mongodb-27017.sock

    如果报错为:

    WiredTiger error (13) [1543829280:361502][14474:0x7f42abbdad00], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied

    那就提升权限:

    sudo chown -R mongodb:mongodb /var/lib/mongodb

    然后使用

    sudo systemctl start mongod

    启动即可

  • 相关阅读:
    0918作业-----所有数值未做合法性检测
    尝试安装和配置JDK,并给出安装、配置JDK的步骤
    java为什么可以跨平台执行
    字符集
    java 入门及简介
    时间轴特效
    javascript简介
    javascript while循环
    Javascript for循环
    函数豹子问题
  • 原文地址:https://www.cnblogs.com/TimLiuDream/p/10067350.html
Copyright © 2011-2022 走看看