practice makes perfect

MongoDB 설치 및 계정 생성 본문

Linux

MongoDB 설치 및 계정 생성

후니옹 2020. 10. 4. 20:08

MongoDB 설치 및 계정 생성

 

  • CentOS 7 기준으로 설치 진행

  • 계정생성 및 모니터링 용 계정 권한 설정

 

[설치]

- Repository 등록

# /etc/yum.repos.d/mongodb-org.repo

[mongodb-org-3.4]

name=MongoDB Repository

baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/

gpgcheck=1

enabled=1

gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

 

- Repo 확인

# yum repolist

 

- Mongo 설치

# yum install mongodb-org

 

- Mongo 서비스 시작

# systemctl start mongod (시작)

 

※ [참고]

# systemctl stop mongod (중지)

# systemctl reload mongod (설정파일 다시 읽기 및 반영)

# tail /var/log/mongodb/mongod.log (로그확인)

 

- 설치 후 접속

# mongo localhost:27017

MongoDB shell version v3.4.24

connecting to: mongodb://localhost:27017/test

MongoDB server version: 3.4.24

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-02-18T00:34:40.300+0000 I CONTROL  [initandlisten]

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten]

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten]

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten]

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2020-02-18T00:34:40.300+0000 I CONTROL  [initandlisten]

> db

test

> show dbs

admin  0.000GB

local  0.000GB

>

 

 

- 계정만들기 (admin)

> use admin

switched to db admin

> db.createUser(

...   {

...     user: "mhadmin",

...     pwd: "abc123",

...     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]

...   }

... )

Successfully added user: {

"user" : "mhadmin",

"roles" : [

{

"role" : "userAdminAnyDatabase",

"db" : "admin"

}

]

}

 

- 새로만든계정으로 접속

# mongo --port 27017 -u "mhadmin" -p "abc123" --authenticationDatabase "admin"

 

 

- 모니터링 용 계정 생성 및 Role 추가

use admin

db.createUser(

   {

     user: "monitoruser",

     pwd: "monitoruser",

     roles: [ { role: "clusterMonitor", db: "admin" } ]

   }

)

'Linux' 카테고리의 다른 글

Oracle Linux 호스트 네임  (0) 2024.05.06
ELK Configure (with Docker)  (0) 2020.12.13
Apache Method 예외처리  (0) 2020.01.01
Centos Repository 변경  (0) 2019.03.01
Linux cmdlet 정리  (0) 2017.11.30
Comments