![]() Once we confirm that the data folder has been changed on PostgreSQL, we will now delete the old data with the below command. To verify the current data location settings on the server – postgres=# SHOW data_directory Once the service is restarted we will now verify the data folder location. Sep 12 16:57:39 ubuntu-16 systemd: Started PostgreSQL RDBMS. Sep 12 16:57:32 ubuntu-16 systemd: Started PostgreSQL RDBMS. Sep 12 16:57:32 ubuntu-16 systemd: Starting PostgreSQL RDBMS. Main PID: 22296 (code=exited, status=0/SUCCESS) Process: 22296 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Loaded: loaded (/lib/systemd/system/rvice enabled vendor presĪctive: active (exited) since Mon 16:57:32 IST 12s ago Once the servies gets, restarted we will now check the status of the PostgreSQL services with the below command – $ sudo systemctl status postgresql Restarting the PostgreSQL Server and Verify the Data folder LocationĪs we have to update the PostgreSQL configuration, we will restart the PostgreSQL services so that the configuration is applied. Once the new data folder is updated in the /etc/postgresql/9.5/main/nf we needed to restart the server. Ident_file = '/etc/postgresql/9.5/main/pg_nf' # ident configuration file Hba_file = '/etc/postgresql/9.5/main/pg_hba.conf' # host-based authentication file # option or PGDATA environment variable, represented here as ConfigDirĭata_directory = '/mnt/data_vol/postgresql/9.5/main' # use data in another directory # The default values of these variables are driven from the -D command-line We can change the default data folder by editing the /etc/postgresql/9.5/main/nf file and edit the data_directory. $ sudo mv /var/lib/postgresql/9.5/main /var/lib/postgresql_backup Changing the Data folder Location on Postgresql Configuration Files Once the database is copied we will rename the old data folder and we will keep this folder till we confirm the changes in later steps so that we cannot lose the data from the machine. Postgresql/9.5/main/pg_xlog/archive_status/ Postgresql/9.5/main/global/pg_filenode.map $ sudo rsync -av /var/lib/postgresql /mnt/data_vol/ Using rsync, we will create a new postgresql folder at new location here the new location means new mounted volume with data_vol at /mnt/data_vol and the permissions are retained with PostgreSQL so that we cannot get any permission issues while copying the files to the new location.īelow is the command to copy the data. Moving the Existing PostgreSQL data to the New LocationĪs we stopped the data we will now move the existing PostgreSQL data to the new location with rysnc command with -a and –v flags, -a preserves the files and folder permission at the new location and –v will display the verbose output. Sep 12 15:20:23 ubuntu-16 systemd: Stopped PostgreSQL RDBMS. Sep 07 19:27:27 ubuntu-16 systemd: Started PostgreSQL RDBMS. Sep 07 19:27:27 ubuntu-16 systemd: Starting PostgreSQL RDBMS. Main PID: 1553 (code=exited, status=0/SUCCESS) Process: 1553 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Loaded: loaded (/lib/systemd/system/rvice enabled vendor preseĪctive: inactive (dead) since Mon 15:40:23 IST 3s ago Once we stop the PostgreSQL we will check the status of the PostgreSQL services with the below command $ sudo systemctl status postgresql Now, we will stop the PostgreSQL service to change the default location for the data folderīelow is the command to stop the PostgreSQL services. With the above command, we will come to know that the default data directory location is /var/lib/postgresql/9.5/main To verify the current data location settings on the server postgres=# SHOW data_directory Below is the command to verify the current data location settings on the server. A new volume or location where we want to move the database data location, the new location will be /mnt/data_vol/PostgreSQL as the data_vol is the new volume attached to the machine or server.Ĭhanging the PostgreSQL Data Folder Locationīefore we change the location of the PostgreSQL data location, we will first check the current settings on the PostgreSQL Server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |