Create the databases before Deploy the agents. The place of this page in the guide is Getting started.
Install PostgreSQL:
apt install postgresql
Provide access for external agent connections by making changes to the configuration file pg_hba.conf, for example:
# IPv4 local connections:
host all all 10.1.1.1/32 md5
Create a database, user password to connect the Mikiri WAF agents:
API
su - postgres -c "psql -c \"CREATE DATABASE api;\""
su - postgres -c "psql -c \"CREATE ROLE api PASSWORD 'YOUR_PASSWORD';\""
su - postgres -c "psql -c \"ALTER DATABASE api OWNER TO api;\""
su - postgres -c "psql -c \"ALTER ROLE api WITH LOGIN;\""
su - postgres -c "psql api -c \"GRANT ALL ON ALL TABLES IN SCHEMA public TO api;\""
su - postgres -c "psql api -c \"GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO api;\""
su - postgres -c "psql api -c \"GRANT CREATE ON SCHEMA public TO api;\""
WMC
su - postgres -c "psql -c \"CREATE DATABASE wmc;\""
su - postgres -c "psql -c \"CREATE ROLE wmc PASSWORD 'YOUR_PASSWORD';\""
su - postgres -c "psql -c \"ALTER DATABASE wmc OWNER TO wmc;\""
su - postgres -c "psql -c \"ALTER ROLE wmc WITH LOGIN;\""
su - postgres -c "psql wmc -c \"GRANT ALL ON ALL TABLES IN SCHEMA public TO wmc;\""
su - postgres -c "psql wmc -c \"GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO wmc;\""
su - postgres -c "psql wmc -c \"GRANT CREATE ON SCHEMA public TO wmc;\""
YOUR_PASSWORD is a placeholder. Replace it, then reload PostgreSQL: systemctl reload postgresql.
Replace 10.1.1.1 with the address of the server that runs API and WMC. When those agents run on this same server, the existing 127.0.0.1 line is enough and the extra host line is not required.
Configure the SELinux policy or deactivate it with the command:
setenforce 0
then bring the file /etc/selinux/config to the form:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Install and configure PostgreSQL:
dnf update
dnf install postgresql-devel postgresql-server
postgresql-setup initdb
sed -i "s|host all all 127.0.0.1/32 ident|host all all 127.0.0.1/32 md5|" /var/lib/pgsql/data/pg_hba.conf
sed -i "s|host all all ::1/128 ident|host all all ::1/128 md5|" /var/lib/pgsql/data/pg_hba.conf
systemctl start postgresql
systemctl enable postgresql
Grant access to external agent connections by making changes to the configuration file pg_hba.conf, for example:
# IPv4 local connections:
host all all 10.1.1.1/32 md5
Create a database, user password to connect the Mikiri WAF agents:
API
su - postgres -c "psql -c \"CREATE DATABASE api;\""
su - postgres -c "psql -c \"CREATE ROLE api PASSWORD 'YOUR_PASSWORD';\""
su - postgres -c "psql -c \"ALTER DATABASE api OWNER TO api;\""
su - postgres -c "psql -c \"ALTER ROLE api WITH LOGIN;\""
su - postgres -c "psql api -c \"GRANT ALL ON ALL TABLES IN SCHEMA public TO api;\""
su - postgres -c "psql api -c \"GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO api;\""
su - postgres -c "psql api -c \"GRANT CREATE ON SCHEMA public TO api;\""
WMC
su - postgres -c "psql -c \"CREATE DATABASE wmc;\""
su - postgres -c "psql -c \"CREATE ROLE wmc PASSWORD 'YOUR_PASSWORD';\""
su - postgres -c "psql -c \"ALTER DATABASE wmc OWNER TO wmc;\""
su - postgres -c "psql -c \"ALTER ROLE wmc WITH LOGIN;\""
su - postgres -c "psql wmc -c \"GRANT ALL ON ALL TABLES IN SCHEMA public TO wmc;\""
su - postgres -c "psql wmc -c \"GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO wmc;\""
su - postgres -c "psql wmc -c \"GRANT CREATE ON SCHEMA public TO wmc;\""
YOUR_PASSWORD is a placeholder. Replace it, then reload PostgreSQL: systemctl reload postgresql.
Replace 10.1.1.1 with the address of the server that runs API and WMC. When those agents run on this same server, the existing 127.0.0.1 line is enough and the extra host line is not required.
Information about using the database in a Docker container is available in Deploying the PostgreSQL Docker container.