私はosxを使用してmongodbをいじろうとしています。そのためには、mongodb exeのディレクトリ内に次を使用してディレクトリを作成する必要があります
mkdir /data/db
ただし、そうしようとすると、コマンドプロンプトは次のように返します
$ mkdir /data/db
mkdir: /data: No such file or directory
現在、私のmongodb exeはコマンドラインが有効になっていません。つまり、bashのパスにありません。mongodbプログラムをグローバルにする方法を知っている人はいますか?
前もって感謝します
追加したので、bashファイルを追加してみました
$ sudo mkdir -p /data/db/
$ mkdir -p /data/db
単に入力する
$ mongod
まだ機能しません。次のように入力する必要があります
$ ./mongod
しかし、それは次のようになります
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 13:27:37.558 [initandlisten] MongoDB starting : pid=1042 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 13:27:37.559 [initandlisten]
Thu Jul 18 13:27:37.559 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 13:27:37.559 [initandlisten] db version v2.4.5
Thu Jul 18 13:27:37.559 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 13:27:37.559 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu- 1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 13:27:37.559 [initandlisten] allocator: system
Thu Jul 18 13:27:37.559 [initandlisten] options: {}
Thu Jul 18 13:27:37.559 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 13:27:37.559 dbexit:
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: final commit...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: closing all files...
Thu Jul 18 13:27:37.559 [initandlisten] closeAllFiles() finished
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 13:27:37.559 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 13:27:37.559 dbexit: really exiting now
編集2:
試した
sudo chown 'myusername' /data/db
sudo ./mongod も ./mongod もありません
働いた
編集3:
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:11:35.144 [initandlisten] MongoDB starting : pid=1550 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:11:35.145 [initandlisten]
Thu Jul 18 14:11:35.145 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:11:35.145 [initandlisten] db version v2.4.5
Thu Jul 18 14:11:35.145 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:11:35.145 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:11:35.145 [initandlisten] allocator: system
Thu Jul 18 14:11:35.145 [initandlisten] options: {}
Thu Jul 18 14:11:35.145 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 14:11:35.145 dbexit:
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: final commit...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:11:35.145 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:11:35.145 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 14:11:35.145 dbexit: really exiting now
$ sudo ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:11:43.450 [initandlisten] MongoDB starting : pid=1552 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:11:43.451 [initandlisten]
Thu Jul 18 14:11:43.451 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:11:43.451 [initandlisten] db version v2.4.5
Thu Jul 18 14:11:43.451 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:11:43.451 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:11:43.451 [initandlisten] allocator: system
Thu Jul 18 14:11:43.451 [initandlisten] options: {}
Thu Jul 18 14:11:43.451 [initandlisten] journal dir=/data/db/journal
Thu Jul 18 14:11:43.451 [initandlisten] recover : no journal files present, no recovery needed
Thu Jul 18 14:11:43.489 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
Thu Jul 18 14:11:43.489 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:28017
Thu Jul 18 14:11:43.489 [initandlisten] ERROR: addr already in use
Thu Jul 18 14:11:43.489 [websvr] ERROR: addr already in use
Thu Jul 18 14:11:43.489 [initandlisten] now exiting
Thu Jul 18 14:11:43.489 dbexit:
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: final commit...
Thu Jul 18 14:11:43.500 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:11:43.505 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:11:43.505 [initandlisten] journalCleanup...
Thu Jul 18 14:11:43.505 [initandlisten] removeJournalFiles
Thu Jul 18 14:11:43.506 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:11:43.506 dbexit: really exiting now
編集4:
$ sudo killall mongod
Password:
$ sudo rm -rf /data/db
$ sudo mkdir -p /data/db
$ sudo chown xxxxx/data/db
usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...
chown [-fhv] [-R [-H | -L | -P]] :group file ...
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:27:04.047 [initandlisten] MongoDB starting : pid=417 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:27:04.047 [initandlisten]
Thu Jul 18 14:27:04.047 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:27:04.047 [initandlisten] db version v2.4.5
Thu Jul 18 14:27:04.047 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:27:04.047 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:27:04.047 [initandlisten] allocator: system
Thu Jul 18 14:27:04.047 [initandlisten] options: {}
Thu Jul 18 14:27:04.110 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 14:27:04.110 dbexit:
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: final commit...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:27:04.119 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:27:04.119 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:27:04.119 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 14:27:04.119 dbexit: really exiting now