1. 啟動(dòng)數(shù)據(jù)庫服務(wù)器(posgres用戶):
目前創(chuàng)新互聯(lián)公司已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站改版維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、棲霞網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
[postgres@localhost bin]$ postgres -D /opt/postgresql/data/ /opt/postgresql/log/pg_server.log 21
[1] 4508
當(dāng)然如果設(shè)置了環(huán)境變量
PGDATA=/opt/postgresql/data
export PGDATA
后,可使用pg_ctl工具進(jìn)行啟動(dòng):
[postgres@localhost log]$ pg_ctl start -l /opt/postgresql/log/pg_server.log
pg_ctl: another server might be running; trying to start server anyway
pg_ctl: could not start server
Examine the log output.
[postgres@localhost log]$
因?yàn)橹耙呀?jīng)啟動(dòng),所以打印“another server might be running”。此時(shí),查看日志,有如下信息:
[postgres@localhost log]$ cat pg_server.log
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 4491) running in data directory "/opt/postgresql/data"?
[postgres@localhost log]$
當(dāng)然,最簡的.啟動(dòng)方式是:
[postgres@localhost ~]$ pg_ctl start
server starting
[postgres@localhost ~]$ LOG: database system was shut down at 2011-07-09 13:58:00 CST
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
如果要在操作系統(tǒng)啟動(dòng)時(shí)就啟動(dòng)PG,可以在/etc/rc.d/rc.local 文件中加以下語句:
/opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data
2.關(guān)閉服務(wù)器
最簡單方法:
[postgres@localhost ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
與Oracle相同,在關(guān)閉時(shí)也可采用不同的模式,簡介如下:
SIGTERM
不再允許新的連接,但是允許所有活躍的會(huì)話正常完成他們的工作,只有在所有會(huì)話都結(jié)束任務(wù)后才關(guān)閉。這是智能關(guān)閉。
SIGINT
不再允許新的連接,向所有活躍服務(wù)器發(fā)送 SIGTERM(讓它們立刻退出),然后等待所有子進(jìn)程退出并關(guān)閉數(shù)據(jù)庫。這是快速關(guān)閉。
SIGQUIT
令 postgres 向所有子進(jìn)程發(fā)送 SIGQUIT 并且立即退出(所有子進(jìn)程也會(huì)立即退出),而不會(huì)妥善地關(guān)閉數(shù)據(jù)庫系統(tǒng)。這是立即關(guān)閉。這樣做會(huì)導(dǎo)致下次啟動(dòng)時(shí)的恢復(fù)(通過重放 WAL 日志)。我們推薦只在緊急的時(shí)候使用這個(gè)方法。
SIGKILL
此選項(xiàng)盡量不要使用,這樣會(huì)阻止服務(wù)器清理共享內(nèi)存和信號(hào)燈資源,那樣的話你只能在啟動(dòng)服務(wù)器之前自己手工做這件事。另外,SIGKILL 直接把 postgres 殺掉,而不會(huì)等它把信號(hào)中繼給它的子進(jìn)程,因此我們還需要手工殺掉每個(gè)獨(dú)立子進(jìn)程。
使用方法舉例:
[postgres@localhost ~]$ pg_ctl stop -o SIGTERM
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
waiting for server to shut down....LOG: shutting down
LOG: database system is shut down
done
server stopped
[postgres@localhost ~]$
最快速關(guān)閉方法:kill postgres 進(jìn)程
[postgres@localhost ~]$ kill -INT `head -1 /opt/postgresql/data/postmaster.pid`
[postgres@localhost ~]$ LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
附:postgre啟動(dòng)后的進(jìn)程,如下:
[postgres@localhost ~]$ ps -ef|grep post
root 4609 4543 0 13:57 pts/2 00:00:00 su - postgres
postgres 4610 4609 0 13:57 pts/2 00:00:00 -bash
postgres 4724 1 0 14:08 pts/2 00:00:00 /opt/postgresql/bin/postgres
postgres 4726 4724 0 14:08 ? 00:00:00 postgres: writer process
postgres 4727 4724 0 14:08 ? 00:00:00 postgres: wal writer process
postgres 4728 4724 0 14:08 ? 00:00:00 postgres: autovacuum launcher process
postgres 4729 4724 0 14:08 ? 00:00:00 postgres: stats collector process
postgres 4752 4610 0 14:11 pts/2 00:00:00 ps -ef
postgres 4753 4610 0 14:11 pts/2 00:00:00 grep post
[postgres@localhost ~]$
打開終端軟件,先用cd命令切換到postgresql-9.4.14-1-linux-x64.run這個(gè)文件所在的目錄,然后執(zhí)行chmod a+x postgresql-9.4.14-1-linux-x64.run命令給postgresql-9.4.14-1-linux-x64.run文件添加可執(zhí)行權(quán)限,在Linux中,當(dāng)一個(gè)文件有了可執(zhí)行權(quán)限之后,這個(gè)文件才可以運(yùn)行。接著運(yùn)行postgresql-9.4.14-1-linux-x64.run這個(gè)文件,方式是在文件名前面加上./,./是一個(gè)英文點(diǎn)號(hào)和一個(gè)英文斜杠,表示在當(dāng)前目錄下運(yùn)行文件,這個(gè)必須加上:
./postgresql-9.4.14-1-linux-x64.run
時(shí)間: 2019-02-14
一、問題
錯(cuò)誤 : 函數(shù) to_date(timestamp without time zone, unknown) 不存在 Hint: 沒有匹配指定名稱和參數(shù)類型的函數(shù). 您也許需要增加明確的類型轉(zhuǎn)換.
原來的使用方式是:
二、解決方式:
方法一:
**方法二: **
? # yum install
? ? # yum list postgres*
? ? # yum install postgresql94-server
? ? # su - postgres
? ? $ /usr/pgsql-9.4/bin/initdb -D /var/lib/pgsql/9.4/data
? ? # systemctl enable postgresql-9.4
? ? # systemctl start postgresql-9.4
? ? #su - postgres
? ? $createuser -W zabbix
? ? $createdb -U postgres -O zabbix -E UTF8 zabbix
? ? $psql
? ?#?cp -f? /var/lib/pgsql/9.4/data/pg_hba.conf? /var/lib/pgsql/9.4/data/pg_hba.conf.bk
? ?#vi /var/lib/pgsql/9.4/data/pg_hba.conf
? ?#service postgresql-9.4 restart
? ?#ps ax | grep postgres
? ?#psql -U zabbix -d zabbix -h 127.0.0.1 -p 5432
? ?#\q
? ?#exit
? ?# rpm -ivh
? ?# yum-config-manager --enable rhel-7-server-optional-rpms
? ?# yum install zabbix-server-pgsql zabbix-web-pgsql
? ?# yum install zabbix-agent
? ?# yum install zabbix-get
? ?# zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix? psql zabbix
? ?#cp -f /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bk
? ?#vi /etc/zabbix/zabbix_server.conf
? ?#systemctl enable zabbix-server.service
? ?#systemctl restart zabbix-server.service
? ?# yum install httpd php php-pgsql php-mbstring php-bcmath php-xml php-gd
? ?# yum install readline-devel zlib-devel
? ?# cp /etc/php.ini? /etc/php.ini.org
? ?# vi /etc/php.ini
? ?# cd? /var/www/html/
? ?# ln -s /usr/share/zabbix .
? ?# systemctl enable httpd.service'.
? ?# systemctl status httpd
? ?# cp -f /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.org
? ?# vi /etc/zabbix/zabbix_agentd.conf
? ?# systemctl enable zabbix-agent.service
? ?# systemctl start zabbix-agent.service
接下來就是登錄Web端初始化設(shè)定及添加Agent啦
現(xiàn)在就動(dòng)手----阿里云ECS
2021年5月20日。Postgrespro是俄羅斯著名的數(shù)據(jù)庫公司,旗下主要產(chǎn)品基于PostgreSQL。近期發(fā)布了一本新書PostgreSQL 14 Internals。postgresql 14 正式版,pg14在2021年5月20日正式發(fā)布。postgresql 14 增加了許多并行查詢功能,還增加了使用FDW查詢遠(yuǎn)程數(shù)據(jù)庫時(shí)的并行執(zhí)行功能。
david=# select extract(year from now());
date_part
-----------
2013
(1 row)
david=# 3.2 取月份
david=# select extract(month from now());
date_part
-----------
4
(1 row)
david=#
david=# select extract(day from timestamp '2013-04-13');
date_part
-----------
13
(1 row)
david=#
david=# SELECT EXTRACT(DAY FROM INTERVAL '40 days 1 minute');
date_part
-----------
40
(1 row)
david=# 3.3 查看今天是一年中的第幾天
david=# select extract(doy from now());
date_part
-----------
102
(1 row)
david=# 3.4
查看現(xiàn)在距1970-01-01 00:00:00 UTC 的秒數(shù)
david=# select extract(epoch from now());
date_part
------------------
1365755907.94474
(1 row)
david=# 3.5 把epoch 值轉(zhuǎn)換回時(shí)間戳
david=# SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 1369755555 * INTERVAL '1 second';
?column?
------------------------
2013-05-28 23:39:15+08
(1 row)
david=#
--取day
skytf= select extract(day from now());
date_part
-----------
3
(1 row)
skytf= select extract(day from timestamp '2011-06-03');
date_part
-----------
3
(1 row)
skytf= select timestamp '2011-06-03';
timestamp
---------------------
2011-06-03 00:00:00
(1 row)
--取小時(shí)
skytf= select extract (hour from now());
date_part
-----------
14
(1 row)
--取分鐘
skytf= select extract (minute from now());
date_part