关于.postgresql的信息

PostgreSQL服务器启动及关闭方法

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

10余年的井研网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整井研建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“井研网站设计”,“井研网站推广”以来,每个客户项目都认真落实执行。

[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如何导入数据

用我写的软件可以用excel导入到postgresql,你上网找fitreport就行了。

或者这样做:

可以写语句或采用以下的方法

网上转录下来的方法:

步骤:

1.将excel表格字段,按照postgresql

数据库中表的字段顺序来整理数据,并保存为csv文件。

2.用记事本打开csv文件,另存为utf-8格式。

3.使用pgadmin客户端链接postgresql数据库,执行如下脚本,导入csv文件到postgresql数据表:

copy

testdata

from

'd:/test/testdata.csv'

delimiter

as','

csv

quote

as

'"'

注:testdata

是postgresql数据库表的名称。

注意事项:

1.test目录需要赋予postgres

用户可读写的权限,否则会有如下报错信息:

error:

could

not

open

file

"d:/testdata2.csv"

forwriting:

permission

denied

2.csv文件要为utf-8格式,否则导入时可能会有报错:

error:

invalid

bytesequence

for

encoding

"utf8":

0xcdf5

3.注意windows环境下文件路径的表述方式,如:d:/test/data.csv

postgreSQL的简单介绍?

postgreSQL是一款先进的开源数据库,拥有非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),可面向企业复杂SQL的OLTP业务场景,支持多项企业级功能,能解决使用数据库的各种难题。

PostgreSQL的优势有很多。它是一个免费的对象-关系数据库服务器(ORDBMS),在灵活的BSD许可证下发行。

postgreSQL的特征

函数:通过函数,可以在数据库服务器端执行指令程序。

索引:用户可以自定义索引方法,或使用内置的 B 树,哈希表与 GiST 索引。

触发器:触发器是由SQL语句查询所触发的事件。如:一个INSERT语句可能触发一个检查数据完整性的触发器。触发器通常由INSERT或UPDATE语句触发。 多版本并发控制:PostgreSQL使用多版本并发控制(MVCC,Multiversion concurrency control)系统进行并发控制,该系统向每个用户提供了一个数据库的"快照",用户在事务内所作的每个修改,对于其他的用户都不可见,直到该事务成功提交。

规则:规则(RULE)允许一个查询能被重写,通常用来实现对视图(VIEW)的操作,如插入(INSERT)、更新(UPDATE)、删除(DELETE)。

数据类型:包括文本、任意精度的数值数组、JSON 数据、枚举类型、XML 数据等。全文检索:通过 Tsearch2 或 OpenFTS,8.3版本中内嵌 Tsearch2。

NoSQL:JSON,JSONB,XML,HStore 原生支持,至 NoSQL 数据库的外部数据包装器。

数据仓库:能平滑迁移至同属postgreSQL生态的GreenPlum,DeepGreen,HAWK 等,使用 FDW 进行 ETL。


新闻名称:关于.postgresql的信息
转载来源:http://lszwz.com/article/dscjdie.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款