PostgreSQL 安裝完成後的一些配置

來源:互聯網
上載者:User

標籤:sage   命令   statement   blank   stp   資料庫服務   tar   target   技術分享   


設定資料目錄,一般使用環境變數 PGDATA 指向資料目錄的根目錄。
目錄的初始化是使用 initdb 來完成的,-D 後面加上自訂目錄的路徑
initdb -D /tmp/testpostgres2/data
完成後在設定的目錄下就會產生一些設定檔。

配置日誌:
PostgreSQL有3種日誌,分別是pg_log(資料庫作業記錄)、pg_xlog(WAL 日誌,即重做日誌)、pg_clog(事務提交日誌,記錄的是事務的中繼資料)

pg_log預設是關閉的,需要設定參數啟用此日誌。
編輯 postgresql.conf


log_statement = ‘all‘
logging_collector = onlog_directory = ‘pg_log‘log_filename = ‘postgresql-%Y-%m-%d_%H%M%S.log‘log_rotation_age = 1dlog_rotation_size = 100MBlog_min_messages = info# 記錄執行慢的SQLlog_min_duration_statement = 60log_checkpoints = onlog_connections = onlog_disconnections = onlog_duration = onlog_line_prefix = ‘%m‘# 監控資料庫中長時間的鎖log_lock_waits = on# 記錄DDL操作log_statement = ‘ddl‘

儲存後重啟PostgreSQL即可在$PGDATA/pg_log/ 下看到新產生的日誌

pg_ctl stop -m fastpg_ctl start
或者使用如下命令
pg_ctl restart
讓資料庫執行個體重新讀取設定檔的命令如下:
pg_ctl reload [-s] [-D datadir]
啟動資料庫服務
pg_ctl -D PGDATA start
具體參數的詳細解釋查看官方文檔:
http://www.postgres.cn/docs/9.4/runtime-config-logging.html
 

PostgreSQL 安裝完成後的一些配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.