Set the data directory, generally use the environment variable PGDATA to point to the root directory of the data directory.
The initialization of the directory is done using initdb, followed by -D with the path to the custom directory.
Initdb -D /tmp/testpostgres2/data
After completion, some configuration files will be generated in the set directory.
Configuration log:
PostgreSQL has three kinds of logs, namely pg_log (database running log), pg_xlog (WAL log, redo log), pg_clog (transaction commit log, which records transaction metadata)
Pg_log is turned off by default, you need to set the parameters to enable this log.
Edit postgresql.conf
Log_statement = ‘all‘
Logging_collector = on
Log_directory = ‘pg_log‘
Log_filename = ‘postgresql-%Y-%m-%d_%H%M%S.log‘
Log_rotation_age = 1d
Log_rotation_size = 100MB
Log_min_messages = info
# Record execution slow SQL
Log_min_duration_statement = 60
Log_checkpoints = on
Log_connections = on
Log_disconnections = on
Log_duration = on
Log_line_prefix = ‘%m‘
# Monitor long locks in the database
Log_lock_waits = on
# Record DDL operations
Log_statement = ‘ddl‘
Restart PostgreSQL after saving to see the newly generated log under $pgdata/pg_log/
Pg_ctl stop-m fastpg_ctl start
or use the following command
Pg_ctl restart
The command to re-read the configuration file for the DB instance is as follows:
Pg_ctl Reload [-S] [-D DataDir]
Start the database service
pg_ctl-d PGDATA Start
Detailed explanation of the specific parameters View the official documentation:
http://www.postgres.cn/docs/9.4/runtime-config-logging.html
Some configurations after PostgreSQL installation is complete