mongodb3.2安装
admin
2023-02-06 13:00:05
0

mongodb3.x版本有好多新功能,关于这方面参考官网即可。。。

mongodb3.x配置文件使用yaml格式,和salt以及ansible格式一样一样滴,哈哈。。。

下载mongodb3.2版本

[root@mongo-test ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.3.tgz

解压mongodb以及改名mongodb

[root@mongo-test ~]# tar fxz mongodb-linux-x86_64-rhel62-3.2.3.tgz 
[root@mongo-test ~]# ll mongodb-linux-x86_64-rhel62-3.2.3
total 100
drwxr-xr-x 2 root root  4096 Mar  5 15:10 bin
-rw-r--r-- 1 root root 34520 Feb 18 03:42 GNU-AGPL-3.0
-rw-r--r-- 1 root root 16726 Feb 18 03:42 MPL-2
-rw-r--r-- 1 root root  1359 Feb 18 03:42 README
-rw-r--r-- 1 root root 35910 Feb 18 03:42 THIRD-PARTY-NOTICES
[root@mongo-test ~]# mv mongodb-linux-x86_64-rhel62-3.2.3 /usr/local/mongodb


mongodb环境变量配置

vim /etc/profile
export PATH=$PATH:/usr/local/mongodb/bin


加载环境配置文件

[root@mongo-test ~]# source /ect/profile




创建mongodb数据目录

[root@mongo-test ~]# mkdir /data
[root@mongo-test ~]# mkdir /data/{logs,mongo-data,config}//logs存放日志目录,mongo-data存放数据,config存放配置文件
[root@mongo-test ~]# tree /data/
/data/
├── config
├── logs
└── mongo-data
3 directories, 0 files


mongod配置文件如下:

[root@mongo-test config]# cat mongod.conf 
systemLog:
  destination: file
  path: /data/logs/mongod.log
  logAppend: true
processManagement:
  fork: true
  pidFilePath: "/data/mongo-data/mongod.pid"
net:
  port: 27017
  http:
    enabled: true
storage:
  dbPath: "/data/mongo-data"
  engine: wiredTiger
  wiredTiger:
    engineConfig:
      cacheSizeGB: 1
      directoryForIndexes: true
    collectionConfig:
      blockCompressor: zlib
    indexConfig:
      prefixCompression: true
  journal:
    enabled: true
  directoryPerDB: true
security:
  authorization: disable


注:现在mongo3.x以后的版本配置文件都是yaml格式的,官方关于mongo配置文件相关选项说明,https://docs.mongodb.org/manual/reference/configuration-options/#configuration-file


  启动mongodb以及查看mongod端口

[root@mongo-test config]# mongod -f mongod.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 17222
child process started successfully, parent exiting
[root@mongo-test config]# netstat -ntpl|grep mongod
tcp        0      0 0.0.0.0:28017               0.0.0.0:*                   LISTEN      17222/mongod        
tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      17222/mongod


登陆mongod实例,并创建zxl以及在test集合中插入数据查询等等。。。

[root@mongo-test config]# mongo --port 27017
MongoDB shell version: 3.2.3
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2016-03-05T22:40:23.212+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-03-05T22:40:23.212+0800 I CONTROL  [initandlisten] 
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] 
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] 
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-03-05T22:40:23.213+0800 I CONTROL  [initandlisten] 
> show dbs;
local  0.000GB
> use zxl;
switched to db zxl
> db.test.insert({name:"haha",age:18})
WriteResult({ "nInserted" : 1 })
> db.test.find()
{ "_id" : ObjectId("56daf1eacfaf29514f85d236"), "name" : "haha", "age" : 18 }

mongod实例web界面,端口是在原有mongod实例端口27017加上1000,也就是28017,在上面查看mongod实例端口可以发现有28017.。

mongodb3.2安装



相关内容

热门资讯

成都深入实施“人工智能+”行动 成都深入实施“人工智能+”行动 到2027年实现人工智能核心产业规模突破2600亿元 华西都市报讯(...
原创 中... 说真的,看到欧洲科学家一本正经拿粪水浇菜做研究,最后还得出了个“安全无害、肥力充足”的结论,我第一反...
小米智能手环11 Active... IT之家 7 月 23 日消息,科技媒体 WinFuture 昨日(7 月 22 日)发布博文,分享...
胡塞武装袭击红海油轮,特朗普威... 据路透社报道,当地时间7月23日,也门胡塞武装表示已在红海袭击两艘沙特油轮,并称这两艘油轮违反该组织...
刚签就要黄了?特朗普:核能协议... 据彭博社报道,当地时间7月23日,美国总统特朗普表示,美国与沙特阿拉伯的民用核能合作协议能否落地,将...
原创 宇... 可观测宇宙的范围远远超出了以光年为单位的其年龄,因为在遥远光线传播的过程中,空间本身已经膨胀了。然而...
我国研发出具有“电子共振”结构... 【我国研发出具有“电子共振”结构的钙钛矿光伏电池】财联社7月22日电,苏州大学李耀文、陈先凯与东南大...
我国牵头制定,智能制造用例国际... 国际电工委员会智能制造系统委员会(IEC/SyC SM)近日发布《智能制造用例模板》国际标准。该标准...
一文看懂三星Z系列三款折叠新机... 【CNMO科技消息】近日,三星正式发布Z Fold8 Ultra、Z Fold8以及Z Flip8三...
4位菲尔兹奖得主有3位会说中文... 当地时间7月23日,2026年国际数学家大会在美国费城开幕,国际数学联盟在开幕式上正式公布第二十一届...