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

    启动即可

  • 相关阅读:
    c++ 队列
    17:特殊类成员:函数指针5
    c++ deque 双端队列
    18:字符串-char型字符串
    c++ 16 this 和 继承 及继承机制中的构造函数 与 析构函数
    c++ string char* const char*
    c++ 小片段
    google protobuf 使用示例
    hibernate-cache
    hibernate-criteria查询(二)
  • 原文地址:https://www.cnblogs.com/TimLiuDream/p/10067350.html
Copyright © 2011-2022 走看看