centos系统安装mongdb

centos系统安装mongdb_第1张图片

centos系统安装mongdb_第2张图片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文件)

centos系统安装mongdb_第3张图片


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

mkdir mongdb_dome (建好了之后进去)

cd mongdb_dome

centos系统安装mongdb_第4张图片

进来之后你需要新建 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



你可能感兴趣的:(技术(mysql))