Skip to content

Commit 957d81b

Browse files
authored
Create README.md
0 parents  commit 957d81b

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# OpenBMP Postgres
2+
The postgres container is a plain postgres/timescaleDB container with
3+
some modifications to support OpenBMP. Any postgres install will work as long as
4+
they have similar changes as shown in [Dockerfile](Dockerfile).
5+
6+
## Building
7+
See the [Dockerfile](Dockerfile) notes for build instructions.
8+
9+
## Running
10+
```
11+
docker run --rm -it -p 5432:5432 \
12+
-e POSTGRES_PASSWORD=openbmp \
13+
-e POSTGRES_USER=openbmp \
14+
-e POSTGRES_DB=openbmp \
15+
openbmp/postgres:<version>
16+
```
17+
18+
### Configuration/Environment Variables
19+
See both [Postgres](https://hub.docker.com/_/postgres) and
20+
[TimescaleDB](https://hub.docker.com/r/timescale/timescaledb) documentation for more
21+
information on how to configure/run the docker container.
22+
23+
### PostgreSQL Related
24+
25+
#### Postgres can be killed by the Linux OOM-Killer
26+
This is very bad as it causes Postgres to restart. This will happen because postgres uses a large shared buffer,
27+
which causes the OOM to believe it's using a lot of VM.
28+
29+
It is suggested to run the postgres server with the following Linux settings:
30+
31+
# Update runtime
32+
sysctl -w vm.vfs_cache_pressure=500
33+
sysctl -w vm.swappiness=10
34+
sysctl -w vm.min_free_kbytes=1000000
35+
sysctl -w vm.overcommit_memory=2
36+
sysctl -w vm.overcommit_ratio=95
37+
38+
# Update startup
39+
echo "vm.vfs_cache_pressure=500" >> /etc/sysctl.conf
40+
echo "vm.min_free_kbytes=1000000" >> /etc/sysctl.conf
41+
echo "vm.swappiness=10" >> /etc/sysctl.conf
42+
echo "vm.overcommit_memory=2" >> /etc/sysctl.conf
43+
echo "vm.overcommit_ratio=95" >> /etc/sysctl.conf
44+
45+
46+
See Postgres [hugepages](https://www.postgresql.org/docs/current/static/kernel-resources.html#LINUX-HUGE-PAGES) for
47+
details on how to enable and use hugepages. Some Linux distributions enable **transparent hugepages** which
48+
will prevent the ability to configure ```vm.nr_hugepages```. If you find that you cannot set ```vm.nr_hugepages```,
49+
then try the below:
50+
51+
echo never > /sys/kernel/mm/transparent_hugepage/enabled
52+
echo never > /sys/kernel/mm/transparent_hugepage/defrag
53+
sync && echo 3 > /proc/sys/vm/drop_caches
54+
55+
56+
#### Postgres Vacuum (reclaim disk space)
57+
Postgres reclaims deleted/updated records using the vacuum process. You can run this manually/cron via the
58+
```VACUUM``` command. **autovacuum** is used to do this periodically. Careful tuning of this
59+
is required. Checkout [autovacuum-tuning-basics](https://blog.2ndquadrant.com/autovacuum-tuning-basics/),
60+
[Routine Vacuuming](https://www.postgresql.org/docs/current/static/routine-vacuuming.html), and
61+
[VACUUM](https://www.postgresql.org/docs/current/static/sql-vacuum.html) for more details.
62+
63+
#### Create persistent postgres locations
64+
65+
*You should use fast SSD and/or ZFS.* Size of these locations/mount points are directly related to the
66+
number of NLRI's maintained and number of changes/updates per second.
67+
68+
> TODO: Will post numbers of how to determine the disk size needed. For now, if you have less
69+
> than 50,000,00 prefixes, then you can use 1TB. If you have more than that, you should consider
70+
> multiple disks. ZFS can make your life easier as you can easily add disks and it supports compression.
71+
72+
- **postgres/main** - This location will be used for the main postgres data
73+
files and tables.
74+
75+
> This really should be a mount point to a dedicated filesystem
76+
77+
```
78+
mkdir -p /var/openbmp/postgres/main
79+
chmod 7777 /var/openbmp/postgres/main
80+
```
81+
82+
- **postgres/ts** - This location will be used for the time series postgres tables
83+
84+
> This really should be a mount point to a dedicated filesystem
85+
86+
```
87+
mkdir -p /var/openbmp/postgres/ts
88+
chmod 7777 /var/openbmp/postgres/ts
89+
```

0 commit comments

Comments
 (0)