Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb installation configuration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1.Mongo DB is a kind of non-relational database (NoSql) which is very popular in IT industry at present, and its flexible data

Storage mode is favored by current IT practitioners. Mongo DB realizes the object-oriented idea (OO idea) very well.

In Mongo DB, each record is a Document object. The biggest advantage of Mongo DB is that all the data

Persistent operations do not require developers to write SQL statements manually, and you can easily implement CRUD operations by calling methods directly.

2.monogodb installation

1.wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.5.tgz

2.tar xf mongodb-linux-x86_64-2.6.5.tgz

3.mv mongodb-linux-x86_64-2.6.5 / usr/local/mongodb

4.yum install openssl-devel openssl

3.mongodb starts the test

1.mkdir-pv / data/mongodb / log/mongodb

2./usr/local/mongodb/bin/mongod-port 27017-fork-dbpath=/data/mongodb-logpath=/log/mongodb/mongodb.log-logappend

3./usr/local/mongodb/bin/mongo

Use admin

Db.shutdownServer ()

Exit

4.mongodb profile

Use another configuration file format after version 2.6, which is not compatible with the previous mode

2.6 http://docs.mongodb.org/manual/reference/configuration-options/

2.4 http://docs.mongodb.org/v2.4/reference/configuration-options/

Outline

ProcessManagement

SystemLog

Storage

Net

SetParameter

Security

OperationProfiling

Replication

Sharding

AuditLog

Example

Cat > > / usr/local/mongodb/mongodb.conf db.getMongo (). SetSlaveOk ()

two。 The primary node does not allow a direct priority of 0. You should execute the following command before setting it.

Rs.stepDown ()

3. View help

Rs.help ()

4. Official document

Http://docs.mongodb.org/manual/

5. Test statement

Db.foo.save ({"id": 123, "name": 'liuyuanshijie'})

Db.foo.find ({"id": 123})

6. Only the master can write, other nodes can not write, but can be set to read

# you can prepare two choices in advance when configuring. After configuration, one becomes primary and the other becomes secondary.

# then by setting it to a higher priority, when the master hangs up, the slave will immediately take over as the master.

# so that you can use keepalived to configure VIP on both machines to make it highly available.

# use a test script to detect the availability of mongodb services on both servers.

7.mongodb Cluster (Shard)

# the main function is that data can be fragmented and distributed to various machines

1. Configure config server

Cat > > / usr/local/mongodb/configsvr.conf / usr/local/mongodb/mongos.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report