Print
카테고리: [ NoSQL ]
조회수: 112

1. 개요

커맨드 상에서 MongoDB 접속을 위해 mongodb-org-shell 패키지를 설치한다.

환경은 Amazon Linux (Redhat 계열) 기준임.

2. Repo 확인

만약 아래와 같이 패키지를 찾을 수 없다면 Repo 등록부터 해야 한다.

# yum install mongodb-org-shell
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                           | 3.7 kB  00:00:00
No package mongodb-org-shell available.
Error: Nothing to do

Repo는 /etc/yum.repos.d/mongodb-org-5.0.repo파일을 생성한다.

[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

3. yum 설치

# yum install mongodb-org-shell
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                           | 3.7 kB  00:00:00
mongodb-org-5.0                                                                                                                                                                      | 2.5 kB  00:00:00
mongodb-org-5.0/primary_db                                                                                                                                                           |  53 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org-shell.x86_64 0:5.0.5-1.amzn2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================
 Package                                              Arch                                      Version                                            Repository                                          Size
============================================================================================================================================================================================================
Installing:
 mongodb-org-shell                                    x86_64                                    5.0.5-1.amzn2                                      mongodb-org-5.0                                     15 M

Transaction Summary
============================================================================================================================================================================================================
Install  1 Package

Total download size: 15 M
Installed size: 56 M
Is this ok [y/d/N]:

4. mongo 실행

# mongo
MongoDB shell version v5.0.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1