In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about the basic management commands commonly used in mongodb. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
1. Start the service
Use parameter
-- dbpath specifies the data file path
-- logpath specifies error log file
-- logappend error log append method
-- bind_ip listens for ip addresses
-- port listening port
-f start with a parameter file
Folk runs in the background as a daemon
-- the time in which the syndelay system synchronously refreshes the disk.
. / mongod-dbpath=/data-logpath=/data/mongo.log-folk-bind_ip=192.168.234.154-port 999
If you start with a parameter file, you can write your own parameter file
Vim mongo.conf
Dbpath=/data
Logpath=/data/mongo.log
For (var item1 witch I db.pincer.dataSize ()
five hundred and forty eight
6. Get the total size of the aggregate set
Db.userInfo.totalSize ()
7. Size of storage space for aggregate sets.
Db.userInfo.storageSize ()
8. Shard version information
Db.userInfo.getShardVersion ()
9. Rename the aggregate set
Db.userInfo.renameCollection ("users")
Rename userInfo to users
10. Delete the current aggregate collection
Db.userInfo.drop ()
3. Get all the aggregate sets of the current db
Db.getCollectionNames ()
4. Display the status of all clustered indexes in the current db
Db.printCollectionStats ()
1. Add a user
Db.addUser ("name")
Db.addUser ("userName", "pwd123", true)
Add users, set passwords, whether read-only
2. Database authentication and security mode
Db.auth ("userName", "123123")
3. Show all current users
Show users
4. Delete a user
Db.removeUser ("userName")
Verify login:
Mongo-host=ip-port=num-uuser-ppassword dbname
1. Query the previous error message
Db.getPrevError ()
2. Clear the error record
Db.resetError ()
3. Rename the aggregate set
Db.userInfo.renameCollection ("users")
List the actions being performed
Db.currentOp (dbname)
Kill the operation being carried out
Db.killOp (opid)
Create a collection
1, creating a collection is 100, 000 bytes
Db.createCollection ("mycollection", {capped:true,size:100000})
2, create a collection with a size of 100000 bytes and a maximum number of documents
Db.createCollection ("mycollection", {capped:true,size:100000max:100})
Force cache data to be flushed to disk
Db.runCommand ({"fsync": 1, "lock": 1})
Online backup and recovery
Mongodump-d database-o backupdir
Mongorestore-d database-- drop backupdir
Mongo master and slave
Master:
Mongod-bind_ip=192.168.0.1-port=999-dbpath=/test-logpath=/test/mongo.log-logappend-master
Slave:
Mongod-bind_ip=192.168.0.2-- port=998-- dbpath=/test-- logpath=/test/mongo.log-- logappend-- slave-- source 192.168.0.1
-- only copies only the specified database
-- slavedelay slave node delay (in seconds)
-- autoersync if the slave node is out of sync with the master node, it will automatically resynchronize
-- oplogSize primary node oplog size in M
These are the basic mongodb management commands that Xiaobian shares with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.