k8s에서 gpu을 사용하는 pod을 만들일이 있어 관련 내용을 정리하였다. 


gpu을 사용하기 위해서는 nvidia driver가 있어야한다.

  

이번 포스팅엔 먼저 nvidia 드라이버 설치 관련 내용을 정리하였다.


nvdia driver설치하기 

$ yum update
$ yum install kernel-devel kernel-headers gcc make
 

nouveau 을 활성화시키면 충돌가능성이 있기에 blacklist해준다. 
$ echo 'blacklist nouveau' >> /etc/modprobe.d/blacklist.conf
$ dracut /boot/initramfs-$(uname -r).img $(uname -r) --force
$ reboot

파일다운

이것저것 뜨는데 다 ok, yes해줌 된다.
$ bash NVIDIA-Linux-x86_64-390.59.run

1. WARNING: nvidia-installer was forced to guess the X library path '/usr/lib64' and X
           module path '/usr/lib64/xorg/modules'; these paths were not queryable from the
           system.  If X fails to find the NVIDIA X driver module, please install the
           `pkg-config` utility and the X.Org SDK/development package for your distribution
           and reinstall the driver
OK
2. Install NVIDIA's 32-bit compatibility libraries?
YES

3. Would you like to run the nvidia-xconfig utility to automatically update your X
  configuration file so that the NVIDIA X driver will be used when you restart X?  Any
  pre-existing X configuration file will be backed up.
YES

4.  Your X configuration file has been successfully updated.  Installation of the NVIDIA
  Accelerated Graphics Driver for Linux-x86_64 (version: 390.59) is now complete.
OK



$ nvidia-smi


Thu May 24 21:39:10 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.59                 Driver Version: 390.59                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 108...  Off  | 00000000:01:00.0 Off |                  N/A |
|  0%   34C    P5    15W / 250W |      0MiB / 11178MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 108...  Off  | 00000000:04:00.0 Off |                  N/A |
|  0%   33C    P5    13W / 250W |      0MiB / 11178MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 | 


위 화면이 뜬다면 완료 

k8s을 설치하고 재 설치 시 전에 있던 데이터가 남아 있어서 문제가 생긴다.


$ kubeadm init 


필자의 경우 위 명령어가 time out으로 계속 실패하여 원인을 찾는데 많은 시간을 소비했다. 

아래 명령어를 통해 docker, k8s을 초기화하고 다시 설치하자 문제 없이 설치가 되었다. 


# docker 초기화

$ docker rm -f `docker ps -aq`

$ docker volume rm `docker volume ls -q`
$ umount /var/lib/docker/volumes
$ rm -rf /var/lib/docker/

$ systemctl restart docker 


# k8s 초기화

$ kubeadm reset

$ systemctl restart kublet


# iptables에 있는 데이터를 청소하기 위해

$ reboot 


 







참고사이트 : 

https://www.howtoforge.com/tutorial/centos-kubernetes-docker-cluster/



설치버전 :

CentOS버전 :
$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

리눅스 커널버전 : 

$ uname -sr
Linux 3.10.0-693.el7.x86_64 


호스트 : 
# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.0.2 master
192.168.0.3 slave01



모든 노드에서 진행해준다.

Disable selinux 
$ setenforce 0
$ sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux



Enable br_netfilter Kernel Module
$ modprobe br_netfilter
$ echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
$ modprobe br_netfilter


위에 modprobe을 하면 bridge관련 모듈이 추가된다.

  
$ ll /proc/sys/net/
total 0
dr-xr-xr-x. 1 root root 0 May 24 22:23 core
dr-xr-xr-x. 1 root root 0 May 24 02:30 ipv4
dr-xr-xr-x. 1 root root 0 May 24 02:30 ipv6
dr-xr-xr-x. 1 root root 0 May 24 02:30 netfilter
-rw-r--r--. 1 root root 0 May 24 22:23 nf_conntrack_max
dr-xr-xr-x. 1 root root 0 May 24 02:30 unix

$ ll /proc/sys/net/
total 0
dr-xr-xr-x. 1 root root 0 May 24 01:19 bridge
dr-xr-xr-x. 1 root root 0 May 24 01:06 core
dr-xr-xr-x. 1 root root 0 May 23 21:09 ipv4
dr-xr-xr-x. 1 root root 0 May 23 21:09 ipv6
dr-xr-xr-x. 1 root root 0 May 23 21:09 netfilter
-rw-r--r--. 1 root root 0 May 24 01:06 nf_conntrack_max
dr-xr-xr-x. 1 root root 0 May 23 21:09 unix 


Disable SWAP

$ swapoff -a
# swap 파티션이나 swap 파일의 구동을 중단시키는 명령어

swap이란 하드디스크를 메모리처럼 사용하는 기법
-> 물리적인 메모리가 모자라면 하드디스크를 메모리처럼 데이터를 기록하여 메모리를 확보
프로그램들을 많이 실행해서 메모리가 부족해지면, 메모리 상에 적재된 프로그램 중 당장 필요하지 않은 프로그램 데이터를 하드디스크에 옮겨서 메모리 공간을 확보

출처: http://nextcube.tistory.com/137 [중성자 별의 충돌 에너지]



$ vi /etc/fstab

/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=e68efdc4-b1c1-4f94-ab67-72d611499e13 /boot                   xfs     defaults        0 0
UUID=E849-B774          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
#/dev/mapper/centos-swap swap                    swap    defaults        0 0



Install Docker 

$ yum install -y yum-utils device-mapper-persistent-data lvm2
$ yum install -y docker-ce




Install Kubernetes

$ cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

# /etc/yum.repos.d/kubernetes.repo


$ yum install -y kubeadm


$ systemctl start docker && systemctl enable docker
$ systemctl start kubelet && systemctl enable kubelet 



Change the cgroup-driver

$ docker info | grep -i cgroup
Cgroup Driver: cgroupfs

$ sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

$ systemctl daemon-reload
$ systemctl restart kubelet 



k8S Cluster Initialization


Master서버에서 ( apiserver-advertise-address 에 master서버 아이피 입력 ) 
$  kubeadm init --apiserver-advertise-address=192.168.0.2 --pod-network-cidr=10.244.0.0/16


Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

 kubeadm join 192.168.0.2:6443 --token bi09ej.5z5q8osipp4r9w5u --discovery-token-ca-cert-hash sha256:0aa7b7489d097ae88ad17c7dad7a591d2da711fca6ed533b4063979c917747a5

# 따로 메모 해둔다. 슬레이브서버에서 조인할때 필요



$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config 



# 여기선 flannel네트웍으로 사용



$ kubectl get nodes
$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY     STATUS    RESTARTS   AGE
kube-system   etcd-jframe-master                      1/1       Running   0          22s
kube-system   kube-apiserver-jframe-master            1/1       Running   0          28s
kube-system   kube-controller-manager-jframe-master   1/1       Running   0          42s
kube-system   kube-dns-86f4d74b45-nxqfr               3/3       Running   0          1m
kube-system   kube-flannel-ds-7dmtt                   1/1       Running   0          1m
kube-system   kube-proxy-w6hm8                        1/1       Running   0          1m
kube-system   kube-scheduler-jframe-master            1/1       Running   0          19s



슬레이브노드에서 진행 : 

$ kubeadm join 192.168.0.2:6443 --token bi09ej.5z5q8osipp4r9w5u --discovery-token-ca-cert-hash sha256:0aa7b7489d097ae88ad17c7dad7a591d2da711fca6ed533b4063979c917747a5


This node has joined the cluster:
* Certificate signing request was sent to master and a response
  was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the master to see this node join the cluster.


마스터노드에서 확인 : ( slave01이 제대로 안 올라오면 위에 과정을 제대로 입력했는지 확인해본다 ) 
$ kubectl get nodes
NAME             STATUS    ROLES     AGE       VERSION
master    Ready     master    21m       v1.10.3
slave01   Ready     <none>    57s       v1.10.3

$  kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY     STATUS    RESTARTS   AGE
kube-system   etcd-jframe-master                      1/1       Running   0          46m
kube-system   kube-apiserver-jframe-master            1/1       Running   0          46m
kube-system   kube-controller-manager-jframe-master   1/1       Running   0          46m
kube-system   kube-dns-86f4d74b45-nxqfr               3/3       Running   0          47m
kube-system   kube-flannel-ds-7dmtt                   1/1       Running   0          47m
kube-system   kube-flannel-ds-f9vbs                   1/1       Running   0          56s
kube-system   kube-proxy-9xgll                        1/1       Running   0          56s
kube-system   kube-proxy-w6hm8                        1/1       Running   0          47m
kube-system   kube-scheduler-jframe-master            1/1       Running   0          46m



마지막으로 팟을 만들어서 확인해본다.
Testing Create First Pod

$ kubectl create deployment nginx --image=nginx
$ kubectl describe deployment nginx
$ kubectl create service nodeport nginx --tcp=80:80
$ kubectl get svc
( 이 명령어를 통해 PORT에 포워딩한 포트를 기억한다 ) 

$  curl master:31280
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>


$ curl slave01:31280
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>





MongoDB란?


 MongoDB는 C++작성된 오픈소스 문서지향(Document-Oriented) 적 Cross-platform데이터베이스이며,

뛰어난 확장성과 성능을 자랑합니다. 또한, 현존하는 NOSQL 데이터베이스 중 인지도 1위를 유지하고 있습니다.


위에 나온 설명은 흔히 mongodb에 관해 설명을 할 때 많이 나오는 내용이다.

MongoDB를 제대로 이해하기 위해서는 NOSQL, 문서지향, Cross-platform이라는 용어에 집중할 필요가있다. 

NOSQL이란 ? 

  Not Only Sql로 RDBMS의 한계를 극복하기 위해 만들어진 새로운 형태의 저장소이다. 관계형 DB가 아니기에, RDBMS처럼 고정된 스키마 및 JOIN이 존재하지않는다.

문서지향이란 ?

MongoDB는 다른 데이터베이스와 다르게 조금 다른 형태의 데이터형식을 지원한다.

key-value pair형태의 Document을 제공하는데 아래 예를 보면 조금 더 이해가 쉬울거다.

 { "_id": ObjectId("5099804saf3f4948bd2f98231"), "username": "yjh", "name": { first: "jh", last: "y" } }


MongoDB에선 위의 json형태의 데이터가 Bson형식의 데이터로 저장된다. 


Cross-platform이란 ? 

간단히 설명하면 여러 종류의 컴퓨터플랫폼에서 동작할 수 있다는 것을 뜻한다.  둘이상의 플랫폼위에서 동작할 시 클로스 플랫폼이라한다. 

 

이제 MongoDB에 대해 간략히 알았다면 다른 SQL랑 용어를 비교해보자 

SQL 사용용어  

 MongoDB 사용용어

 데이터베이스 

 데이터베이스

 테이블 

 컬렉션

 행

문서 또는 BSON문서 

 열 

 필드

 색인

 색인

 테이블 조인

 내장문서 & 링킹

 기본키

기본키 

집합 

집합 프레임워크 







'apps > mongodb' 카테고리의 다른 글

mongodb sharing  (0) 2018.01.28

Mongodb sharding


구성정보 : 


mongo01 : 192.168.0.2

 mongo02 : 192.168.0.3 



mongodb version : 3.6.2


그림 : https://docs.mongodb.com/manual/sharding/




위와같이 구성할꺼다.


 A MongoDB sharded cluster consists of the following components:

  • shard: Each shard contains a subset of the sharded data. Each shard can be deployed as a replica set.
  • mongos: The mongos acts as a query router, providing an interface between client applications and the sharded cluster.
  • config servers: Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must be deployed as a replica set (CSRS).



설치법 : 

별도의 설명이 없다면 양쪽서버에서 진행하시면 됩니다. ^^


먼저 다운받는다.

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.2.tgz 


압출을 풀어준다.

$ tar -zxvf mongodb-linux-x86_64-rhel70-3.6.2.tgz 


링크걸어준다. ( 편리하게 접근하기 위함 ) 

$ ln -s mongodb-linux-x86_64-rhel70-3.6.2 mongodb


mongodb폴더에서 각각의 dir을 만들어준다. 

$ mkdir pid
$ mkdir shardsvr
$ mkdir configsvr # 이 부분은 mongo01 에서만 진행합니다.

$ mkdir log

$ mkdir conf


먼저 config servers을 설치하고 구동시켜야한다. 

config servers은 1대아님 3대가 권장설정이기 때문에 mongo02서버에서는 생략 ( mongo_install_dir 에는 설치한 mongo dir경로를 넣어줌 된다 ) 

 

 $ vi $mongo_install_dir/conf/configsvr.conf

systemLog:
   verbosity: 5
   destination: file
   path: $mongo_install_dir/log/configsvr.log
   logAppend: true

storage:
   dbPath: $mongo_install_dir/mongodb/configsvr

processManagement:
   fork: true
   pidFilePath: $mongo_install_dir/mongodb/pid/configsvr.pid

net:
   bindIp: 0.0.0.0 # 이 부분이 중요하다 127.0.0.1일 시 local에서만 사용가능 
   port: 27022

#security:
#   keyFile: /home/unisecure/mongodb/key/mongodb.key

sharding:
   clusterRole: configsvr

replication:
   replSetName: configGroup



실행

#mongoldb/bin폴더에서 mongod 을 통해 실행

 $ ./mongod --config $mongo_install_dir/mongodb/conf/configsvr.conf 



config server설정 ( mongo01 에서 진행 )

$ mongo --host localhost --port 27022


rs.initiate({id:"configGroup",configsvr:true,members:[{ _id:0 , host:"192.168.0.2:27022"} ] })

# 이와 같이 설정해준다. config server가 여러대라면 members에 같은 형식으로 추가해주면된다.


rs.initiate({})

#config server가 한대라면 이 와같이 입력해도 무방하다.



# 상태확인

rs.status()



# 아래와 같이 나오면 성공 

configGroup:SECONDARY> rs.status()

{

        "set" : "configGroup",

        "date" : ISODate("2018-01-26T01:41:15.233Z"),

        "myState" : 1,

        "term" : NumberLong(1),

        "configsvr" : true,

        "heartbeatIntervalMillis" : NumberLong(2000),

        "optimes" : {

                "lastCommittedOpTime" : {

                        "ts" : Timestamp(1516930863, 3),

                        "t" : NumberLong(1)

                },

                "readConcernMajorityOpTime" : {

                        "ts" : Timestamp(1516930863, 3),

                        "t" : NumberLong(1)

                },

                "appliedOpTime" : {

                        "ts" : Timestamp(1516930863, 3),

                        "t" : NumberLong(1)

                },

                "durableOpTime" : {

                        "ts" : Timestamp(1516930863, 3),

                        "t" : NumberLong(1)

                }

        },

        "members" : [

                {

                        "_id" : 0,

                        "name" : “mongo01:27022",

                        "health" : 1,

                        "state" : 1,

                        "stateStr" : "PRIMARY",

                        "uptime" : 501,

                        "optime" : {

                                "ts" : Timestamp(1516930863, 3),

                                "t" : NumberLong(1)

                        },

                        "optimeDate" : ISODate("2018-01-26T01:41:03Z"),

                        "infoMessage" : "could not find member to sync from",

                        "electionTime" : Timestamp(1516930855, 1),

                        "electionDate" : ISODate("2018-01-26T01:40:55Z"),

                        "configVersion" : 1,

                        "self" : true

                }

        ],

        "ok" : 1,

        "operationTime" : Timestamp(1516930863, 3)

}

 



shard서버 구동 ( mongo01, mongo02서버에서 진행 )

# $mongo_install_dir / conf 디렉토리에서 파일수정

 $ vi shardsvr.conf

systemLog:

   verbosity: 4

   destination: file

   path: $mongo_install_dir/log/shardsvr.log

   quiet: true

   logAppend: true

   logRotate: rename


storage:

   dbPath: $mongo_install_dir/shardsvr

   directoryPerDB: true

   journal:

      enabled: true


processManagement:

   fork: true

   pidFilePath: $mongo_install_dir/pid/shardsvr.pid


net:

   bindIp: 0.0.0.0

   port: 27033


sharding:

   clusterRole: shardsvr


shard서버구동

# $mongo_install_dir / bin 디렉토리에서 mongod 실행

  ./mongod --config $mongo_install_dir/conf/shardsvr.conf 





mongos서버 구동 ( mongo01, mongo02서버에서 진행 )

# $mongo_install_dir / bin 디렉토리에서 mongos 실행 

./mongos --configdb configGroup/mongo01:27022 --bind_ip 0.0.0.0 --port 27011 --logpath $mongo_install_dir/mongodb/log/mongos.log & 


# admin으로 실행

mongos> use admin

switched to db admin


mongos> sh.addShard("mongo01:27033")

{

        "shardAdded" : "shard0000",

        "ok" : 1,

        "$clusterTime" : {

                "clusterTime" : Timestamp(1516934294, 4),

                "signature" : {

                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),

                        "keyId" : NumberLong(0)

                }

        },

        "operationTime" : Timestamp(1516934294, 4)

}

mongos> sh.addShard("mongo02:27033")

{

        "shardAdded" : "shard0001",

        "ok" : 1,

        "$clusterTime" : {

                "clusterTime" : Timestamp(1516934300, 2),

                "signature" : {

                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),

                        "keyId" : NumberLong(0)

                }

        },

        "operationTime" : Timestamp(1516934300, 2)

}


# 샤딩 상태확인

mongos> sh.status()

config.locks collection empty or missing. be sure you are connected to a mongos

--- Sharding Status ---

  sharding version: {

        "_id" : 1,

        "minCompatibleVersion" : 5,

        "currentVersion" : 6,

        "clusterId" : ObjectId("5a6a8cf0744d26f58db56f3b")

  }

  shards:

        {  "_id" : "shard0000",  "host" : “mongo01:27033",  "state" : 1 }

        {  "_id" : "shard0001",  "host" : "mongo02:27033",  "state" : 1 }

  active mongoses:

        "3.6.2" : 1

  balancer:

        Currently enabled:  yes

        Currently running:  no

        Failed balancer rounds in last 5 attempts:  0

        Migration Results for the last 24 hours:

                No recent migrations

  databases:


 


mongos 에서 database와 collection을 활성화시켜야 사용가능하다.


샤딩활성화 ( test데이터베이스 활성화 ) 

 mongos> sh.enableSharding("test")

{

        "ok" : 1,

        "$clusterTime" : {

                "clusterTime" : Timestamp(1516934488, 5),

                "signature" : {

                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),

                        "keyId" : NumberLong(0)

                }

        },

        "operationTime" : Timestamp(1516934488, 5)

}




컬렉션 샤딩설정 ( test db의 t1 컬렉션 활성화 ) 

mongos> sh.shardCollection("test.t1",{regdate:"hashed"})

{

        "collectionsharded" : "test.t1",

        "collectionUUID" : BinData(4,"eM/P3uVVS9OKYMNGmylDwA=="),

        "ok" : 1,

        "$clusterTime" : {

                "clusterTime" : Timestamp(1516934531, 4),

                "signature" : {

                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),

                        "keyId" : NumberLong(0)

                }

        },

        "operationTime" : Timestamp(1516934531, 4)

}

 


설정확인


mongos> sh.status()

config.locks collection empty or missing. be sure you are connected to a mongos

--- Sharding Status ---

  sharding version: {

        "_id" : 1,

        "minCompatibleVersion" : 5,

        "currentVersion" : 6,

        "clusterId" : ObjectId("5a6a8cf0744d26f58db56f3b")

  }

  shards:

        {  "_id" : "shard0000",  "host" : “mongo01:27033",  "state" : 1 }

        {  "_id" : "shard0001",  "host" : "mongo02:27033",  "state" : 1 }

  active mongoses:

        "3.6.2" : 1

  balancer:

        Currently enabled:  yes

        Currently running:  no

        Failed balancer rounds in last 5 attempts:  0

        Migration Results for the last 24 hours:

                No recent migrations

  databases:

        {  "_id" : "test",  "primary" : "shard0001",  "partitioned" : true }

                test.t1

                        shard key: { "regdate" : "hashed" }

                        unique: false

                        balancing: true

                        chunks:

                                shard0001       2

                        { "regdate" : { "$minKey" : 1 } } -->> { "regdate" : NumberLong(0) } on : shard0001 Timestamp(1, 0)

                        { "regdate" : NumberLong(0) } -->> { "regdate" : { "$maxKey" : 1 } } on : shard0001 Timestamp(1, 1) 



검증

샤딩서버로 접속

  ./mongo localhost:27033


# mongo01에서 진행

# mongos서버에서 지정했던 sharding 테이블에 데이터를 집어넣는다.


> use test

switched to db test

>

>

> db.t1.insert([ { name: "Abet", age: 19, regdate: ISODate() },{ name: "Betty", age: 20, regdate: ISODate() } ]);

BulkWriteResult({

        "writeErrors" : [ ],

        "writeConcernErrors" : [ ],

        "nInserted" : 2,

        "nUpserted" : 0,

        "nMatched" : 0,

        "nModified" : 0,

        "nRemoved" : 0,

        "upserted" : [ ]

})

>

>

> show collections;

t1

> db.t1.find({name:"Abet"})

{ "_id" : ObjectId("5a6a9bb0e9e058fc826770c5"), "name" : "Abet", "age" : 19, "regdate" : ISODate("2018-01-26T03:08:32.564Z") }



mongo02에서도 체크 

 ./mongo localhost:27033

> use test

switched to db test

> db.t1.find({name:"Abet"})

{ "_id" : ObjectId("5a6a9bb0e9e058fc826770c5"), "name" : "Abet", "age" : 19, "regdate" : ISODate("2018-01-26T03:08:32.564Z") }












 

'apps > mongodb' 카테고리의 다른 글

Mongodb란?  (0) 2018.02.10

+ Recent posts