博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos7安装mongodb
阅读量:5880 次
发布时间:2019-06-19

本文共 5130 字,大约阅读时间需要 17 分钟。

hot3.png

1.下载安装包

# mkdir mongodb# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.10.tgz-bash: wget: 未找到命令# yum install -y wget #安装wget# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.10.tgz--2016-10-04 17:59:38--  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.10.tgz正在解析主机 fastdl.mongodb.org (fastdl.mongodb.org)... 54.230.73.145, 54.230.73                                                                                  .80, 54.230.73.231正在连接 fastdl.mongodb.org (fastdl.mongodb.org)|54.230.73.145|:443... 已连接。已发出 HTTP 请求,正在等待回应... 读取文件头错误 (Connection reset by peer)。重试中。--2016-10-04 18:00:11--  (尝试次数: 2)  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.10.tgz# yum update openssl   #更新openssl# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.10.tgz

2.解压并测试运行

# tar cxvf mongodb-linux-x86_64-rhel70-3.2.10.tgz# cd mongodb-linux-x86_64-rhel70-3.2.10# bin/mongod2016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] MongoDB starting : pid=2642 port=27017 dbpath=/data/db 64-bit host=localhost.localdomain2016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] db version v3.2.102016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d03172016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 20132016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] allocator: tcmalloc2016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] modules: none2016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] build environment:2016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten]     distmod: rhel702016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten]     distarch: x86_642016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten]     target_arch: x86_642016-10-04T20:21:34.217+0800 I CONTROL  [initandlisten] options: {}2016-10-04T20:21:34.238+0800 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.2016-10-04T20:21:34.238+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),2016-10-04T20:21:38.481+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten]2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten]2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten]2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2016-10-04T20:21:38.482+0800 I CONTROL  [initandlisten]2016-10-04T20:21:38.486+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'2016-10-04T20:21:38.487+0800 I NETWORK  [initandlisten] waiting for connections on port 270172016-10-04T20:21:38.488+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

使用robomongo测试连接状态

输入图片说明 3.配置环境变量(可省略) 在/etc/profile中添加

export PATH=/mongodb/mongodb-linux-x86_64-rhel70-3.2.10/bin:$PATH
# source /etc/profile   #刷新bash# echo $PATH/mongodb/mongodb-linux-x86_64-rhel70-3.2.10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

4.使用配置文件启动 新建mongod.conf,上传至/etc

port=27018 #端口号  logpath=/data/mongodb/log/mongodb.log #日志输出文件路径  logappend=true #日志输出方式  dbpath=/data/mongodb/data/db #数据库路径
# mkdir -p  /data/mongodb/log/# mkdir -p /data/mongodb/data/db# mongod --config /etc/mongod.conf   #因为配置了环境变量,可直接使用mongod,如果不配置,可执行命令bin/mongod --config /etc/mongod.conf

输入图片说明 5.创建service启动 添加mongod.service文件,并将其上传到/usr/lib/systemd/system目录

[Unit]Description=Mongodb nosql databaseAfter=network.target[Service]ExecStart=/mongodb/mongodb-linux-x86_64-rhel70-3.2.10/bin/mongod --config /etc/mongod.conf[Install]WantedBy=multi-user.target

启动并配置随开机启动

# systemctl start mongod.service# systemctl enable mongod.service# ss -ltState      Recv-Q Send-Q Local Address:Port                 Peer Address:Port                                                                                     LISTEN     0      128        *:27018                    *:*LISTEN     0      128        *:ssh                      *:*LISTEN     0      100    127.0.0.1:smtp                     *:*                                                                                                   LISTEN     0      128       :::ssh                     :::*LISTEN     0      100      ::1:smtp                    :::*

转载于:https://my.oschina.net/weidedong/blog/754373

你可能感兴趣的文章
Spring中factory-method的使用
查看>>
zTree默认选中指定节点并执行事件
查看>>
编译安装syslog-ng debian
查看>>
通过爬妹子图片来学习async/await
查看>>
【python】编程语言入门经典100例--35
查看>>
cookie增加Secure属性
查看>>
360浏览器兼容模式 - 兼容问题
查看>>
WebLogic11g-负载分发
查看>>
appcan是什么
查看>>
美国破获世纪“银行大劫案”隐形罪犯不再拿刀枪
查看>>
我的友情链接
查看>>
linux系统网络服务命令(一)
查看>>
IT讲师韩顺平:我为什么辞去百万年薪,自己创业?
查看>>
工作记录
查看>>
【go语言】读书随笔
查看>>
Activity猫的一生-故事解说Activity生命周期
查看>>
python:使用socket模块,进行服务器与客户端简单交互
查看>>
FTP服务器的部署和维护心得
查看>>
第一部分 思科九年 一(15)
查看>>
IE6/IE7/IE8/Firefox/Chrome/Safari的CSS hack兼容一览表
查看>>