일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- CrossAxisAlignment
- 반석천
- Row Widget
- Flutter 앱 배포
- Flutter 강좌
- Image.network
- Scaffold
- Load Image
- Networking
- ListView.builder
- listview
- Row
- Hello World
- ListTile
- FutureBuilder
- sqlite
- Column Widget
- Flutter Example
- InkWell
- node.js
- Snackbar
- HTTP
- WillPopScope
- navigator
- AppBar
- Cached Image
- Flutter Tutorial
- MainAxisAlignment
- Flutter 예제
- flutter
- Today
- Total
꿈꾸는 시스템 디자이너
[MongoDB] Ubuntu 18.04에 MongoDB 설치 방법 본문
다음의 mongoDB 사이트 문서를 참고한다.
docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
1. MongoDB의 public GPG key를 주입한다.
ubuntu@dev:~$ wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
OK
2. MongoDB를 위한 리스트파일을 생성한다.
ubuntu@dev:~$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse"
| sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse
3. 로컬 패키지 데이터베이스를 갱신한다.
ubuntu@dev:~$ sudo apt-get update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Ign:5 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 InRelease
Get:6 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 Release [5391 B]
Get:7 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 Release.gpg [801 B]
Get:8 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4/multiverse arm64 Packages [5112 B]
Get:9 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4/multiverse amd64 Packages [6838 B]
Fetched 107 kB in 2s (60.5 kB/s)
Reading package lists... Done
ubuntu@dev:~$
4. MongoDB를 설치한다.
ubuntu@dev:~$ sudo apt-get install -y mongodb-org
5. MoongoDB 서비스를 실행한다.
ubuntu@dev:~$ sudo service mongod start
6. MongoDB에 접속한다.
ubuntu@dev:~$ mongo
MongoDB shell version v4.4.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("98b58ce7-e220-46e1-9d66-c32ebbd7c30c") }
MongoDB server version: 4.4.2
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
---
The server generated these startup warnings when booting:
2020-11-25T07:27:46.807+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-11-25T07:27:47.571+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> exit
bye
ubuntu@dev:~$
exit 명령어로 빠져나올 수 있다.
7. 관리자 계정 추가
MongoDB에 다시 접속하여 관리자 계정을 추가한다.
ubuntu@dev:~$ mongo
MongoDB shell version v4.4.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("d8bf7079-140f-4e9a-a774-cb5926cc08a5") }
MongoDB server version: 4.4.2
---
The server generated these startup warnings when booting:
2020-11-25T07:27:46.807+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-11-25T07:27:47.571+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> use admin
switched to db admin
> db.createUser({user: 'test', pwd: 'test1234', roles: ['root']})
Successfully added user: { "user" : "test", "roles" : [ "root" ] }
> exit
bye
ubuntu@dev:~$
8. 인증 설정
MongoDB에 접속할 때 인증과정이 이루어지도록 설정파일을 수정한다.
우선 MongoDB를 종료한 후 수정을 한다.
ubuntu@dev:~$ sudo service mongod stop
ubuntu@dev:~$ sudo vim /etc/mongod.conf
mongod.conf 설정파일의 security 항목의 주석을 해제한 후 그 하단에 authorization: enabled 를 추가한다.
# 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:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
~
9. 인증 접속
MongoDB를 다시 실행한 후 등록한 계정 정보로 접속을 시도해 보자.
ubuntu@dev:~$ sudo service mongod start
ubuntu@dev:~$ mongo admin -u test -p test1234
MongoDB shell version v4.4.2
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("5e6ae32d-901a-42b6-b1c6-2391482b2cec") }
MongoDB server version: 4.4.2
---
The server generated these startup warnings when booting:
2020-11-25T07:38:12.870+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
---
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> exit
bye
ubuntu@dev:~$
10. 외부 접속 설정
MongoDB는 기본적으로 로컬호스트에서만 접속이 가능하도록 설정되어 있다. 외부 접속을 위해서는 net 항목의 bindIp 항목을 0.0.0.0으로 변경한다.
# 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
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
~
~
추가로 사용할 Port를 변경하려면 port 항목도 변경한다.
11. 외부 접속 시도
외부에서 서버에 설치된 MongoDB로 접속하기 위해 GUI 툴을 이용해보자.
다음 링크에서 Robo3T를 다운로드 한다.
Robo3T를 설치한 후 실행한다.
연결 설정에서 서버의 주소와 포트번호를 입력한다.
인증 설정에서 생성했던 계정 정보를 입력한다.
설정을 저장하고 연결을 시도한다.
연결에 성공하면 다음과 같이 MongoDB의 내용을 확인할 수 있다.
'Development > Cloud computing' 카테고리의 다른 글
Docker란? | Docker를 사용하는 이유 | Docker 장점 (0) | 2020.07.09 |
---|---|
Docker 사용법 | 컨테이너와 이미지 상태 확인 및 삭제 방법 (1) | 2020.07.02 |
Docker 사용법 | 컨테이너에 포트 부여 방법 | 이미지 생성 방법 (0) | 2020.07.01 |
Docker 사용법 | 컨테이너 생성/종료/실행/진입 (1) | 2020.07.01 |
Ubuntu에 Docker 설치 방법 | How to install Docker on Ubuntu (0) | 2020.05.26 |