I'm using DBeaver to connect the postgres db and want to access the logs via DBeaver.
I run the command below to find log destination and got stderr as the location.
show log_destination ;
How can I reach that file on DB app? FYI, I want all logs, not the logs that are from DBeaver.
On recent PostgreSQL versions, that is simple:
SELECT pg_current_logfile();
For old versions, proceed as follows:
Verify that the logging collector is started:
SHOW logging_collector;
If not, the location of the log depends on how PostgreSQL was started.
If yes, the log will be in log_directory:
SHOW log_directory;
If that is a relative path, it is relative to the PostgreSQL data directory.
Since the log file is on the database server, you probably won't be able to access it with a client tool.
https://tableplus.com/blog/2018/10/how-to-show-queries-log-in-postgresql.html#:~:text=The%20location%20of%20the%20log,pgsql%2Fdata%2Fpg_log%2F%20.
In Ubuntu is under /var/log/postgresql
You can run pg_lsclusters.
> pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
11 main 5432 online postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
Related
I have installed postgres 9.5 in my linux(16.04) machine.I have started service using below command.
sudo service postgresql start
This will start postgres service as a postgres user.
But I want to run postgres a different user(myown user).
How can I do .Please help !!.
You have to recursively change the ownership of the database directory to the new user.
If the WAL directory or tablespaces are outside the data directory, you have to change their ownership too.
Then you will have to configure the startup script so that it starts PostgreSQL as the new user. Watch out: if you installed the startup script with an installation package, any changes to it will probably be lost after an update.
I recommend that you don't do all that and continue running PostgreSQL as postgres.
Ok, so I have a client who has a postgresql database. He sent me the files (they look like this: http://prntscr.com/fbyz2l).
I have PGAdmin 4 on my windows 10 box. I also have postgres installed locally.
I have the database name and login information... but I can't figure out how to connect to the database.
I am guessing it is pretty simple, but I am having a tough time googling the right thing to get some help.
Update
I am still hunting this, but my feeling is the files are not the right format to import or bring onto my localhost. I am asking for a backup file that PGAdmin can make. If anyone has input on this, I am all ears.
Update 2
So I copied all the files to C:\Program Files\PostgreSQL\data\pg96\base
Restarted the server. When I do a
psql -h "C:\Program Files\PostgreSQL\data\pg96\base" -l
I get this:
http://prntscr.com/fbzxf2
I can connect to template1 and postgres, but neither of them is my database (184429). Ugh...
Thanks!
These files are basically copy of the postgres DB . You need to restore it on your machine .
You can find default path of postgres DB on C:\Program Files\PostgreSQL\some version\data location . Place the root of these files within that directory and restart your postgres service .
After that you can find new database in your PGAdmin .
I'm new to Postgres so can't seem to change the logging setting.
At the moment it logs ALL queries that are executed by any application. The app writes millions of queries a day so the log files get too big. I only need it to log any errors.
How can I change that in Postgres? I've installed it using Homebrew on Mac OS X.
You need to configure in postgresql.conf(data/postgresql.conf) file
change the setting in log_statement = 'all' to get the desired value which is available in When To Log
see this SO question for more info.
#jacob You can restart the postgresql service by sudo /etc/init.d/postgresql restart or sudo service postgresql restart.
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 have a database file (*.db) that need to be recovered.
The bad is, the end-user have null idea of the version of the database. Not know the password. The original developer is lost. The computer where was installed was formatted. We have not experience in this database software. Yeah, nightmare.
My guess is a old database. I'm trying to open it in Sybase 11, dev edition.
I follow this steps: http://dcx.sybase.com/1101en/sachanges_en11/unloading-reloading-upgrading-newjasper.html
I try to use the UNLOAD utility from command line & from the Sybase central utility. From command line I do:
./dbinfo -c "DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB;UID=DBA;PWD=sql"
SQL Anywhere Information Utility Version 11.0.1.2045
Unable to start specified database: '/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB' was created by a different version of the software
Ok, I try to unload:
./dbunload -c "DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB;UID=DBA;PWD=sql" -n /Users/mamcx/Desktop/
SQL Anywhere Unload Utility Version 11.0.1.2045
Connecting and initializing
***** SQL error: Unable to start database server
Ok, from the server admin tool:
dbunload -v -c "UID=dba;PWD=***;DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB" -an "/Users/mamcx/Desktop/baba.db" -ap 4096 -ea None -ii -sa -so _sc866192545
Connecting and initializing
***** SQL error: Unable to start database server
An error occurred while attempting to unload the database '/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB'.
Exist a way to know the version of the database server used to create this? Is possible to recover this file?
I don't know how to get the version out of the Database File if you are not able to start it.
You could get a hint from the hopefully existing Client PC's. Check the ODBC Driver Version they have installed.
I had good success with the support of Sybase. If you or your client has a support contract you can get them involved.
HTH
Try to simply start a server with that database and capture the output with -z -o server.out. The server.out file should contain a more specific error telling you why it can't start the database. This error can occur if you are trying to start something that is not a SQL Anywhere database.
You may also want to post this question over at http://sqlanywhere-forum.sap.com/.