'DBMS, noSQL/mongoDB'에 해당되는 글 4건

노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Java Code for mongoDB Query


1. MongoCursor 생성

Document docQuery = new Document();

docQuery.put("key1","value1");


MongoCursor<Document> mc = collection.find(docQuery).iterator();

Document curDoc = mc.next;

...

mc.close(); // cursor close


2. MongoClient 생성

List<MongoCredential> credentialList = new ArrayList<>();

MongoCredential credential = MongoCredential.createCredential(_USER, "admin",_PWD.toCharArray() );

credentialList.add(credential);


ServerAddress svr = new ServerAddress(_SVR, _PORT);

mongoClient = new MongoClient(svr, credentialList);

...

mongoClient.close(); // 연결 닫기


3. MongoCollection 생성

MongoDatabase db = mongoClient.getDatabase(dbName);

MongoCollection<Document> collection = db.getColleciton(collectionName); 


* ISODate, docQuery, 자료 목록 가져오기

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

Date gtDate = sdf.parse("2018-06-04T00:00:00.000Z");


Document docQuery = new Document();

docQuery.put("reg_dt", new Document("$gt", gtDate) );


* ISODate, JSON -> Document, 자료 추가 하기

String jsonData = "{" 

        + " 'key1' : '"+ curDoc.get("key1")+"',"+

        + " 'key2' : '"+ curDoc.get("key2")+"'"+ "}";

Document docInsert = Document.parse(jsonData);

docInsert("reg_dt", regDate);


collection.insertOne(docInsert);


* Error 1,  메시지 & 해결 시도 방법

A pipeline stage specification object must contain exactly one field.

A

You should make a pair every pipeline in {}.

db.collection.aggregation(

  { $group: ... },

  { $match: ...}

)




'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Robo 3T(Robomongo) 폰트 변경  (0) 2018.10.24
CentOS에 MongoDB 64bit 설치하기  (0) 2017.02.07
사용자 계정 관리  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

Robo 3T(Robomongo)  폰트 변경



-- 부제:  몽고 DB 클라이언트, 폰트 사이즈 변경하기



방법1. Config수정 하기



1) Config 위치 (윈도우 기준)



C:/.3T/robo-3T/1.2.1/robo3t.json


** 기존 버젼 : robomongo.json




2) 폰트 정보 변경



변경 전

  "textFontFamily" : "",

 "textFontPointSize" : -1,

 변경 후

  "textFontFamily" : "Lucida Console",

 "textFontPointSize" : 12,




* 변경 후 (스크린 샷)




*** 클라이언트를 종료후에 robo3t.json을 수정하고, 다시 실행




참조1 : https://github.com/Studio3T/robomongo/issues/1250

참조2: https://github.com/Studio3T/robomongo/issues/645

'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Java Code for mongoDB Query  (0) 2018.10.30
CentOS에 MongoDB 64bit 설치하기  (0) 2017.02.07
사용자 계정 관리  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

CentOS에 MongoDB 64bit 설치하기


1.CentOS에 MongoDB 64bit 설치하기 



1) 저장소 추가
	$ vi /etc/yum.repos.d/mongodb.repo
	[mongodb]
	name=MongoDB Repository
	baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
	gpgcheck=0
	enabled=1
2) yum으로 설치
	$ yum -y install mongodb-org

3) yum -update로 몽고디비가 업데이트되는 것을 방지
	$ vi /etc/yum.conf
	exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

4) 실행시키기
	$ service mongod start
	$ service mongod restart
	$ service mongod stop
 
	# 부팅시 자동으로 실행하려면
	$ chkconfig mongod on
5) 방화벽 오픈
	$ iptables -I INPUT 1 -p tcp --dport 27017 -j ACCEPT
	$ service iptables save
	$ service iptables restart

2.Install MongoDB on Red Hat Enterprise or CentOS Linux


'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Java Code for mongoDB Query  (0) 2018.10.30
Robo 3T(Robomongo) 폰트 변경  (0) 2018.10.24
사용자 계정 관리  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.
사용자 계정 관리

몽고DB를 시동하고 나서 가장 먼저 해야 할 일은 데이터베이스에 접근할 수 있도록 사용자를 추가하는 것이다.


1) 계정 생성
	use test
	db.createUser( {use: "testUser", pwd: "test", 
	roles: ["readWrite", "dbAdmin"] } )
2) 계정 삭제
	use test
	db.dropUser("testUser")
3) 계정 목록
	use admin
	show users

* 사용자 계정은 각 데이터베이스의 db.system.users 컬렉션에 저장된다.
* User 객체는 id, user, pwd, roles등을 갖는다.



'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Java Code for mongoDB Query  (0) 2018.10.30
Robo 3T(Robomongo) 폰트 변경  (0) 2018.10.24
CentOS에 MongoDB 64bit 설치하기  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,