资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

postgresql14的简单介绍

PostgreSQL服务器启动及关闭方法

1. 启动数据库服务器(posgres用户):

目前创新互联公司已为上千的企业提供了网站建设、域名、虚拟空间、网站改版维护、企业网站设计、栖霞网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

[postgres@localhost bin]$ postgres -D /opt/postgresql/data/ /opt/postgresql/log/pg_server.log 21

[1] 4508

当然如果设置了环境变量

PGDATA=/opt/postgresql/data

export PGDATA

后,可使用pg_ctl工具进行启动:

[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]$

因为之前已经启动,所以打印“another server might be running”。此时,查看日志,有如下信息:

[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]$

当然,最简的.启动方式是:

[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

如果要在操作系统启动时就启动PG,可以在/etc/rc.d/rc.local 文件中加以下语句:

/opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data

2.关闭服务器

最简单方法:

[postgres@localhost ~]$ pg_ctl stop

waiting for server to shut down.... done

server stopped

与Oracle相同,在关闭时也可采用不同的模式,简介如下:

SIGTERM

不再允许新的连接,但是允许所有活跃的会话正常完成他们的工作,只有在所有会话都结束任务后才关闭。这是智能关闭。

SIGINT

不再允许新的连接,向所有活跃服务器发送 SIGTERM(让它们立刻退出),然后等待所有子进程退出并关闭数据库。这是快速关闭。

SIGQUIT

令 postgres 向所有子进程发送 SIGQUIT 并且立即退出(所有子进程也会立即退出),而不会妥善地关闭数据库系统。这是立即关闭。这样做会导致下次启动时的恢复(通过重放 WAL 日志)。我们推荐只在紧急的时候使用这个方法。

SIGKILL

此选项尽量不要使用,这样会阻止服务器清理共享内存和信号灯资源,那样的话你只能在启动服务器之前自己手工做这件事。另外,SIGKILL 直接把 postgres 杀掉,而不会等它把信号中继给它的子进程,因此我们还需要手工杀掉每个独立子进程。

使用方法举例:

[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 ~]$

最快速关闭方法:kill postgres 进程

[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启动后的进程,如下:

[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 ~]$

如何运行postgresql-9.4.14-1-linux-x64.run

打开终端软件,先用cd命令切换到postgresql-9.4.14-1-linux-x64.run这个文件所在的目录,然后执行chmod a+x postgresql-9.4.14-1-linux-x64.run命令给postgresql-9.4.14-1-linux-x64.run文件添加可执行权限,在Linux中,当一个文件有了可执行权限之后,这个文件才可以运行。接着运行postgresql-9.4.14-1-linux-x64.run这个文件,方式是在文件名前面加上./,./是一个英文点号和一个英文斜杠,表示在当前目录下运行文件,这个必须加上:

./postgresql-9.4.14-1-linux-x64.run

Postgresql中to_date()函数使用问题

时间: 2019-02-14

一、问题

错误 : 函数 to_date(timestamp without time zone, unknown) 不存在 Hint: 没有匹配指定名称和参数类型的函数. 您也许需要增加明确的类型转换.

原来的使用方式是:

二、解决方式:

方法一:

**方法二: **

14.带你轻松完整部署Zabbix 4.0(+Postgresql9.4)完整安装

  # 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端初始化设定及添加Agent啦

现在就动手----阿里云ECS

pg14什么时候出

2021年5月20日。Postgrespro是俄罗斯著名的数据库公司,旗下主要产品基于PostgreSQL。近期发布了一本新书PostgreSQL 14 Internals。postgresql 14 正式版,pg14在2021年5月20日正式发布。postgresql 14 增加了许多并行查询功能,还增加了使用FDW查询远程数据库时的并行执行功能。

postgresql根据已知的一个日期,查询数据库中这个日期所属的月份的所有数据

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

查看现在距1970-01-01 00:00:00 UTC 的秒数

david=# select extract(epoch from now());

date_part

------------------

1365755907.94474

(1 row)

david=# 3.5 把epoch 值转换回时间戳

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)

--取小时

skytf= select extract (hour from now());

date_part

-----------

14

(1 row)

--取分钟

skytf= select extract (minute from now());

date_part


分享名称:postgresql14的简单介绍
文章来源:http://cdkjz.cn/article/dscdjds.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220