In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "the installation and configuration steps of mongodb". In the daily operation, I believe many people have doubts about the installation and configuration steps of mongodb. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "installation and configuration steps of mongodb". Next, please follow the editor to study!
1. Mongodb installation
1. Download:
Https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.10.tgz
2. Installation
[root@node1 mongodb] # tar-xzvf mongodb-linux-x86_64-rhel62-3.4.10.tgz
[root@node1 mongodb] # mv mongodb-linux-x86_64-rhel62-3.4.10 / usr/local/mongodb
[root@node1 mongodb] # vi ~ / .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mongodb/bin
Export PATH
[root@node1 mongodb] # source ~ / .bash_profile
3. Configuration
(1) creation of data and log directories
[root@node1 mongodb] # mkdir-p / home/mongodb/data
[root@node1 mongodb] # mkdir / home/mongodb/logs
(2) launch configuration file creation
[root@node1 mongodb] # touch / home/mongodb/mongo.conf
Click (here) to collapse or open
Port = 27017
Fork = true
Pidfilepath = / home/mongodb
Dbpath = / home/mongodb/data
Logpath = / home/mongodb/logs/mongodb.log
Logappend = true
OplogSize = 1000
MaxConns = 5000
Profile = 1
Slowms = 5
Shardsvr = true
StorageEngine = wiredTiger
(3) start service configuration
[root@node1 mongodb] # vi / etc/init.d/mongod
[root@node1 mongodb] # chmod uplix / etc/init.d/mongod
[root@node1 mongodb] # chkconfig-- add / etc/init.d/mongod
Click (here) to collapse or open
#! / bin/sh
# chkconfig:-64 36
# description:mongod
Case $1 in
Start)
/ usr/local/mongodb/bin/mongod-f / home/mongodb/mongo.conf
Stop)
/ usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.shutdownServer ()"
Status)
/ usr/local//mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.stats ()"
Esac
4. Start
(1) Command line startup
Do not start http access, listen on port 27017
[root@node1 mongodb] # mongod-dbpath / home/mongodb/data-port 27017-logpath / home/mongodb/logs-logappend
Start http access, http listens on port 28017
[root@node1 mongodb] # mongod-- dbpath / home/mongodb/data-- rest
(2) configuration file startup
[root@node1 mongodb] # mongod-f / home/mongodb/mongo.conf
About to fork child process, waiting until server is ready for connections.
Forked process: 16357
Child process started successfully, parent exiting
(3) Service startup
[root@node1 mongodb] # service mongod start
About to fork child process, waiting until server is ready for connections.
Forked process: 16814
Child process started successfully, parent exiting
5. Close
(1) > use admin
Switched to db admin
> db.shutdownServer ()
Server should be down...
(2) or close directly through the kill command
(3) service mongod stop
6. Connect mongodb
The default port is 27017 and the listening IP address is 127.0.0.1
(1) Direct connection
[root@node1 ~] # mongo
(2) specify connection IP, port, user, and password connection
(3)
II. Daily management of Mongodb
1. Mongodb tool
Bsondump
Mongod
Mongoexport
Mongoimport
Mongoperf
Mongorestore
Mongostat
Mongo
Mongodump
Mongofiles
Mongooplog
Mongoreplay
Mongos
Mongotop
2. Mongodb common commands
(1) View the database
> show dbs # # View all databases
Admin 0.000GB
Local 0.000GB
> db # # View the current database
Test
(2) switch databases
> use admin # # switch to admin database
Switched to db admin
(3)
III. Concept
1. Data comparison
The basic concepts in mongodb are documents, collections and databases.
SQL terminology / concept MongoDB terminology / concept explanation / explanation
Database database database
Table collection database tables / collections
Row document data record rows / documents
Column field data Fields / domains
Index index index
Table joins table join, not supported by MongoDB
Primary key. MongoDB automatically sets the _ id field as the primary key.
2. Mongodb common commands
IV. Appendix
1. Mongod parameter description
-- quiet # quiet output
-- port arg # specifies the service port number, default port 27017
-- bind_ip arg # bind service IP. If binding 127.0.0.1, it can only be accessed locally. Default local IP is not specified.
-- logpath arg # specifies the MongoDB log file. Note that the specified file is not a directory.
-- logappend # writes logs by appending
-- the full path of pidfilepath arg # PID File. If not set, there is no PID file.
-- the full path of the private key of the keyFile arg # cluster, valid only for Replica Set architecture
-- unixSocketPrefix arg # UNIX domain socket replacement directory (default is / tmp)
-- fork # runs MongoDB as a daemon to create a server process
-- auth # enable authentication
-- cpu # periodically displays the CPU utilization and iowait of CPU
-- dbpath arg # specify the database path
-- diaglog arg # diaglog option 0=off 1 "W 2R 3=both 7=W+some reads
-- directoryperdb # sets that each database will be saved in a separate directory
-- journal # enable the logging option, and the data operations of MongoDB will be written to the files in the journal folder
-- journalOptions arg # enable log diagnostics option
-- ipv6 # enable IPv6 option
-- jsonp # allows JSONP access via HTTP (with security implications)
-- maxConns arg # maximum number of simultaneous connections defaults to 2000
-- noauth # does not enable authentication
-- nohttpinterface # shuts down the http interface and port 27018 access is disabled by default
-- noprealloc # disables data file pre-allocation (often affecting performance)
-- noscripting # disable scripting engine
-- notablescan # does not allow table scanning
-- nounixsocket # disable Unix socket snooping
-- nssize arg (= 16) # set the letter database. ns file size (MB)
-- objcheck # checks the validity of customer data after receiving it
-- profile arg # Archive parameters 0=off 1=slow, 2=all
-- quota # limits the number of files per database. The default setting is 8.
-quotaFiles arg # number of files allower per db, requires-quota
-- rest # enable simple rest API
-- repair # repair all database run repair on all dbs
-- repairpath arg # the directory of the files generated by the repair library. The default is the directory name dbpath
-slowms arg (= 100) # value of slow for profile and console log
-- smallfiles # uses smaller default files
-- syncdelay arg (= 60) # seconds in which data is written to disk (0=never, not recommended)
-- sysinfo # print some diagnostic system information
-- upgrade # if you need to upgrade the database * Replicaton parameter
-- fastsync # enables the slave library replication service from a dbpath whose database is a snapshot of the master library and can be used to quickly enable synchronization
-- autoresync # if the synchronization data between the slave library and the master database is much worse, it will be resynchronized automatically.
-- oplogSize arg # set the size of oplog (MB) * master / slave parameters
-- master # main library mode
-- slave # slave library mode
-- source arg # Slave Port number
-- only arg # specifies a single database replication
-- slavedelay arg # sets the Replica set (replica set) option for synchronizing the master database from the library:
-- replSet arg # set replica set name * Sharding (sharding) option
-- configsvr # declares that this is a cluster config service, default port 27019, default directory / data/configdb
-- shardsvr # declares that this is a cluster shard, default port 27018
-- noMoveParanoia # turn off paranoia for moveChunk data saving
At this point, the study on the "installation and configuration steps of mongodb" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.