-
Notifications
You must be signed in to change notification settings - Fork 59
Setup PostgreSQL on Arch Linux
Install the postgresql
package:
$ sudo pacman -S postgresql
Create a new database cluster:
$ sudo -u postgres -i initdb --locale $LANG -E UTF8 -D /var/lib/postgres/data
Start and enable postgresql.service
:
$ sudo systemctl start postgresql.service
$ sudo systemctl enable postgresql.service
Switch to the postgres
user:
$ sudo -u postgres -i
Create user octoprint
:
[postgres]$ createuser --interactive -P
Enter name of role to add: octoprint
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
Create database octoprint_filamentmanager
:
[postgres]$ createdb -O octoprint octoprint_filamentmanager
Per default PostgreSQL only accepts connections from localhost
. To make the database server available in your network you have to modify two config files.
In the /var/lib/postgres/data/postgresql.conf
change the line with listen_addresses
to
listen_addresses = '*'
Then append the following line to /var/lib/postgres/data/pg_hba.conf
host octoprint_filamentmanager octoprint 192.168.178.0/24 md5
Adapt the IP address to your network, e.g. if your server has the IP 192.168.0.25
use 192.168.0.0/24
instead. This allows all clients in your network to access the database. For more information see https://en.wikipedia.org/wiki/Subnetwork
The final step is to restart the PostgreSQL service:
$ sudo systemctl restart postgresql.service
In order to use PostgreSQL with the FilamentManager you need to manually install the psycopg2
package as an additional dependency to your virtualenv. If you followed the guide from the OctoPrint wiki your virtualenv is located under ~/OctoPrint/venv
, otherwise modify the path accordingly.
$ ~/OctoPrint/venv/bin/pip install psycopg2
If you ran into issues ensure postgresql-libs
is installed.
$ sudo pacman -S postgresql-libs
After restarting your OctoPrint instance you can now configure the PostgreSQL settings. You can find them in the plugin settings dialog under the Database
tab. Enter your user credentials, database name, etc. like shown below.
Finally you can test your connection by clicking Test connection
. If the button turns green everything is OK and ready to go. Restart OctoPrint again and you are done.