mongoDB ReplicaSet 설정시 couldn’t initiate : can’t find self in the replset config my port 오류

 

mongoDB ReplicaSet 설정시 rs.initiate() 실행시 오류가 발생하며 정상적으로 설정이 진행이 안되는 문제가 있었습니다.

[root@mongo03 cfg]# mongo localhost:31000
MongoDB shell version: 2.4.4-pre-
connecting to: localhost:31000/test
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
> use admin
ㅁswitched to db admin
> rs.initiate()
{
“info2” : “no configuration explicitly specified — making one”,
“me” : “mongo03:31000”,
“ok” : 0,
“errmsg” : “couldn’t initiate : can’t find self in the replset config my port: 31000
}

문제 해결 : 해당 에러가 발생하는 건 mongoDB에서 IP로 해당 서버 DB에 접근하는 것이 아닌 HOSTNAME으로 접근하기때문에 발생한 문제입니다. 에러메세지를 보면 “me”라고 된 부분에 hostname이 표시되어있습니다. 해당 hostname으로 mongoDB에 잘 찾아갈 수 있게 /etc/hosts파일에 해당 hostname을 추가해주면 해결이 가능합니다.