MongoDB stepped pit Record

Start MongoDB:

mongod --config mongod.cfg --auth --fork

--auth 开启身份认证

--fork 后台启动服务

connection:mongo

set password:

use admin
db.createUser({user: "root", pwd: "123456", roles:["root"]})
db.auth("root","123456")

Centos Firewall settings

Ali cloud server firewall settings invalid. . .

Need to modify the security group configuration, it can be accessed remotely.

/ *************** The following settings for Ali cloud server is invalid, Ali cloud server needs to modify the security group configuration *************** /

netstat -ano|grep 27017View 27017 whether to allow remote access

First, list all ports

netstat -ntlp

View already open ports:

firewall-cmd --list-ports

Open port

firewall-cmd --zone=public --add-port=80/tcp --permanent
–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

Second, set up a firewall

重启防火墙
firewall-cmd --reload

Start firewall

systemctl start firewalld

Disable the firewall

systemctl stop firewalld

Set boot

systemctl enable firewalld

Stop and disable the boot

sytemctl disable firewalld

View Status

systemctl status firewalld或者 firewall-cmd --state

View version

firewall-cmd --version

View information specified interface belongs

firewall-cmd --get-zone-of-interface=eth0

The interface to the area (the default interface in public)

firewall-cmd --zone=public --add-interface=eth0(永久生效再加上 --permanent 然后reload防火墙)

Set the default interface area

firewall-cmd --set-default-zone=public(立即生效,无需重启)

Updated firewall rules

firewall-cmd --reload或firewall-cmd --complete-reload(两者的区别就是第一个无需断开连接,就是firewalld特性之一动态
添加规则,第二个需要断开连接,类似重启服务)

View all open ports designated area

firewall-cmd --zone=public --list-ports

Open ports in the designated area (remember to restart firewall)

firewall-cmd --zone=public --add-port=80/tcp(永久生效再加上 --permanent)

Guess you like

Origin www.cnblogs.com/cherishSmile/p/11828772.html