Linux安装Mongodb-4.2.9

1. 下载

下载地址:https://www.mongodb.com/

在这里插入图片描述

2. 上传文件到服务器并解压

tar -zxvf mongodb-linux-x86_64-rhel70-4.2.9.tgz
mv mongodb-linux-x86_64-rhel70-4.2.9 mongodb
[root@rpp local]# tar -zxvf mongodb-linux-x86_64-rhel70-4.2.9.tgz 
mongodb-linux-x86_64-rhel70-4.2.9/THIRD-PARTY-NOTICES.gotools
mongodb-linux-x86_64-rhel70-4.2.9/README
mongodb-linux-x86_64-rhel70-4.2.9/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel70-4.2.9/MPL-2
mongodb-linux-x86_64-rhel70-4.2.9/LICENSE-Community.txt
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongodump
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongorestore
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongoexport
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongoimport
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongostat
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongotop
mongodb-linux-x86_64-rhel70-4.2.9/bin/bsondump
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongofiles
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongoreplay
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongod
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongos
mongodb-linux-x86_64-rhel70-4.2.9/bin/mongo
mongodb-linux-x86_64-rhel70-4.2.9/bin/install_compass
[root@rpp local]# mv mongodb-linux-x86_64-rhel70-4.2.9 mongodb
[root@rpp local]# cd mongodb
[root@rpp mongodb]# ls
bin  LICENSE-Community.txt  MPL-2  README  THIRD-PARTY-NOTICES  THIRD-PARTY-NOTICES.gotools

3. 服务端启动

  • 以默认配置启动
./bin/mongod
  • 指定配置文件启动
./bin/mongod -f mongo.conf
[root@rpp mongodb]# ./bin/mongod -f mongo.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 2651
child process started successfully, parent exiting
  • 配置文件示例内容如下
dbpath=/data/mongo/ # 数据库目录,默认/data/db 
port=27017 			# 监听的端口,默认27017 
bind_ip=0.0.0.0 	# 监听IP地址,默认全部可以访问 
fork=true			# 是否已后台启动的方式登陆 
logpath = /data/mongo/MongoDB.log # 日志路径
logappend = true 	# 是否追加日志
auth=false			# 是开启用户密码登陆
  • 启动日志
2020-09-27T14:01:30.522+0800 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-09-27T14:01:30.525+0800 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] MongoDB starting : pid=2651 port=27017 dbpath=/usr/local/mongodb/data/ 64-bit host=rpp
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] db version v4.2.9
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] git version: 06402114114ffc5146fd4b55402c96f1dc9ec4b5
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] allocator: tcmalloc
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] modules: none
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] build environment:
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten]     distmod: rhel70
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten]     distarch: x86_64
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-09-27T14:01:30.525+0800 I  CONTROL  [initandlisten] options: { config: "mongo.conf", net: { bindIp: "0.0.0.0", port: 27017 }, processManagement: { fork: true }, security: { authorization: "disabled" }, storage: { dbPath: "/usr/local/mongodb/data/" }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/mongodb/logs/MongoDB.log" } }
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] 
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1289M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-09-27T14:01:31.064+0800 I  STORAGE  [initandlisten] WiredTiger message [1601186491:64630][2651:0x7f158b4e0c40], txn-recover: Set global recovery timestamp: (0, 0)
2020-09-27T14:01:31.073+0800 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-09-27T14:01:31.083+0800 I  STORAGE  [initandlisten] Timestamp monitor starting
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 14327 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.088+0800 I  STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 7ac718bb-7407-4fbe-b23c-081fd5305822 and options: { uuid: UUID("7ac718bb-7407-4fbe-b23c-081fd5305822") }
2020-09-27T14:01:31.098+0800 I  INDEX    [initandlisten] index build: done building index _id_ on ns admin.system.version
2020-09-27T14:01:31.098+0800 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-09-27T14:01:31.098+0800 I  COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.2
2020-09-27T14:01:31.098+0800 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-09-27T14:01:31.098+0800 I  STORAGE  [initandlisten] Flow Control is enabled on this deployment.
2020-09-27T14:01:31.098+0800 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-09-27T14:01:31.098+0800 I  STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: ee07e635-9f76-46c6-b7b5-14eb57f42c1d and options: { capped: true, size: 10485760 }
2020-09-27T14:01:31.109+0800 I  INDEX    [initandlisten] index build: done building index _id_ on ns local.startup_log
2020-09-27T14:01:31.109+0800 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-09-27T14:01:31.109+0800 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/usr/local/mongodb/data/diagnostic.data'
2020-09-27T14:01:31.111+0800 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-09-27T14:01:31.111+0800 I  STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with provided UUID: 175270bd-fa10-43f1-9279-e6f893ee2d12 and options: { uuid: UUID("175270bd-fa10-43f1-9279-e6f893ee2d12") }
2020-09-27T14:01:31.112+0800 I  NETWORK  [listener] Listening on /tmp/mongodb-27017.sock
2020-09-27T14:01:31.112+0800 I  NETWORK  [listener] Listening on 0.0.0.0
2020-09-27T14:01:31.112+0800 I  NETWORK  [listener] waiting for connections on port 27017
2020-09-27T14:01:31.121+0800 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index _id_ on ns config.system.sessions
2020-09-27T14:01:31.132+0800 I  INDEX    [LogicalSessionCacheRefresh] index build: starting on config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 } using method: Hybrid
2020-09-27T14:01:31.132+0800 I  INDEX    [LogicalSessionCacheRefresh] build may temporarily use up to 200 megabytes of RAM
2020-09-27T14:01:31.132+0800 I  INDEX    [LogicalSessionCacheRefresh] index build: collection scan done. scanned 0 total records in 0 seconds
2020-09-27T14:01:31.132+0800 I  INDEX    [LogicalSessionCacheRefresh] index build: inserted 0 keys from external sorter into index in 0 seconds
2020-09-27T14:01:31.134+0800 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index lsidTTLIndex on ns config.system.sessions
2020-09-27T14:01:31.136+0800 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-09-27T14:01:32.000+0800 I  SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
  • 数据文件
[root@rpp mongodb]# cd data/
[root@rpp data]# ll
total 184
-rw------- 1 root root 20480 Sep 27 14:02 collection-0-6741117600621229546.wt
-rw------- 1 root root 20480 Sep 27 14:02 collection-2-6741117600621229546.wt
-rw------- 1 root root  4096 Sep 27 14:01 collection-4-6741117600621229546.wt
drwx------ 2 root root  4096 Sep 27 14:02 diagnostic.data
-rw------- 1 root root 20480 Sep 27 14:02 index-1-6741117600621229546.wt
-rw------- 1 root root 20480 Sep 27 14:02 index-3-6741117600621229546.wt
-rw------- 1 root root  4096 Sep 27 14:01 index-5-6741117600621229546.wt
-rw------- 1 root root  8192 Sep 27 14:02 index-6-6741117600621229546.wt
drwx------ 2 root root  4096 Sep 27 14:01 journal
-rw------- 1 root root 20480 Sep 27 14:02 _mdb_catalog.wt
-rw------- 1 root root     5 Sep 27 14:01 mongod.lock
-rw------- 1 root root  4096 Sep 27 14:01 sizeStorer.wt
-rw------- 1 root root   114 Sep 27 14:01 storage.bson
-rw------- 1 root root    46 Sep 27 14:01 WiredTiger
-rw------- 1 root root  4096 Sep 27 14:01 WiredTigerLAS.wt
-rw------- 1 root root    21 Sep 27 14:01 WiredTiger.lock
-rw------- 1 root root  1246 Sep 27 14:02 WiredTiger.turtle
-rw------- 1 root root 32768 Sep 27 14:02 WiredTiger.wt

4. mongo shell 的启动

  • 默认配置直接启动
./bin/mongo
  • 指定主机和端口的方式启动
./bin/mongo --host=主机IP --port=端口
[root@rpp mongodb]# ./bin/mongo
MongoDB shell version v4.2.9
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("3b1763d4-2156-45b5-9199-81e3de9823ee") }
MongoDB server version: 4.2.9
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
        https://community.mongodb.com
Server has startup warnings: 
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] 
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-09-27T14:01:30.526+0800 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 14327 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2020-09-27T14:01:31.087+0800 I  CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> 

5. Mongodb GUI工具

5.1 MongoDB Compass Community

MongoDB Compass Community由MongoDB开发人员开发,这意味着更高的可靠性和兼容性。它为 MongoDB提供GUI mongodb工具,以探索数据库交互,具有完整的CRUD功能并提供可视方式。借助 内置模式可视化,用户可以分析文档并显示丰富的结构。为了监控服务器的负载,它提供了数据库操作 的实时统计信息。就像MongoDB一样,Compass也有两个版本,一个是Enterprise(付费),社区可 以免费使用。适用于Linux,Mac或Windows。

下载地址:https://www.mongodb.com/

在这里插入图片描述
在这里插入图片描述

5.2 NoSQLBooster(mongobooster)

NoSQLBooster是MongoDB CLI界面中非常流行的GUI工具。它正式名称为MongoBooster。 NoSQLBooster是一个跨平台,它带有一堆mongodb工具来管理数据库和监控服务器。这个Mongodb 工具包括服务器监控工具,Visual Explain Plan,查询构建器,SQL查询,ES2017语法支持等等…它 有免费,个人和商业版本,当然,免费版本有一些功能限制。NoSQLBooster也可用于Windows, MacOS和Linux。

下载地址:https://www.mongobooster.com/downloads

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值