Instalei o mongo no meu Linux Mint e em /etc/mongod.conf vejo que a pasta padrão para armazernar os bancos de dados é /var/lib/mongodb:
$ cat /etc/mongod.conf
# 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: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Quero alterar a pasta onde o Mongo armazena os dados para /data/db. Descobri que o comando pra fazer isso é setar a variavel dbPath por linha de comando. Mas quando executo dá erro:
$ mongod --dbpath "/data/db"
2019-02-21T06:31:58.855-0300 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] MongoDB starting : pid=10703 port=27017 dbpath=/data/db 64-bit host=rafael-Inspiron-5566
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] db version v4.0.4
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] git version: f288a3bdf201007f3693c58e140056adf8b04839
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] allocator: tcmalloc
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] modules: none
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] build environment:
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] distmod: ubuntu1604
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] distarch: x86_64
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] target_arch: x86_64
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2019-02-21T06:31:58.859-0300 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] now exiting
2019-02-21T06:31:58.859-0300 I CONTROL [initandlisten] shutting down with code:48
Que erro é esse e como altero diretório onde o Mongo armazena os dados??