tms training

27
TMS system and MongoDB introduction RICH LEE CHT TMS Developer [email protected]

Upload: -

Post on 04-Jul-2015

120 views

Category:

Technology


6 download

DESCRIPTION

CHT TMS training and MongoDB introduction.

TRANSCRIPT

Page 1: Tms training

TMS system and MongoDB introduction

RICH LEE

CHT TMS Developer

richleethinkpowercomtw

TMS System Architecture

MongoDB Introduction

TMS MongoDB

QampA

2014826 CHT TMS Training 2

TMS Module CDR Parser

CDR Consolidator Data Voice Mvpn

CSV Generator

Report Usage Lumsum Frozen

Performance Report

SNMP Alarm

API

2014826 CHT TMS Training 3

TMS Module Diagram

2014826 CHT TMS Training 4

CDR process flow

2014826 CHT TMS Training 5

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 2: Tms training

TMS System Architecture

MongoDB Introduction

TMS MongoDB

QampA

2014826 CHT TMS Training 2

TMS Module CDR Parser

CDR Consolidator Data Voice Mvpn

CSV Generator

Report Usage Lumsum Frozen

Performance Report

SNMP Alarm

API

2014826 CHT TMS Training 3

TMS Module Diagram

2014826 CHT TMS Training 4

CDR process flow

2014826 CHT TMS Training 5

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 3: Tms training

TMS Module CDR Parser

CDR Consolidator Data Voice Mvpn

CSV Generator

Report Usage Lumsum Frozen

Performance Report

SNMP Alarm

API

2014826 CHT TMS Training 3

TMS Module Diagram

2014826 CHT TMS Training 4

CDR process flow

2014826 CHT TMS Training 5

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 4: Tms training

TMS Module Diagram

2014826 CHT TMS Training 4

CDR process flow

2014826 CHT TMS Training 5

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 5: Tms training

CDR process flow

2014826 CHT TMS Training 5

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 6: Tms training

Parser multi-thread conceptsbull Three stages of the CDR Parser

1st Decoder (Decode worker and MongoBO)

2nd Queues (Mongo Queue)

3rd Insert into DB (Mongo worker)bull Three parser instances

Parser (CCN)

Parser (SDP)

Parser (AIR)

2014826 CHT TMS Training 6

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 7: Tms training

What is MongoDB MongoDB is an open source document-oriented

database designed with both scalability and developer agility in mind

Instead of storing your data in tables and rows as you would with a relational database in MongoDB you store JSON-like documents with dynamic schemas(schema-free schemaless)

2014826 CHT TMS Training 7

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 8: Tms training

MongoDB Feature

Schema-less

Document-oriented (Bson)

Scale-out

Replica set

Sharding

Rich functionality

Index Aggregation Backup

2014826 CHT TMS Training 8

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 9: Tms training

Why use MongoDB bridge the gap between key-value stores (which are fast and

scalable) and relational databases (which have rich functionality)

2014826 CHT TMS Training 9

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 10: Tms training

MongoDB vs RDBMS

2014826 CHT TMS Training 10

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 11: Tms training

Data model

Using BSON (binary JSON) developers can easily map to modern object-oriented languages without a complicated ORM layer

2014826 CHT TMS Training 11

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 12: Tms training

Schema design

2014826 CHT TMS Training 12

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 13: Tms training

Schema design

2014826 CHT TMS Training 13

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 14: Tms training

Basic operator

2014826 CHT TMS Training 14

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 15: Tms training

2014826 CHT TMS Training 15

Read Command in MySQL

Read Command in MongoDB

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 16: Tms training

Replica set ndash scale out

2014826 CHT TMS Training 16

1 Availability

2 Fault tolerance

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 17: Tms training

Replica set - election

2014826 CHT TMS Training 17

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 18: Tms training

Replica set consistency Only one server is active for writes (the primary) at a given time ndash

this is to allow strong consistent (atomic) operations

One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable

2014826 CHT TMS Training 18

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 19: Tms training

DB list

2014826 CHT TMS Training 19

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 20: Tms training

User role

Login TMS MongoDB mongo --host 1010660654001 --username tmsdb mdashpassword xxxx --

authenticationDatabase admin

Use DB and count show dbs (only root uesr) use TMS_CCN_1_DB dbTMS_CCN_1_140506count()

2014826 CHT TMS Training 20

Account DB Role Description

tmsdb ROOT Super admin

cht_app Read Write Can CRUD

cht_report Read Only query data

cht_cluster Cluster admin View replica status

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 21: Tms training

Field mapping

2014826 CHT TMS Training 21

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 22: Tms training

Query definition

Equal Query

dbTMS_CCN_2_140715find(MSISDN886988413631)

Regex Query

dbTMS_CCN_2_140715find(MSISDN$regex 988413631)

And Query

dbTMS_CCN_4_140804find( $and [ MSISDN886988413631rdquo

rdquoBP886905001256rdquo ] )

Project (Select feild)

dbTMS_CCN_4_140724find( MSISDN886905004094rdquo

MSISDN 1 BP 1 TT 1 DT 1)

2014826 CHT TMS Training 22

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 23: Tms training

2014826 CHT TMS Training 23

Query by date range GMT not local timezone

dbTMS_CCN_1_140609find( $and [ MSISDN 886905001250 TT $gte new ISODate(2014-06-16 010050652Z) DT $lte new ISODate(2014-06-16 015950652Z) ] )

Distinct Query dbTMS_CCN_1_140822distinct( MSISDN

TT $gt new ISODate(2014-08-22 050000294Z) )

Sort Query dbTMS_CCN_4_140722find( ISCSVfalse )sort( OCCR8 1 )

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 24: Tms training

Check Replica set status rsstatus()

View Replica set configuration rsconf()

Set secondary node can read rsslaveOk()

2014826 CHT TMS Training 24

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 25: Tms training

Http Rest interface httphostportport is mongod port +1000

2014826 CHT TMS Training 25

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 26: Tms training

MongoDB monitor mongostat --host localhost27017 --username accountmdashpassword

pass --authenticationDatabase admin

Check MongoDB log Mongolog (optmongodatalog)

2014826 CHT TMS Training 26

2014826 CHT TMS Training 27

Page 27: Tms training

2014826 CHT TMS Training 27