二进制安装MongoDB
下载mongodb
官网下载地址:
也可以wget
安装,如下
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.22.tgz
tar xf mongodb-linux-x86_64-4.0.22.tgz
mv mongodb-linux-x86_64-4.0.22 /usr/local/mongodb
创建数据与日志存放目录
mkdir /usr/local/mongodb/data
mkdir /usr/local/mongodb/logs
环境变量设置
echo 'export PATH=$PATH:/usr/local/mongodb/bin' >>/etc/profile
source /etc/profile
#测试
[root@localhost mongodb]# mongo -version
MongoDB shell version v4.0.22
git version: 1741806fb46c161a1d42870f6e98f5100d196315
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
创建配置文件mongodb.conf
#数据文件存放目录
dbpath=/usr/local/mongodb/data
#日志文件存放目录
logpath=/usr/local/mongodb/logs/mongodb.log
# pid文件
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
#端口
port=27017
#监听ip
bind_ip=0.0.0.0
#以守护程序的方式启用,即在后台运行
fork=true
directoryperdb=true
#开启认证
auth=true
wiredTigerCacheSizeGB=1
---------------------------------------------------------------------
cat > /usr/local/mongodb/mongodb.conf<<EOF
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/logs/mongodb.log
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
port=27017
bind_ip=0.0.0.0
fork=true
directoryperdb=true
auth=true
wiredTigerCacheSizeGB=1
EOF
启动
[root@localhost mongodb]# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4115
child process started successfully, parent exiting
#查看
[root@localhost mongodb]# ps -ef|grep mongodb
root 4115 1 1 21:20 ? 00:00:03 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
root 4147 4055 0 21:25 pts/1 00:00:00 grep --color=auto mongodb
登录测试
[root@localhost mongodb]# mongo -port 27017
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1713229c-9fef-4c19-96bd-eb13a62ccbe6") }
MongoDB server version: 4.0.22
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
>
mkdir /usr/local/mongodb/data
mkdir /usr/local/mongodb/logs
echo 'export PATH=$PATH:/usr/local/mongodb/bin' >>/etc/profile
source /etc/profile
#测试
[root@localhost mongodb]# mongo -version
MongoDB shell version v4.0.22
git version: 1741806fb46c161a1d42870f6e98f5100d196315
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
创建配置文件mongodb.conf
#数据文件存放目录
dbpath=/usr/local/mongodb/data
#日志文件存放目录
logpath=/usr/local/mongodb/logs/mongodb.log
# pid文件
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
#端口
port=27017
#监听ip
bind_ip=0.0.0.0
#以守护程序的方式启用,即在后台运行
fork=true
directoryperdb=true
#开启认证
auth=true
wiredTigerCacheSizeGB=1
---------------------------------------------------------------------
cat > /usr/local/mongodb/mongodb.conf<<EOF
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/logs/mongodb.log
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
port=27017
bind_ip=0.0.0.0
fork=true
directoryperdb=true
auth=true
wiredTigerCacheSizeGB=1
EOF
启动
[root@localhost mongodb]# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4115
child process started successfully, parent exiting
#查看
[root@localhost mongodb]# ps -ef|grep mongodb
root 4115 1 1 21:20 ? 00:00:03 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
root 4147 4055 0 21:25 pts/1 00:00:00 grep --color=auto mongodb
登录测试
[root@localhost mongodb]# mongo -port 27017
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1713229c-9fef-4c19-96bd-eb13a62ccbe6") }
MongoDB server version: 4.0.22
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
>
#数据文件存放目录
dbpath=/usr/local/mongodb/data
#日志文件存放目录
logpath=/usr/local/mongodb/logs/mongodb.log
# pid文件
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
#端口
port=27017
#监听ip
bind_ip=0.0.0.0
#以守护程序的方式启用,即在后台运行
fork=true
directoryperdb=true
#开启认证
auth=true
wiredTigerCacheSizeGB=1
---------------------------------------------------------------------
cat > /usr/local/mongodb/mongodb.conf<<EOF
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/logs/mongodb.log
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
port=27017
bind_ip=0.0.0.0
fork=true
directoryperdb=true
auth=true
wiredTigerCacheSizeGB=1
EOF
[root@localhost mongodb]# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4115
child process started successfully, parent exiting
#查看
[root@localhost mongodb]# ps -ef|grep mongodb
root 4115 1 1 21:20 ? 00:00:03 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
root 4147 4055 0 21:25 pts/1 00:00:00 grep --color=auto mongodb
登录测试
[root@localhost mongodb]# mongo -port 27017
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1713229c-9fef-4c19-96bd-eb13a62ccbe6") }
MongoDB server version: 4.0.22
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
>
[root@localhost mongodb]# mongo -port 27017
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1713229c-9fef-4c19-96bd-eb13a62ccbe6") }
MongoDB server version: 4.0.22
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
>
Comments | NOTHING