欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

postgresql錯(cuò)誤日志收集的方法-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!

企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對(duì)外擴(kuò)展宣傳的重要窗口,一個(gè)合格的網(wǎng)站不僅僅能為公司帶來巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺(tái),創(chuàng)新互聯(lián)面向各種領(lǐng)域:成都輕質(zhì)隔墻板成都網(wǎng)站設(shè)計(jì)營銷型網(wǎng)站解決方案、網(wǎng)站設(shè)計(jì)等建站排名服務(wù)。

小編給大家分享一下postgresql錯(cuò)誤日志收集的方法,相信大部分人都還不怎么了解,因此分享這邊文章給大家學(xué)習(xí),希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去學(xué)習(xí)方法吧!

PG安裝完成后默認(rèn)不會(huì)記錄日志,必須修改對(duì)應(yīng)的(${PGDATA}/postgresql.conf)配置才可以,這里只介紹常用的日志配置。

1、logging_collector = on/off  ----  是否將日志重定向至文件中,默認(rèn)是off(該配置修改后,需要重啟DB服務(wù)).

DB安裝完成,啟動(dòng)的服務(wù)進(jìn)程如下

[root@localhost ~]# ps -elf | grep postgres
S postgres  2385     1  0  80   0 - 66829 poll_s 12:41 ?        00:00:00 /opt/pg9.6/bin/postgres -D /mnt/pgdata
S postgres  2387  2385  0  80   0 - 66829 ep_pol 12:41 ?        00:00:00 postgres: checkpointer process        
S postgres  2388  2385  0  80   0 - 66829 ep_pol 12:41 ?        00:00:00 postgres: writer process              
S postgres  2389  2385  0  80   0 - 66870 ep_pol 12:41 ?        00:00:00 postgres: wal writer process          
S postgres  2390  2385  0  80   0 - 66952 ep_pol 12:41 ?        00:00:00 postgres: autovacuum launcher process   
S postgres  2391  2385  0  80   0 - 29643 ep_pol 12:41 ?        00:00:00 postgres: stats collector process

將此配置修改為on,并重啟DB服務(wù),DB啟動(dòng)過程中會(huì)提示將日志重定向${PGDATA}/pg_log中。

[root@localhost ~]# su -l postgres -c '/opt/pg9.6/bin/pg_ctl -D /mnt/pgdata start'server starting
LOG:  redirecting log output to logging collector process
HINT:  Future log output will appear in directory "pg_log".

 此時(shí)在運(yùn)行的進(jìn)程如下,與之前相比,多了一個(gè)logger進(jìn)程。

[root@localhost ~]# ps -elf | grep postgres
S postgres  2448     1  0  80   0 - 66830 poll_s 12:50 ?        00:00:00 /opt/pg9.6/bin/postgres -D /mnt/pgdata
S postgres  2449  2448  0  80   0 - 29645 ep_pol 12:50 ?        00:00:00 postgres: logger process              
S postgres  2451  2448  0  80   0 - 66830 ep_pol 12:50 ?        00:00:00 postgres: checkpointer process        
S postgres  2452  2448  0  80   0 - 66830 ep_pol 12:50 ?        00:00:00 postgres: writer process              
S postgres  2453  2448  0  80   0 - 66871 ep_pol 12:50 ?        00:00:00 postgres: wal writer process          
S postgres  2454  2448  0  80   0 - 66953 ep_pol 12:50 ?        00:00:00 postgres: autovacuum launcher process   
S postgres  2455  2448  0  80   0 - 29644 ep_pol 12:50 ?        00:00:00 postgres: stats collector process

以下配置修改不需要重啟服務(wù),只需重載配置

[root@localhost ~]# su -l postgres -c '/opt/pg9.6/bin/pg_ctl -D /mnt/pgdata reload'

2、log_directory = 'pg_log' ---- 日志文件目錄,默認(rèn)是PGDATA的相對(duì)路徑,即PGDATA的相對(duì)路徑,即{PGDATA}/pg_log,也可以改為絕對(duì)路徑

默認(rèn)為${PGDATA}/pg_log,即集群目錄下,但是日志文件可能會(huì)非常多,建議將日志重定向到其他目錄或分區(qū)。

將此配置修改為/var/log/pg_log下,必須先創(chuàng)建此目錄,并修改權(quán)限,如

[root@localhost ~]# mkdir -p /var/log/pg_log
[root@localhost ~]# chown postgres:postgres /var/log/pg_log/[root@localhost ~]# chmod 700 /var/log/pg_log/

重啟DB服務(wù)后,日志將重定向至/var/log/pg_log下

[root@localhost ~]# su -l postgres -c '/opt/pg9.6/bin/pg_ctl -D /mnt/pgdata start'
server starting
LOG:  redirecting log output to logging collector process
HINT:  Future log output will appear in directory "/var/log/pg_log".

[root@localhost ~]# ls /var/log/pg_log/
postgresql-2016-06-18_130611.log

3.log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' ---- 日志文件命名形式,使用默認(rèn)即可

4. log_rotation_age = 1d ----  單個(gè)日志文件的生存期,默認(rèn)1天,在日志文件大小沒有達(dá)到log_rotation_size時(shí),一天只生成一個(gè)日志文件

5. log_rotation_size = 10MB  ---- 單個(gè)日志文件的大小,如果時(shí)間沒有超過log_rotation_age,一個(gè)日志文件大只能到10M,否則將新生成一個(gè)日志文件。

6.log_truncate_on_rotation = off ---- 當(dāng)日志文件已存在時(shí),該配置如果為off,新生成的日志將在文件尾部追加,如果為on,則會(huì)覆蓋原來的日志。

7.log_lock_waits = off ---- 控制當(dāng)一個(gè)會(huì)話等待時(shí)間超過deadlock_timeout而被鎖時(shí)是否產(chǎn)生一個(gè)日志信息。在判斷一個(gè)鎖等待是否會(huì)影響性能時(shí)是有用的,缺省是off。

8.log_statement = 'none' # none, ddl, mod, all ---- 控制記錄哪些SQL語句。none不記錄,ddl記錄所有數(shù)據(jù)定義命令,比如CREATE,ALTER,和DROP 語句。mod記錄所有ddl語句,加上數(shù)據(jù)修改語句INSERT,UPDATE等,all記錄所有執(zhí)行的語句,將此配置設(shè)置為all可跟蹤整個(gè)數(shù)據(jù)庫執(zhí)行的SQL語句。

9.log_duration = off ---- 記錄每條SQL語句執(zhí)行完成消耗的時(shí)間,將此配置設(shè)置為on,用于統(tǒng)計(jì)哪些SQL語句耗時(shí)較長。

10.log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements and their durations, > 0 logs only statements running at least this number of milliseconds

-1表示不可用,0將記錄所有SQL語句和它們的耗時(shí),>0只記錄那些耗時(shí)超過(或等于)這個(gè)值(ms)的SQL語句。個(gè)人更喜歡使用該配置來跟蹤那些耗時(shí)較長,可能存在性能問題的SQL語句。雖然使用log_statement和log_duration也能夠統(tǒng)計(jì)SQL語句及耗時(shí),但是SQL語句和耗時(shí)統(tǒng)計(jì)結(jié)果可能相差很多行,或在不同的文件中,但是log_min_duration_statement會(huì)將SQL語句和耗時(shí)在同一行記錄,更方便閱讀。

11.log_connections = off ----是否記錄連接日志

12.log_disconnections = off ---- 是否記錄連接斷開日志

13.log_line_prefix = '%m %p %u %d %r ' ---- 日志輸出格式(%m,%p實(shí)際意義配置文件中有解釋),可根據(jù)自己需要設(shè)置(能夠記錄時(shí)間,用戶名稱,數(shù)據(jù)庫名稱,客戶端IP和端口,方便定位問題)

14.log_timezone = 'Asia/Shanghai' ---- 日志時(shí)區(qū),最好和服務(wù)器設(shè)置同一個(gè)時(shí)區(qū),方便問題定位

服務(wù)器時(shí)區(qū)設(shè)置

[root@localhost ~]# cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

以上是postgresql錯(cuò)誤日志收集的方法的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!

當(dāng)前名稱:postgresql錯(cuò)誤日志收集的方法-創(chuàng)新互聯(lián)
URL鏈接:http://www.chinadenli.net/article28/dgiojp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作軟件開發(fā)定制網(wǎng)站標(biāo)簽優(yōu)化全網(wǎng)營銷推廣網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)