Set up an external PostgreSQL server
Splunk SOAR (On-premises) uses a PostgreSQL 15.3 database. In many installations, the database runs on the same server as Splunk SOAR (On-premises). It is possible to put the database on its own server. For more information about configuring and operating a PostgreSQL database, consult the PostgreSQL website and their documentation.
Support for PostgreSQL 15
Splunk SOAR (On-premises) release 6.1.1 added support for external PostgreSQL 15.X databases. Splunk SOAR (On-premises) release 6.2.0 upgrades the internal PostgreSQL database to 15.3 for all deployments.
To configure an external PostgreSQL 15.X database, follow the directions in this topic.
For information on upgrading PostgreSQL see Upgrading a PostgreSQL Cluster on postgresql.org.
Install and configure PostgreSQL
- Install one of the operating systems supported by PostgreSQL 15. PostgreSQL 15.3 or higher is recommended, but you may use any release of PostgreSQL 15.x. Configure the operating system according to your organization's requirements. See Supported Platforms on PostgreSQL.org.
- Update the kernel semaphore parameters and refresh the system configuration.
echo "kernel.sem=250 32000 32 5000" >> /etc/sysctl.conf sysctl --system
- Configure your firewall to allow access. For a complete list of ports, see Splunk SOAR (On-premises) required ports.
- Add any additional yum repositories that you need. Use the tool on the Linux downloads (Red Hat family) page to identify the correct repository for your architecture and operating system combination.
yum install <URL>
- Install the PostgreSQL server.
yum install postgresql15-server-15.3
- Initialize the PostgreSQL database.
/usr/pgsql-15/bin/postgresql-15-setup initdb
- Set PostgreSQL to start when the system starts.
systemctl enable postgresql-15
- Start the PostgreSQL database.
systemctl start postgresql-15
- Change to the postgres user.
su - postgres
- Change to the PostgreSQL data directory.
cd /var/lib/pgsql/15
- Generate the SSL certificate PostgreSQL uses.
openssl req -new -x509 -days 3650 -nodes -text -out server.crt -keyout server.key -subj "/CN=postgres.cluster1"
Note: You can use an SSL certificate purchased from a Certificate Authority instead of generating a self-signed certificate. - Set the permissions on the server.key file.
chmod og-rwx server.key
- Run a PostgreSQL shell as the
postgres
user.Note: You should already be the postgres user.psql
- Set the postgres user password, if it has not already been set.
ALTER USER postgres PASSWORD '<postgrespassword>';
- Create the pgbouncer user.
CREATE USER pgbouncer PASSWORD '<pgbouncerpassword>';
- Set PostgreSQL to use SSL. Provide the keys and cipher level.
ALTER SYSTEM SET ssl = on; ALTER SYSTEM SET ssl_cert_file = '/var/lib/pgsql/15/server.crt'; ALTER SYSTEM SET ssl_key_file = '/var/lib/pgsql/15/server.key'; ALTER SYSTEM SET ssl_ciphers = 'HIGH:+3DES:!aNULL';
- Exit the PostgreSQL shell by typing CTRL+D.
- Change back to the
root
user.exit
- Edit the
pg_hba.conf
file to enable access to the database. Splunk SOAR (On-premises) must be able to connect as both thepostgres
andpgbouncer
users. In each entry, supply the IP range that will be used by your Splunk SOAR (On-premises) install or cluster.# TYPE DATABASE USER ADDRESS METHOD local all all peer hostssl all postgres <IP Range>/<XX> md5 hostssl phantom pgbouncer <IP Range>/<XX> md5
- Edit
postgresql.conf
. Set values formax_connections
,work_mem
,shared_buffers
, andlisten_address
.max_connections=2500 work_mem=2796kB shared_buffers=2GB listen_addresses = '*' # what IP address(es) to listen on;
Note: Several factors can influence the amount of memory dedicated to thework_mem
setting. Larger, high event volume deployments will want significantly more, while smaller, lower volume deployments may use slightly less. The setting above assumes a medium sized deployment with a moderate event volume.For
listen_address
set a value that matches your security requirements. Valid settings are:*
for all addresses, 0.0.0. for all IPv4 addresses::
for all IPv6 addresses- specific addresses you supply.
- Restart the PostgreSQL service.
systemctl restart postgresql-15
Backup a Splunk SOAR (On-premises) database and restore to an external database
To backup a Splunk SOAR (On-premises) database and restore it on an external database, use the ibackup.pyc tool. See Splunk SOAR (On-premises) backup and restore overview in Administer Splunk SOAR (On-premises).
Create an external PostgreSQL database in AWS RDS
Some Splunk SOAR (On-premises) deployments, especially those in Amazon Web Services, may want to put the PostgreSQL database on its own host using AWS's Relational Database Service (RDS). These steps can also be used to migrate a standalone Splunk SOAR (On-premises) instance to an instance using a PostgreSQL database hosted in AWS' RDS.
For more information on building a PostgreSQL database host in RDS, see the Amazon Relational Database Service documentation.
For information on upgrading a PostgreSQL database in RDS see Upgrading the PostgreSQL DB engine for Amazon RDS in the AWS documentation.
Checklist
Number | Task | Description |
---|---|---|
1 | Create a PostgreSQL database in AWS. | Create the external PostgreSQL database with the Relational Database System |
2 | Create the pgbouncer user account. | Create the pgbouncer user for the RDS |
3 | Back up the Splunk SOAR (On-premises) instance's PostgreSQL database, then restore it to the AWS RDS instance. | Backup a Splunk SOAR (On-premises) database and restore to an external database |
Create the external PostgreSQL database with the Relational Database System (RDS)
Splunk SOAR (On-premises) uses a PostgreSQL 15.3 database. In many installations, the database runs on the same server as Splunk SOAR (On-premises). If you opt to run the PostgreSQL database on its own Amazon Web Services RDS instance, follow the procedures here. These instructions assume you already have an AWS account and VPCs established for your organization's resources.
- From your EC2 dashboard, click Services in the menu bar, and under Database choose RDS.
- Click Create database.
- Select Standard Create.
- Under Engine options, select PostgreSQL.
- For Version, select 15.3 from the menu.
- For Templates, select either Production for production environments or Dev/Test for development/testing or Proof of Value environments.
- Under Settings, type a name for your DB instance identifier. Make sure that the name is unique across all DB instances owned by your AWS account.
- Under Credential Settings:
- Master username: postgres
- Make sure the Auto generate a password checkbox is not selected.
- Type and confirm the Master password in the fields provided. Record this password. You will need it later.
- Under DB instance size, select the radio button that matches your organization's needs. CAUTION: Warning: Instances below db.t2.large may deplete their available connections before installation of Splunk SOAR (On-premises) is complete.
- Under Storage, select a Storage type based on your organization's needs.
- For Allocated storage, set a number of GiB that matches your organization's needs. CAUTION: Databases with less than 500 gigabytes of storage are not supported for production use.
- Select the Enable storage autoscaling check box.
- Set Maximum storage threshold to 1000 (GiB).
- For Allocated storage, set a number of GiB that matches your organization's needs.
- Under Availability & durability, select the Do not create a standby instance radio button.
- Under Connectivity, select the same VPC as you used for your Splunk SOAR (On-premises) instance.
- Under the Additional connectivity configuration section:
- Select the correct Subnet group. The available groups depend on your VPC selection.
- Under Publicly accessible, select the No radio button.
- Under VPC security group, select Choose existing.
- Select the appropriate security group from the menu.
- Click the X icon to remove any unwanted security groups that were added by default.
- Make sure the Database port is set to 5432.
- Under Additional configuration, Database options:
- Type phantom for Initial database name.
- Make sure the DB parameter group is set to default.postgres15.3.
- Under Additional configuration, Backup, leave everything at the defaults.
- Click Create Database.
Create the pgbouncer user for the RDS
Splunk SOAR (On-premises) interacts with the PostgreSQL database using the pgbouncer user account. This account needs to be created for the database you built in RDS.
- SSH to the operating system of your Splunk SOAR (On-premises) instance and use the user Splunk SOAR (On-premises) was installed with. For privileged installs, this will be the root user.
- Create the pgbouncer user.
psql --host <DNS name for RDS instance> --port 5432 --username postgres --echo-all --dbname phantom --command "CREATE ROLE pgbouncer WITH PASSWORD '<pgbouncer password>' login;"
- Make the pgbouncer user a superuser.
psql --host <DNS name for RDS instance> --port 5432 --username postgres --echo-all --dbname phantom --command "GRANT rds_superuser TO pgbouncer;"
Backup the external PostgreSQL database with the Relational Database System (RDS)
To backup an external PostgreSQL database with the RDS, you can perform the following steps as the unprivileged user.
- Backup the database.
cd <PHANTOM_HOME>/bin phenv python backup.pyc --all
- Copy the file path that shows the backup file that was created to use in a future step.
All data backed up to <PHANTOM_HOME>/data/phantom_backups/phantom_backup_2017-07-15-20-47-04.126913.tgz
- Edit the
<PHANTOM_HOME>/etc/pgbouncer/pgbouncer.database.ini
file as shown in the following code.host
is the IP address or DNS name of the database server.[databases] phantom = user=pgbouncer password=<pgbouncerpassword> host=<pg server> postgres = user=postgres password=<postgrespassword> host=<pg server> [pgbouncer] server_tls_sslmode = require
Note: Amazon Web Services RDS PostgreSQL databases do not need theserver_tls_sslmode = require
entry. - Stop all Splunk SOAR (On-premises) services.
<PHANTOM_HOME>/bin/stop_phantom.sh
- Reload pgbouncer. For all deployments, use the following command:
<PHANTOM_HOME>/bin/phsvc restart pgbouncer
- Test the connection to the database server.
<PHANTOM_HOME>/bin/phenv psql -h /tmp -p 6432 -d postgres
If connectivity is successful, you will see the following message:
To exit from psql, usepsql (15.3) Type "help" for help. postgres=#
\q
. - Initialize the database to use with Splunk SOAR (On-premises).
cd <PHANTOM_HOME>/bin phenv prepare_db --db-exist-ok
- Start all Splunk SOAR (On-premises) services.
<PHANTOM_HOME>/bin/start_phantom.sh
- Restore the backup using the file name you copied in step 2.
cd <PHANTOM_HOME>/bin phenv python restore.pyc --file <PHANTOM_HOME>/data/phantom_backups/phantom_backup_2017-07-15-20-47-04.126913.tgz
- Connect to the Splunk SOAR (On-premises) server's web user interface.
Change the IP address of the PostgreSQL database
You may need to change the IP address of your PostgreSQL database. If so, follow these steps.
- Edit the
<PHANTOM_HOME>/etc/pgbouncer/pgbouncer.database.ini
file as shown in the following code.host
is the IP address or DNS name of the database server.[databases] phantom = user=pgbouncer password=<pgbouncerpassword> host=<pg server> postgres = user=postgres password=<postgrespassword> host=<pg server> [pgbouncer] server_tls_sslmode = require
Note: Amazon Web Services RDS PostgreSQL databases do not need theserver_tls_sslmode = require
entry. - Stop all Splunk SOAR (On-premises) services.
<PHANTOM_HOME>/bin/stop_phantom.sh
- Reload pgbouncer. For all deployments, use the following command:
<PHANTOM_HOME>/bin/phsvc restart pgbouncer
- Test the connection to the database server.
<PHANTOM_HOME>/bin/phenv psql -h /tmp -p 6432 -d postgres
If connectivity is successful, you will see the following message:
To exit from psql, usepsql (15.3) Type "help" for help. postgres=#
\q
. - Start all Splunk SOAR (On-premises) services.
<PHANTOM_HOME>/bin/start_phantom.sh