Skip to content

Increase PostgreSQL Database storage

kuanfandevops edited this page Oct 10, 2017 · 24 revisions

The current configuration

The 1G storage is currectly mounted to /var/lib/pgsql/data in postgresql pod. This is where the PostgreSQL database is located.

Storage:

postgresql:  Bound to volume app-pv-152-1g	1 GiB  

Postgresql deployment configuration:

    spec:
	template:
		spec:
		  volumes:
			- name: postgresql-data
			  persistentVolumeClaim:
				claimName: postgresql
	containers:
		  volumeMounts:
			- name: postgresql-data
			  mountPath: /var/lib/pgsql/data				

Increase database storage

Step1: send out notifications to end users if necessary

Step2: backup current database
Use oc command to login OpenShift
Switch to project moe-gwells-
Run command 'oc get pods' to get all pods and find the active PostgreSQL pod, it should be named like postgresql-42-t01rv
Run command 'oc rsync :/var/lib/pgsql/data . This command should copy everything under /var/lib/pgsql/data to local directory
Run command 'oc rsh ' to rsh to the pod and verify if the data has been all copied to load directory, especially the hidden files if there are any.

Step3: create a new 5GiB storage named as postgresql2

postgresql2:  Bound to volume <new storage name>	5GiB			  

Step4: update postgresql deployment configuration to mount current storage claim to postgresql-data-old and mount the new storage claim to postgresql-data:

    spec:
	template:
		spec:
		  volumes:
			- name: postgresql-data
			  persistentVolumeClaim:
				claimName: postgresql2
			- name: postgresql-data-old
			  persistentVolumeClaim:
				claimName: postgresql
	containers:
		  volumeMounts:
			- name: postgresql-data
			  mountPath: /var/lib/pgsql/data				
			- name: postgresql-data-old
			  mountPath: /var/lib/pgsql/data-old

Step5: verify if a new deployment for postgresql has happened, manually trigger one if not. After the new pod gets created, the both data and data-old folders should be found under /var/lib/pgsql directory.

Step6: find the new pod, the login to it and copy everything under /var/lib/pgsql/data-old to /var/lib/pgsql/data

Step7: update postgresql deployment configuration to remove postgresql-data-old:

    spec:
	template:
		spec:
		  volumes:
			- name: postgresql-data
			  persistentVolumeClaim:
				claimName: postgresql2
	containers:
		  volumeMounts:
			- name: postgresql-data
			  mountPath: /var/lib/pgsql/data				

Step8: verify if a new deployment for postgresql has happened, manually trigger one if not

Step9: verify if application works properly

Backout Plan

As the 1G storage postgresql still stays, in case of any failure, just need to restore to the original configuration which can refer to the section on the top. Remember to run the redeployment after all the the configuration is restored.

Further consideration

A site maintenance page may need to be displayed before we run the storage increase process.

Clone this wiki locally