I need to get databases from the old PostgreSQL folder that was in Program Files (win 10).
I tried changing the data path through the registry (ImagePath
value after "-D" at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\postgresql-x64-12) from the current to the old PostgreSQL data folder.
I also tried replacing files in the current folder from PostgreSQL with old ones (replaced data for C:\Program Files\PostgreSQL\12\data\base and C:\Program Files\PostgreSQL\12\data\global).
In both cases, an error occurred when trying to start the postgresql-x64-12 service. Error message: the postgresql-x64-12 service on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.
How can I get databases from old ../Program Files/PostgreSQL folder?
After replacing the folders C:\Program Files\PostgreSQL\12\data\base and C:\Program Files\PostgreSQL\12\data\global with the old ones and attempts to start the postgresql-x64-12 service, a log file appeared with the following content:
LOG: database system was shut down at ...
LOG: invalid primary checkpoint record
PANIC: could not locate a valid checkpoint record
LOG: startup process (PID 17452) was terminated by exception 0xC0000409
HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
LOG: aborting startup due to startup process failure
LOG: database system is shut down
Because of the message PANIC: could not locate a valid checkpoint record, I used pg_resetwal: in PowerShell I opened the folder C:\Program Files\PostgreSQL\12\bin, then ran the command .\pg_resetwal.exe -f -D "C:\Program Files\PostgreSQL\12\data. In some cases, it is worth using the command without -f, also for other versions of Postgres a different command may be needed. More information: https://stackoverflow.com/a/8812934/14145682.
After that, the service also did not start, and the following error was present in the log:
FATAL: could not access status of transaction
DETAIL: Could not read from file "pg_multixact/members/0000" at offset 8192: read too few bytes.
So, I replaced the files in the C:\Program Files\PostgreSQL\12\data\pg_multixact folder with the old ones.
After these steps, the postgresql-x64-12 service started without errors and it was possible to restore the old database.
Related
I am new to PostgreSQL and I am trying to set up a streaming replication from our server to a test DB on my laptop. I have been following this tutorial https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/ along with the Postgres documentation here https://www.postgresql.org/docs/11/runtime-config-replication.html.
I'm running Windows 10, PostgreSQL 11, PostGIS 2.5 extension.
The server and my local machine both keep shutting down and the logs are filled with postmaster.pid errors such as:
LOG: performing immediate shutdown because data directory lock file is invalid
LOG: received immediate shutdown request
LOG: could not open file "postmaster.pid": No such file or directory
WARNING: terminating connection because of crash of another server process
DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
Could anyone point me towards the issue here? I know my server's aren't configured properly but I just don't know what configurations need to be changed.
Here is an image of my standby server's most recent log.
standby log
Here is an image of my master server's most recent log.
master log
You must have messed up in many ways.
You removed or overwrote postmaster.pid on the master server.
That is very dangerous and causes the server to die with the error message you quote.
You didn't create recovery.conf before starting the standby server, or you removed backup_label. From the error messages I'd suspect the second, with ensuing data corruption.
We have a PostgreSQL 9.5 installed on the system and sometimes the postgres service can't be started. When I look into the pg_log I see the following messages:
2017-02-07 12:55:18 IST [4800]: [3-1] user=,db=,app=,client= LOG: configuration file "C:/Program Files/PostgreSQL/9.5/data/pg_hba.conf" contains no entries
2017-02-07 12:55:18 IST [4800]: [4-1] user=,db=,app=,client= FATAL: could not load pg_hba.conf
After looking into the pg_hba.conf file I can see that the whole file is corrupt. When I open the file in the Windows editor I can't see anything except spaces and when I open it in Notepad++ there are only "NUL" characters in the whole file.
To fix this we copied a fresh version of the file to its location and after that the service starts without any problem. But how can this happen and what can we do to avoid it.
I apologize for the long post. I have a Postgresql 9.3 server running on a Amazon linux AMI. I also have a compressed dump file from another server which I created using pg_dumpall. Now, I want to restore the data from this dump file in my Postgres. However, I want to load this data into a specific location (say /data).
I'm having a fresh installation of Postgres. So when I tried to do a:
sudo service postgresql93 start
I got an error message asking me to initialize the db. So I did a:
sudo service postgresql initdb
which created the required files in /var/lib/pgsql93/data. After that, I changed the 'data_directory' configuration in /var/lib/pgsql93/data/postgresql.conf and pointed it to /data (I had to do this as root user. I couldn't open the file as the default user).
Now when I try to do a
sudo service postgresql93 start
it fails to start, and when I check the /var/lib/pgsql93/pg_startup.log file, it says:
FATAL: "/data/postgresql" is not a valid data directory
DETAIL: File "/data/postgresql/PG_VERSION" is missing.
So I copied the files from the default (/var/lib/pgsql9.3/data) to /data, changed the permissions to 700 and owner to postgres.
However, when I try to start the service again, it still fails, and in the pgstartup.log, it only says:
LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
And when I check the log in /data/pg_log, it says:
LOG: database system was shut down at 2014-12-30 21:31:18 UTC
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
What else could be the problem? I haven't restored the data yet. I just have the files which were created by the initdb command.
#BMW http://www.linuxquestions.org/questions/linux-server-73/change-postgresql-data-directory-649911/ is exactly what I was looking for. Thanks.
I'm trying to install postgres 9.1 on an ubuntu 12.04 machine using puppet v3.4.3 and puppetlabs/postgresql module v3.3.0. I want the data_directory to point to a large disk I've mounted.
If I change the datadir property of postgresql::globals it doesn't seem to do anything. The postgres.conf file still has data_directory pointing to /var/lib/postgresql/9.1/main
Then I tried also using postgresql::server::config_entry to change the data_directory param in postgres.config but that gives the following error:
Debug: Executing 'service postgresql reload'
Notice: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]/returns: * Reloading PostgreSQL 9.1 database server
Notice: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]/returns: * pg_ctl: PID file "/data/PGDATA/postmaster.pid" does not exist
Notice: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]/returns: Is server running?
Notice: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]/returns: ...fail!
Error: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]: Failed to call refresh: service postgresql reload returned 1 instead of one of [0]
Error: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]: service postgresql reload returned 1 instead of one of [0]
I believe this fails because postgres was started before configuring the data_directory, and this parameter is part of the startup of the process so when you change the value it can no longer find the process to stop and start it. If I kill postgres and try to start it I get an error saying /data/PGDATA is not a valid directory, as the database was not created in the data_directory location I specified.
Finally I tried creating the user, group and file path, and then mounting the disk to /var/lib/postgresql/9.1/main all in puppet before puppet installs postgres, but I get this error:
Notice: /Stage[main]/Mm_postgres::Server/Postgresql::Server::Config_entry[checkpoint_segments]/Postgresql_conf[checkpoint_segments]/ensure: created
Error: Puppet::Util::FileType::FileTypeFlat could not write /etc/postgresql/9.1/main/postgresql.conf: No such file or directory - /etc/postgresql/9.1/main/postgresql.conf
Error: /Stage[main]/Mm_postgres::Server/Postgresql::Server::Config_entry[checkpoint_segments]/Postgresql_conf[checkpoint_segments]: Could not evaluate: Puppet::Util::FileType::FileTypeFlat could not write /etc/postgresql/9.1/main/postgresql.conf: No such file or directory - /etc/postgresql/9.1/main/postgresql.conf
I believe everything was done in the correct order, and permissions were fine, but I'll keep looking into this. Does anyone know if it is possible to install postgres via puppet on ubuntu and change the data_directory, and if so, how?
Thanks
Problem is that postgresql module from puppetlabs doesn't quite work with that kind of customization. I think there are even some bug reports out there. This is what I did, and it works without a problem:
file { '/data/postgresql':
ensure => directory,
}
file { '/var/lib/postgresql':
ensure => link,
target => '/data/postgresql',
before => Class['::postgresql::server::install'],
}
class { '::postgresql::globals':
}->class { '::postgresql::server':
}
Hope it helps!
PS. I used puppetlabs-postgresql version 3.3.3
Where are log file stored in DB2?
I am searching for a file with name Updatedb20100604182008.log
from this page:
http://www.ibm.com/developerworks/data/library/techarticle/0301kline/0301kline.html
(The article goes into further detail about default locations as well.)
The database logs are initially
created in a directory called
SQLOGDIR, a sub-directory of the
database directory. You can change the
location where active logs and future
archive logs are placed by changing
the value for this configuration
parameter to point to either a
different directory, or to a device.
Archive logs that are currently stored
in the database log path directory are
not moved to the new location if the
database is configured for
roll-forward recovery.
Because you can change the log path
location, the logs needed for
roll-forward recovery may exist in
different directories or on different
devices. You can change this
configuration parameter during the
roll-forward process to allow you to
access logs in multiple locations.
The change to the value of newlogpath
will not be applied until the database
is in a consistent state. An
informational database configuration
parameter, database_consistent,
indicates the status of the database.
Note: The database manager writes to
transaction logs one at a time. The
total size of transactions that can be
active is limited by the database
configuration parameters:
The DB2 log file location can be found from the DB CFG parameter - 'Path to log files'.
The command would be the below, without an explicit connection to the DB.
db2 get db cfg for db_name | grep 'Path to log files'
Else, you can connect to the DB first and use the command as follows:-
db2 connect to db_name
db2 get db cfg | grep 'Path to log files'
db2 terminate
db2 connect to database
db2 get db cfg | grep -i log
cd /data/dblogs/NODE0000(path to the log files)
cd LOGSTREAM0000(these is log folder)
ls -altr(we can see all the log files with .log extension)
rm abc.log (give the log name which you want to delete)