技术开发 频道

行式数据库PostgreSQL 9.04版本评测

  initdb命令提示由于字符集冲突,或者不指定字符集,或者使用匹配的字符集。我们设定LANG环境变量为C,即英语,重新运行initdb命令,这次字符集验证通过,但缺少创建目录的权限,使用root用户改变目录的属主,接下来就顺利执行了。

-bash-3.2$ export LANG=C
-bash-3.2$ ./initdb --encoding=utf8 -D /user1/postgresql/data
The files belonging to this database system will be owned by user "postgres".
This
user must also own the server process.

The
database cluster will be initialized with locale C.
The
default text search configuration will be set to "english".

creating directory
/user1/postgresql/data ... initdb: could not create directory "/user1/postgresql": Permission denied
-bash-3.2$ su -
Password:
[root@redflag11012501 ~]# mkdir /user1/postgresql
[root@redflag11012501 ~]# chown postgres:dba /user1/postgresql
[root@redflag11012501 ~]# exit
logout

-bash-3.2$ ./initdb --encoding=utf8 -D /user1/postgresql/data
The files belonging to this database system will be owned by user "postgres".
This
user must also own the server process.

The
database cluster will be initialized with locale C.
The
default text search configuration will be set to "english".

creating directory
/user1/postgresql/data ... ok
creating subdirectories ... ok
selecting
default max_connections ... 100
selecting
default shared_buffers ... 32MB
creating configuration files ... ok
creating template1
database in /user1/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects
' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    ./postgres -D /user1/postgresql/data
or
    ./pg_ctl -D /user1/postgresql/data -l logfile start

  数据库初始化后,才可以启动postgresql数据库服务器的后台服务,注意postgresql和pg_ctl命令也需要指定路径。接下来创建我们测试用的数据库pgdb。用psql命令测试数据库创建成功,执行默认的不带路径的psql调用的是旧版软件,系统给出警告信息,一些\开始的命令不能正确运行,如果用带路径的psql,则不会出现警告。

-bash-3.2$ ./postgres -D /user1/postgresql/data &
[1] 27388
-bash-3.2$ LOG:  database system was shut down at 2011-04-24 12:57:09 CST
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

-bash-3.2$ createdb pgdb
CREATE DATABASE
-bash-3.2$ psql pgdb
Welcome
to psql 8.1.18 (server 9.0.4), the PostgreSQL interactive terminal.

Type:  \copyright
for distribution terms
       \h
for help with SQL commands
       \?
for help with psql commands
       \g
or terminate with semicolon to execute query
       \q
to quit

WARNING:  You are connected
to a server with major version 9.0,
but your psql client
is major version 8.1.  Some backslash commands,
such
as \d, might not work properly.


-bash-3.2$ ./psql pgdb
psql (
9.0.4)
Type "help"
for help.

  至此,安装过程结束。

0