어떤 도구를 설치해보려고 했는데,
필요 조건이 MongoDB가 이미 설치되어 있어야 한단다.
그래서 부랴부랴 MongoDB 설치를 해보고자 한다.
# Environment
- 기본 환경은 아래와 같다.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
$ uname -a
Linux chani1804 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
# install
- 그냥 바로 apt-get으로 설치하면 된다.
$ sudo apt-get install mongodb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libgoogle-perftools4 libpcrecpp0v5 libsnappy1v5 libstemmer0d
libtcmalloc-minimal4 libyaml-cpp0.5v5 mongo-tools mongodb-clients mongodb-server mongodb-server-core
The following NEW packages will be installed:
libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-program-options1.65.1 libboost-system1.65.1 libgoogle-perftools4 libpcrecpp0v5 libsnappy1v5 libstemmer0d
libtcmalloc-minimal4 libyaml-cpp0.5v5 mongo-tools mongodb mongodb-clients mongodb-server mongodb-server-core
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 53.5 MB of archives.
After this operation, 217 MB of additional disk space will be used.
Do you want to continue? [Y/n]
# check status
- 설치를 완료하게 되면 바로 서비스로 실행이 된다.
- 서비스 상태를 확인해보자.
$ systemctl status mongodb.service
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-03-10 22:58:24 KST; 4min 31s ago
Docs: man:mongod(1)
Main PID: 3334 (mongod)
Tasks: 23 (limit: 2318)
CGroup: /system.slice/mongodb.service
└─3334 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf
3월 10 22:58:24 chani1804 systemd[1]: Started An object/document-oriented database.
- 버전과 접근 정보를 확인해보자.
$ mongo --eval 'db.runCommand({ connectionStatus: 1 })'
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
{
"authInfo" : {
"authenticatedUsers" : [ ],
"authenticatedUserRoles" : [ ]
},
"ok" : 1
}
# 자동 실행
- 재부팅할 때 자동으로 실행되도록 설정해보자.
$ sudo systemctl enable mongodb.service
Synchronizing state of mongodb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mongodb
# 간단한 사용
- 동작을 하는 것인지 확인만 해보자.
$ mongo
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2020-03-15T04:12:20.040+0900 I STORAGE [initandlisten]
2020-03-15T04:12:20.040+0900 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-03-15T04:12:20.040+0900 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-03-15T04:12:26.952+0900 I CONTROL [initandlisten]
2020-03-15T04:12:26.952+0900 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-03-15T04:12:26.952+0900 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-03-15T04:12:26.952+0900 I CONTROL [initandlisten]
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> use tutorial
switched to db tutorial
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> db.book.insert({"name": "Tutorial", "author": "whatwant"});
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
tutorial 0.000GB
> ^C
bye
'Dev Tools > Database' 카테고리의 다른 글
Redis 맛보기 (Docker로 Redis 설치해보기) (0) | 2022.07.10 |
---|---|
PostgreSQL 계정 및 권한 관리 (0) | 2022.03.23 |
pgAdmin4를 Docker로 설치하자 (PostgreSQL Tools) (0) | 2022.03.21 |
PostgreSQL을 Docker로 설치하자 (0) | 2022.03.21 |
MySQL 설치 (Ubuntu, SourceCode, v5.6.14) (0) | 2013.10.12 |