This section describes how to create a PostgreSQL resource. The PostgreSQL resource provides the functionality to protect PostgreSQL database instances on LifeKeeper nodes.
System Configuration
The environment created in this guide is a two-node configuration as shown below.
Install PostgreSQL ARK in advance.
The environment in this guide is PostgreSQL
- PostgreSQL 9.2.24 is used in this guide.
- Create a PostgreSQL data directory in the file system on the shared storage.
- The PostgreSQL database admin user should use the “postgres” created when the database is initialized.
- Protect a PostgreSQL resource instance with an active/standby configuration.
*Make sure that your system does not fall under any of file system restrictions. See (LifeKeeper Core – Known Issues / Restrictions) for details.
Perform the following steps on target1 and target2
- Installing PostgreSQL
After installing, disable the autostart of the PostgreSQL service as follows:
# systemctl disable postgresql.service
Perform the following steps on target1
- Mounting the file system
Mount the file system in which the data directory will be created, refer to Step 1 in Creating file system resources.
- Creating a data directory
Create a PostgreSQL data directory on the shared disk.
[target1]# mkdir -p /mnt/fs/pgsql/data [target1]# chown -R postgres:postgres /mnt/fs/pgsql
Change the following path described in the /usr/lib/systemd/system/postgresql.service file to the data directory on the shared disk.
Environment=PGDATA=/mnt/fs/pgsql/data
- Database initialization
Execute the following command to initialize the database.
The database is created under the data directory.
[target1]# postgresql-setup initdb
- Starting the PostgreSQL service
Execute the following command to start the PostgreSQL service.
[target1]# systemctl start postgresql.service
- Creating a resource
Execute the following command:
[target1]# lkcli resource create pgsql --tag pgsql-tag --datadir /mnt/fs/pgsql/data --port 5432 --socket /tmp/.s.PGSQL.5432 --dbuser postgres --logfile /tmp/pgsql-5432.lk.log
Resource Settings
Item | Input Value |
---|---|
--tag | Tag name |
--datadir | Absolute path of the directory that contains the PostgreSQL database data |
--port | Port number used by PostgreSQL |
--socket | Path of the socket used by PostgreSQL |
--dbuser | PostgreSQL database administrator user name |
--logfile | Absolute path to the pg_ctl log file used to start and stop PostgreSQL |
- Extending the resource
Execute the following command:
[target1]# lkcli resource extend pgsql --tag pgsql-tag --dest target2
Resource Settings
Item | Input Value |
---|---|
--tag | Tag name of the created resource |
--dest | Backup node name |
- Checking the resource
After creating and extending the resource, run the following command.
The resource information is displayed.
[target1]# lkcli status -q LOCAL TAG ID STATE PRIO PRIMARY target1 pgsql-tag target1.pgsql-5432 ISP 1 target1 target1 /mnt/fs /mnt/fs ISP 1 target1 target1 device17885 36000c292eb0c693b2efb44ed56556636-1 ISP 1 target1 target1 disk17816 36000c292eb0c693b2efb44ed56556636 ISP 1 target1
When a PostgreSQL resource is created, a file system resource is automatically created as shown above.
Post your comment on this topic.