mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-17 18:14:50 +00:00
doc[mongodb]: update mongodb doc
This commit is contained in:
1 parent
6cdd676c2d
commit
50828613b9
3 files changed
+29
-34
No files matched your search
@@ -1,11 +0,0 @@
|
|||||||
# Ⅰ. Windows 11 优化策略
|
|
||||||
|
|
||||||
- 设置 | 更新和安全 | 传递优化,这个会占用网络带宽,全部关闭
|
|
||||||
|
|
||||||
- 设置 | 系统 | 电源和睡眠 | 其它电源设置 | 选择电源按钮的功能,快速启动会占用大量C盘空间,关闭快速启动
|
|
||||||
|
|
||||||
- 设置 | 系统 | 远程桌面,远程桌面会启动端口,有隐私泄露风险,关闭设置
|
|
||||||
|
|
||||||
- 设置 | 隐私 | 常规,全部关闭,没有什么用的功能
|
|
||||||
|
|
||||||
- 设置 | 应用 | 应用和功能,将安装软件来源的任何位置,改为安装不是Microsoft Store提供的应用前向我发出警告,可以避免安装垃圾软件
|
|
||||||
@@ -33,8 +33,8 @@ rm -rf JDK的安装路径
|
|||||||
把JDK下载到/usr/local目录下,在/usr/local下新建文件夹java
|
把JDK下载到/usr/local目录下,在/usr/local下新建文件夹java
|
||||||
```
|
```
|
||||||
|
|
||||||
- tar -zxvf openjdk-11+28_linux-x64_bin.tar.gz -C /usr/local
|
- tar -zxvf openjdk-17.0.2_linux-x64_bin.tar.gz -C /usr/local
|
||||||
- rename jdk-11 java jdk-11
|
- mv jdk-17.0.2 java
|
||||||
|
|
||||||
- vim /etc/profile
|
- vim /etc/profile
|
||||||
|
|
||||||
@@ -56,17 +56,8 @@ export JAVA_HOME JRE_HOME PATH
|
|||||||
|
|
||||||
# 三、Linux内核参数设置
|
# 三、Linux内核参数设置
|
||||||
|
|
||||||
- 文件句柄设置
|
- vim /etc/sysctl.conf,然后执行sysctl -p使参数生效,永久生效
|
||||||
|
|
||||||
```
|
```
|
||||||
root身份编辑 vim /etc/security/limits.conf, * 表示所有用户
|
|
||||||
|
|
||||||
root soft nofile 1000000
|
|
||||||
root hard nofile 1000000
|
|
||||||
* soft nofile 1000000
|
|
||||||
* hard nofile 1000000
|
|
||||||
|
|
||||||
vim /etc/sysctl.conf,然后执行sysctl -p使参数生效,永久生效
|
|
||||||
|
|
||||||
# ******************* SYN状态的内核参数调优 *******************
|
# ******************* SYN状态的内核参数调优 *******************
|
||||||
# 新建连接如果无响应,内核要发送多少次SYN连接才放弃,默认值为5
|
# 新建连接如果无响应,内核要发送多少次SYN连接才放弃,默认值为5
|
||||||
|
|||||||
+26
-11
@@ -61,8 +61,8 @@ mongotop # 读写监控工具
|
|||||||
- 把MongoDB下载到/usr/local目录下,在/usr/local下新建文件夹MongoDB
|
- 把MongoDB下载到/usr/local目录下,在/usr/local下新建文件夹MongoDB
|
||||||
|
|
||||||
```
|
```
|
||||||
tar -zxvf mongodb-linux-x86_64-enterprise-rhel70-4.2.0.tgz -C /usr/local
|
tar -zxvf mongodb-linux-x86_64-ubuntu2204-6.0.6.tgz -C /usr/local
|
||||||
rename /usr/local/mongodb-linux-x86_64-enterprise-rhel70-4.2.0 mongodb /usr/local/mongodb-linux-x86_64-enterprise-rhel70-4.2.0
|
mv mongodb-linux-x86_64-ubuntu2204-6.0.6 mongodb
|
||||||
vim /usr/local/mongodb/mongodb.config # 创建自定义配置文件,解压的mongodb安装包没有默认的配置文件
|
vim /usr/local/mongodb/mongodb.config # 创建自定义配置文件,解压的mongodb安装包没有默认的配置文件
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ storage:
|
|||||||
# 生产环境需要设置ip:bind_ip=127.0.0.1,本机ip
|
# 生产环境需要设置ip:bind_ip=127.0.0.1,本机ip
|
||||||
net:
|
net:
|
||||||
bindIp: 0.0.0.0
|
bindIp: 0.0.0.0
|
||||||
port: 22400
|
port: 27017
|
||||||
maxIncomingConnections: 900
|
maxIncomingConnections: 900
|
||||||
processManagement:
|
processManagement:
|
||||||
fork: true
|
fork: true
|
||||||
@@ -138,7 +138,21 @@ mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open
|
|||||||
如果启动看到上面这个错误,则是缺少net-snmp安装包,yum install net-snmp
|
如果启动看到上面这个错误,则是缺少net-snmp安装包,yum install net-snmp
|
||||||
```
|
```
|
||||||
|
|
||||||
- mongo -port 22400 # 使用mongo客户端链接MongoDB
|
- mongosh -port 22400 # 使用mongo客户端链接MongoDB
|
||||||
|
```
|
||||||
|
dpkg -i mongodb-mongosh_1.10.1_amd64.deb
|
||||||
|
mongodb客户端命令行和服务器分开了,需要安装mongosh工具
|
||||||
|
```
|
||||||
|
|
||||||
|
- vim /etc/security/limits.conf 数据库需要大的文件句柄,保存并退出编辑器,重新启动机器使配置生效
|
||||||
|
```
|
||||||
|
* soft nofile 65536
|
||||||
|
* hard nofile 65536
|
||||||
|
root soft nofile 65536
|
||||||
|
root hard nofile 65536
|
||||||
|
|
||||||
|
# * 表示所有用户
|
||||||
|
```
|
||||||
|
|
||||||
### 2.关闭MongoDB服务
|
### 2.关闭MongoDB服务
|
||||||
|
|
||||||
@@ -159,7 +173,7 @@ db.shutdownServer()
|
|||||||
- 方式三:如果MongoDB注册为service,可以使用服务的命令关闭
|
- 方式三:如果MongoDB注册为service,可以使用服务的命令关闭
|
||||||
|
|
||||||
```
|
```
|
||||||
systemctl stop mongodb
|
systemctl stop mongod
|
||||||
```
|
```
|
||||||
|
|
||||||
- 修复未正常关闭MongoDB,导致无法启动
|
- 修复未正常关闭MongoDB,导致无法启动
|
||||||
@@ -172,8 +186,8 @@ systemctl stop mongodb
|
|||||||
|
|
||||||
### 3.将MongoDB设置为开机自动启动
|
### 3.将MongoDB设置为开机自动启动
|
||||||
|
|
||||||
- vim /usr/lib/systemd/system/mongodb.service,创建启动脚本,systemctl是最新的启动命令,避免用service
|
- vim /etc/systemd/system/mongod.service,创建启动脚本,systemctl是最新的启动命令,避免用service
|
||||||
- chmod 754 /usr/lib/systemd/system/mongodb.service,赋予启动脚本可执行的权限
|
- chmod 754 /etc/systemd/system/mongod.service,赋予启动脚本可执行的权限
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -185,6 +199,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
#定义Service的运行类型,一般是forking(后台运行)
|
#定义Service的运行类型,一般是forking(后台运行)
|
||||||
Type=forking
|
Type=forking
|
||||||
|
LimitNOFILE=65536
|
||||||
|
|
||||||
ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.config
|
ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.config
|
||||||
ExecReload=
|
ExecReload=
|
||||||
@@ -196,9 +211,9 @@ WantedBy=multi-user.target
|
|||||||
```
|
```
|
||||||
|
|
||||||
- systemctl daemon-reload,重新加载服务
|
- systemctl daemon-reload,重新加载服务
|
||||||
- systemctl enable mongodb,会有一行反馈
|
- systemctl enable mongod,会有一行反馈
|
||||||
- systemctl status mongodb,注意看 -> enabled; vendor preset: disabled)
|
- systemctl status mongod,注意看 -> enabled; vendor preset: disabled)
|
||||||
- systemctl start mongodb
|
- systemctl start mongod
|
||||||
|
|
||||||
### 4.安全和访问控制
|
### 4.安全和访问控制
|
||||||
|
|
||||||
@@ -236,7 +251,7 @@ db.revokeRolesFromUser( "test", [{ role: "readWrite", db: "reporting" }]) #
|
|||||||
```
|
```
|
||||||
|
|
||||||
- 添加完成后,在配置文件中取消注释,#authorization
|
- 添加完成后,在配置文件中取消注释,#authorization
|
||||||
- 再重启mongod服务:systemctl restart mongodb
|
- 再重启mongod服务:systemctl restart mongod
|
||||||
|
|
||||||
- 用户登录
|
- 用户登录
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user