阅读模式:

centos7.3安装mongodb3.6

查看:9712  回复:0  类型:  来源:php自学网  标签 linux centos 运维 nosql mongodb

        centos7.3安装mongodb3.6并设置开机启动和守护进程的运行。

一、mongodb安装包下载

        官网下载地址:https://www.mongodb.com/download-center#community,打开页面选择linux栏目和对应的包下载,如图:

mongodb下载界面.png

二、解压安装包,复制到对应目录中

#下载安装包
wget -c https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.0.tgz
#下载完后进行解压包
tag -xzvf mongodb-linux-x86_64-rhel70-3.6.0.tgz
#创建mogodb目录
mkdir /usr/local/mongodb
#复制安装包到mongodb目录中
mv mongodb-linux-x86_64-rhel70-3.6.0 /usr/local/mongodb
cd /usr/local/mongodb

三、守护进程启动mongodb

    启动方式和参数:./mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/data/log/logs.log --logappend --fork

#/usr/local/mongodb/创建数据库目录和日志目录
mkdir data
#进入data目录
cd data
#创建两个文件夹
mkdir db
mkdir log
cd log
#建立日志文件
touch logs.log

#进入/usr/local/mongodb/bin/目录中启动mongodb

[root@localhost bin]# ./mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/data/log/logs.log --logappend --fork
#运行结果
about to fork child process, waiting until server is ready for connections.
forked process: 1874
child process started successfully, parent exiting

四、使用客户端进行mongodb数据库的操作

    启动方式(/usr/local/mongodb/bin/目录):./mongo

[root@localhost bin]# ./mongo
MongoDB shell version v3.6.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.0
Server has startup warnings: 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-12-08T16:00:38.798+0800 I CONTROL  [initandlisten] 
>
#查看数据库
> show databases;
admin   0.000GB
config  0.000GB
local   0.000GB
#选择数据库
> use admin
switched to db admin
#查看数据表
> show tables;
system.users
system.version

        mongodb3.6开机启动脚本设置:http://zixuephp.net/article-374.html

分享到:
0 0

发布评论:


登录:
  表情:
提交