centos系统安装mongdb

wget  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.4.tgz (下载)

然后解压

tar -zxvf    mongodb-linux-x86_64-rhel70-3.4.4.tgz

然后mv(改名成mongdb文件)


cd 进到 bin/  里 是没有mong_dome文件夹的(你需要自己手动建我是建好了)

mkdir mongdb_dome (建好了之后进去)

cd mongdb_dome

进来之后你需要新建 bin、conf、data、log文件夹

mkdir bin

mkdir conf

mkdir data

mkdir log

建完之后 进入conf文件

cd conf

[root@localhost mongdb_dome]# cd conf/
[root@localhost conf]# ll
总用量 4
-rw-r--r--. 1 root root 203 5月  31 22:53 mongdb.conf
[root@localhost conf]# cat mongdb.conf
dbpath = data #数据文件存放目录
logpath = log/mongodb.log #日志文件存放目录
port = 27017  #端口
fork = true  #以守护程序的方式启用,即在后台运行
nohttpinterface = true

vim的新建一个文件(mongdb.conf)里面的内容如上

cd ..  (回到mongdb_dome)

把  mongo  mongod  这两个复制到mongdb_dome里面的bin里

[root@localhost mongdb_dome]# cp ../mongod    ./bin/
[root@localhost mongdb_dome]# cp ../mongo    ./bin/

确保复制成功之后(做以下操作)

[root@localhost mongdb_dome]# ./bin/mongod  -f  conf/mongdb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2535
child process started successfully, parent exiting

提示信息跟我一样你就可以进data目录看看有没有数据和log有没有日志,有的话就恭喜你安装成功

[root@localhost mongdb_dome]# ./bin/mongo 127.0.0.1:27017/test
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017/test
MongoDB server version: 3.4.4
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:
2017-05-31T22:55:36.950+0800 I CONTROL  [initandlisten]
2017-05-31T22:55:36.950+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-05-31T22:55:36.950+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-05-31T22:55:36.950+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-05-31T22:55:36.950+0800 I CONTROL  [initandlisten]
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten]
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten]
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-05-31T22:55:36.951+0800 I CONTROL  [initandlisten]
>

有>就是链接成功

(退出mongdb)
> db.shutdownServer()
shutdown command only works with the admin database; try 'use admin'
> use admin
switched to db admin
> db.shutdownServer()
server should be down...
2017-05-31T23:24:14.939+0800 I NETWORK  [thread1] trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2017-05-31T23:24:14.940+0800 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-05-31T23:24:14.941+0800 I NETWORK  [thread1] reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
> (ctrl+c)

> ^C
bye
[root@localhost mongdb_dome]#

然后查看日志



[root@localhost mongdb_dome]# ./bin/mongod  -f  conf/mongdb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2621
child process started successfully, parent exiting
[root@localhost mongdb_dome]# ./bin/mongo 127.0.0.1:27017
MongoDB shell version v3.4.4
connecting to: 127.0.0.1:27017
MongoDB server version: 3.4.4
Server has startup warnings:
2017-05-31T23:37:00.741+0800 I CONTROL  [initandlisten]
2017-05-31T23:37:00.741+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-05-31T23:37:00.741+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-05-31T23:37:00.741+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-05-31T23:37:00.741+0800 I CONTROL  [initandlisten]
2017-05-31T23:37:00.742+0800 I CONTROL  [initandlisten]
2017-05-31T23:37:00.742+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-05-31T23:37:00.742+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-05-31T23:37:00.742+0800 I CONTROL  [initandlisten]
2017-05-31T23:37:00.743+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-05-31T23:37:00.743+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-05-31T23:37:00.743+0800 I CONTROL  [initandlisten]
> show dbs
admin  0.000GB
local  0.000GB



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

An_s

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值