展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

linux安装mongodb

查看详情
  • onemake配置网路
# 配置网卡
cd /etc/sysconfig/network-scripts/
vi ifcfg-ens33
# 修改为如下
BOOTPROTO=static  
ONBOOT=yes
IPADDR=192.168.128.100   
NETMASK=255.255.255.0   
GATEWAY=192.168.128.2  
DNS1=8.8.8.8
# 重启生效
service network restart
# 查看ip
ip a
# 测试外网
ping www.baidu.com
  • 将mongodb-linux-x86_64-rhel70-4.0.4.tgz上传到服务器
# 解压
cd /home/software
tar -zxvf mongodb-linux-x86_64-rhel70-4.0.4.tgz

# 重命名
mv mongodb-linux-x86_64-rhel70-4.0.4 mongodb

# 新建目录
cd mongodb
mkdir datas
mkdir logs

# 配置
cd bin
vim mongodb.conf
# 配置如下
dbpath=/home/software/mongodb/datas
logpath=/home/software/mongodb/logs/mongodb.log
logappend=true
port=27017
fork= false
auth=true
bind_ip=0.0.0.0

# 启动
nohup ./mongod --logappend --config mongodb.conf &

# 进入下面目录  
cd /home/software/mongodb/bin
# 执行
./mongo
# 执行下面语句创建用户
use admin
db.createUser(
    { 
      user: "root",
      pwd: "root", 
      roles: [ { role: "root", db: "admin" } ]
    }
  )
查看详情
[root@node1 bin]# nohup ./mongod --logappend --config mongodb.conf &
[1] 4702
[root@node1 bin]# nohup: ignoring input and appending output to ‘nohup.out’

[root@node1 bin]# ./mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("bebc07d1-6a64-4b45-85c4-dd697f34c064") }
MongoDB server version: 4.0.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
> use admin
switched to db admin
> db.createUser(
...     { 
...       user: "root",
...       pwd: "root", 
...       roles: [ { role: "root", db: "admin" } ]
...     }
...   )
Successfully added user: {
	"user" : "root",
	"roles" : [
		{
			"role" : "root",
			"db" : "admin"
		}
	]
}
  • 连接
  • DataGrip -> Data Source -> MongoDB
posted @ 2024-01-10 17:16  DogLeftover  阅读(35)  评论(0编辑  收藏  举报