Postgres 9.1 DEB

前端之家收集整理的这篇文章主要介绍了Postgres 9.1 DEB前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Postgres 9.1 DEB

From OpenSCG Wiki

OpenSCG provides Postgresql 9.1 DEB packages for an easy installation experience on Ubuntu 8+ distributions. This tutorial explains how to install and configure Postgresql using OpenSCG's deb packages.

Contents

[hide]@H_404_20@

Requirements @H_404_20@

Appropriate 32 or 64 bit Postgresql 9.1 deb package from OpenSCG.

Installation Steps @H_404_20@

The installation of Postgresql 9.1 server is very easy. To install:

  • Download and save deb package.
user @@H_404_20@ubuntu:~$ ls@H_404_20@@H_404_20@ -l@H_404_20@@H_404_20@ postgres_9.1.1- 1@H_404_20@.amd64.openscg.deb
-rw-r--r--@H_404_20@@H_404_20@ 1@H_404_20@ user user 16375318@H_404_20@ 2011@H_404_20@-02-02 09: 46@H_404_20@ postgres_9.1.1- 1@H_404_20@.amd64.openscg.deb
  • Install the deb package as sudo
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ dpkg@H_404_20@@H_404_20@ -i@H_404_20@@H_404_20@ . /@H_404_20@postgres_9.1.1- 1@H_404_20@.amd64.openscg.deb
[@H_404_20@@H_404_20@sudo@H_404_20@@H_404_20@]@H_404_20@@H_404_20@ password for@H_404_20@ user:
Selecting prevIoUsly deselected package postgres91.
(@H_404_20@@H_404_20@Reading database ... 118945@H_404_20@ files and directories currently installed. )@H_404_20@
@H_404_20@
Unpacking postgres (@H_404_20@@H_404_20@from ... /@H_404_20@postgres_9.1.1- 1@H_404_20@.amd64.openscg.deb )@H_404_20@@H_404_20@ ...
Setting up postgres91 (@H_404_20@@H_404_20@9.1.1- 1@H_404_20@ )@H_404_20@@H_404_20@ ...
Processing triggers for@H_404_20@ ureadahead ...
ureadahead will be reprofiled on next reboot
user @@H_404_20@ubuntu:~$

Postgresql is cleanly installed to the "/opt/postgres/9.1" directory without changing any other shared libraries on your system. All the libraries that Postgresql uses are in the "/opt/postgres/9.1/lib" directory to minimize the chances of conflicts and other incompatibilities.

Configure and initializing Postgresql Server @H_404_20@

OpenSCG's server control script makes it very easy to configure the Postgresql server. The start command will attempt to initialize the server on its first usage (technically in the absence of data directory).

  • Enter following command in your shell prompt (as sudo):
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg start
  • You will be prompted to provide database server port,superuser password and server startup options. You can either press <ENTER> for default values,or you can provide your own customized inputs. Following the inputs,the database cluster will be initialized and server will be started.
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg start
Postgresql 9.1@H_404_20@ Configuration
---------------------------------@H_404_20@
@H_404_20@This will initialize Postgresql database cluster. The following
questions will determine the database server port,superuser password
and to start server on system boot. Press <@H_404_20@ENTER >@H_404_20@ to accept defaults.

Specify Postgresql server port [@H_404_20@@H_404_20@ 5432@H_404_20@ ]@H_404_20@@H_404_20@:


Specify superuser password [@H_404_20@@H_404_20@password ]@H_404_20@@H_404_20@:
Do you want Postgresql server to be started on boot (@H_404_20@@H_404_20@y /@H_404_20@n )@H_404_20@@H_404_20@ [@H_404_20@@H_404_20@y ]@H_404_20@@H_404_20@:

useradd: warning: the home directory already exists.
Not copying any file@H_404_20@@H_404_20@ from skel directory into it.
The files belonging to this database system will be owned by user "postgres"@H_404_20@@H_404_20@.
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF- 8@H_404_20@.
The default text search configuration will be set@H_404_20@ to "english"@H_404_20@@H_404_20@.

fixing permissions on existing directory /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100@H_404_20@
selecting default shared_buffers ... 24MB
creating configuration files ... ok
creating template1 database in@H_404_20@ /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@data /@H_404_20@base /@H_404_20@ 1@H_404_20@ ... ok
initializing pg_authid ... ok
setting password ... 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 /@H_404_20@pgsql server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@bin /@H_404_20@postgres -D@H_404_20@@H_404_20@ /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@data
or
/@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@bin /@H_404_20@pg_ctl -D@H_404_20@@H_404_20@ /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@data -l@H_404_20@@H_404_20@ logfile start

Configuring Postgresql server startup scripts
Adding system startup for@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg ...
/@H_404_20@etc /@H_404_20@rc0.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc1.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc6.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc2.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc3.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc4.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc5.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg - >@H_404_20@ .. /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg
Starting Postgresql 9.1@H_404_20@:
waiting for@H_404_20@ server to start.... done@H_404_20@
server started
Postgresql 9.1@H_404_20@ started successfully
To load this postgres into your environment,source@H_404_20@@H_404_20@ the env@H_404_20@@H_404_20@ file@H_404_20@@H_404_20@:
. /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@pg91-openscg.env
  • The server can now be controlled by either using invoke-rc.d command and/or by calling the init script directly:
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ invoke-rc.d postgres- 9.1@H_404_20@-openscg status
pg_ctl: server is running (@H_404_20@@H_404_20@PID: 13260@H_404_20@ )@H_404_20@
@H_404_20@/@H_404_20@
opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@bin /@H_404_20@postgres "-D"@H_404_20@@H_404_20@ "/opt/postgres/9.1/data"@H_404_20@@H_404_20@
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg status
pg_ctl: server is running (@H_404_20@@H_404_20@PID: 13260@H_404_20@ )@H_404_20@
@H_404_20@/@H_404_20@
opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@bin /@H_404_20@postgres "-D"@H_404_20@@H_404_20@ "/opt/postgres/9.1/data"@H_404_20@@H_404_20@

The server is controlled by postgres operating system user,which will be created (as a locked account) by the configuration script if it does not already exists.

Setting the Environment and Using the database @H_404_20@


The OpenSCG's deb package does not do anything to your system environment in order to prevent conflicts with other software. If you wish to load the environment for this install,you can use the included env file:

user @@H_404_20@ubuntu:~$ . /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@pg91-openscg.env
user @@H_404_20@ubuntu:~$ psql
Password:
psql (@H_404_20@@H_404_20@9.1.1 )@H_404_20@
@H_404_20@
Type "help"@H_404_20@@H_404_20@ for@H_404_20@ help.

postgres@H_404_20@@H_404_20@= #@H_404_20@@H_404_20@

This will load:

* PGHOME
* PGDATA
* PATH
* LD_LIBRARY_PATH
* PGUSER
* PGDATABASE
* PGPORT

Default database @H_404_20@


The default database created at initialization time (as with most other Postgresql packages) is:

   postgres

Default username @H_404_20@


The default superuser created at initialization time (as with most other Postgresql packages) is:

   postgres

Default password @H_404_20@


The default password (unless you set it at initialization time) is:

   password

Change the default password @H_404_20@


To change the default password,you first need to login to the database with your current password:

user @@H_404_20@ubuntu:~$ . /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@pg91-openscg.env
user @@H_404_20@ubuntu:~$ psql
Password:
psql (@H_404_20@@H_404_20@9.1.1 )@H_404_20@
@H_404_20@
Type "help"@H_404_20@@H_404_20@ for@H_404_20@ help.

postgres@H_404_20@@H_404_20@= #@H_404_20@@H_404_20@

Now,change the password for the postgres user:

postgres@H_404_20@@H_404_20@= # ALTER USER postgres WITH PASSWORD 'newpasswordgoeshere';@H_404_20@
@H_404_20@
ALTER ROLE
postgres@H_404_20@@H_404_20@= #@H_404_20@@H_404_20@

Now your password is changed.

Forgot my password! @H_404_20@


If you've forgotten your password,that's no problem. Here's the reset process:

  • Use sudo or become postgres user. (Note: postgres might be locked,in which case you must use sudo - or unlock postgres account)
  • Edit the pg_hba.conf (host based access) file using your favorite editor
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ vi@H_404_20@@H_404_20@ /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@data /@H_404_20@pg_hba.conf
  • Change highlighted line
# TYPE DATABASE USER CIDR-ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all md5@H_404_20@

by changing connection method from md5 to trust:

# TYPE DATABASE USER CIDR-ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all trust@H_404_20@
  • Save your changes
  • Command postgres to re-read it's config file (either using sudo or as postgres user)
user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg reload
Reloading Postgresql 9.1@H_404_20@:
server signaled
  • Login to the database (you will not be prompted for password).
user @@H_404_20@ubuntu:~$ exit@H_404_20@
exit@H_404_20@
@H_404_20@
user @@H_404_20@ubuntu:~$ . /@H_404_20@opt /@H_404_20@postgres /@H_404_20@ 9.1@H_404_20@ /@H_404_20@pg91-openscg.env
user @@H_404_20@ubuntu:~$ psql
psql (@H_404_20@@H_404_20@9.1.2 )@H_404_20@
@H_404_20@
Type "help"@H_404_20@@H_404_20@ for@H_404_20@ help.

postgres@H_404_20@@H_404_20@= #@H_404_20@@H_404_20@
  • Edit the pg_hba.conf (host based access) file and change trust back to md5 and reload the server.

Uninstalling Postgresql Server @H_404_20@

The uninstallation of Postgresql server can be performed as follows by using dpkg:

user @@H_404_20@ubuntu:~$ sudo@H_404_20@@H_404_20@ dpkg@H_404_20@@H_404_20@ --remove@H_404_20@@H_404_20@ postgres91
(@H_404_20@@H_404_20@Reading database ... 121647@H_404_20@ files and directories currently installed. )@H_404_20@
@H_404_20@
Removing postgres ...
Attempting to stop server...
Stopping Postgresql 9.1@H_404_20@:
waiting for@H_404_20@ server to shut down.... done@H_404_20@
server stopped
Attempting to update server startup status...
Removing any system startup links for@H_404_20@ /@H_404_20@etc /@H_404_20@init.d /@H_404_20@postgres- 9.1@H_404_20@-openscg ...
/@H_404_20@etc /@H_404_20@rc0.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc1.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc2.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc3.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc4.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc5.d /@H_404_20@S85postgres- 9.1@H_404_20@-openscg
/@H_404_20@etc /@H_404_20@rc6.d /@H_404_20@K15postgres- 9.1@H_404_20@-openscg
dpkg@H_404_20@@H_404_20@: warning: while@H_404_20@ removing postgres,directory '/opt/postgres/9.1'@H_404_20@@H_404_20@ not empty so not removed.
dpkg@H_404_20@@H_404_20@: warning: while@H_404_20@ removing postgres,directory '/opt/postgres'@H_404_20@@H_404_20@ not empty so not removed.
dpkg@H_404_20@@H_404_20@: warning: while@H_404_20@ removing postgres,directory '/opt'@H_404_20@@H_404_20@ not empty so not removed.
Processing triggers for@H_404_20@ ureadahead ...

Note 1: The data folder is not deleted after uninstallation.
Note 2: The dpkg warnings can be safely ignored.

Reporting Bugs/Suggestions @H_404_20@

If you have any questions related to deb installation,or you would like to report any bugs and/or suggestions in OpenSCG's deb packaging,feel free to join OpenSCG mailing list to discuss.

猜你在找的Postgre SQL相关文章