Skip to content

Commit e31cf98

Browse files
committed
add mongodb section to README
1 parent b6e69ef commit e31cf98

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,45 @@ Ollama allows you to run open-source large language models and keep privacy. Set
4646
curl -fsSL https://ollama.com/install.sh | sh
4747
ollama run llama3
4848
```
49+
50+
### MongoDB Authentication
51+
To set up authentication, follow these steps:
52+
```
53+
mongosh
54+
55+
use admin
56+
db.createUser({
57+
user: "mongodb-index-advisor",
58+
pwd: passwordPrompt(),
59+
roles: [ { role: "clusterMonitor", db: "admin" } ]
60+
})
61+
62+
docker run --rm -it --net host andriik/mongodb-index-advisor -aiProvider ollama -dbName rto -mongoURI "mongodb://mongodb-profiler-exporter:<password>@127.0.0.1:27017/admin?authSource=admin&readPreference=primaryPreferred"
63+
```
64+
65+
### Enable MongoDB Profiler
66+
There are two ways to enable profiler in mongodb:
67+
#### Per Dababase
68+
```
69+
use db_name
70+
db.getProfilingStatus()
71+
db.setProfilingLevel(1, { slowms: 100 })
72+
```
73+
74+
#### Globally in mongod.conf
75+
```yaml
76+
operationProfiling:
77+
mode: slowOp
78+
slowOpThresholdMs: 50
79+
```
80+
81+
### Increase system.profile size
82+
The default size of the `system.profile` collection is set to 1MB, which can be insufficient for certain scenarios. To address this limitation, you can adjust the size of the collection by recreating it. Note that this process should not be replicated to replicas.
83+
84+
Below are example commands that can be used to increase the size of the system.profile collection:
85+
```js
86+
db.setProfilingLevel(0) // Disable profiling temporarily
87+
db.system.profile.drop() // Drop the existing system.profile collection
88+
db.createCollection( "system.profile", { capped: true, size: 1024 * 1024 * 50 } ) // 50Mb
89+
db.setProfilingLevel(1, { slowms: 100 }) // Enable profiling again
90+
```

0 commit comments

Comments
 (0)