站点公告
最新日志
博文评论
博客留言
博客登陆
博文搜索
博客信息
收藏连接
 
手工安装Postgresql
一孑 发表于 2006/12/27 15:44:00

接上同一个项目,需要利用安装软件制作Postgresql的自动安装,我们采用的是Postgresql8.0。postgresql采用的是MSI的安装方式,这样就给我们提供了后台安装的便利,可以直接使用msiexec驱动安装程序完成安装(有关msiexec的命令行可通过msiexec/?进行查看)。这里面主要着重说明postgresql的安装。

postgresql官方说明支持NTFS格式,不支持FAT32,但通过实际应用,postgresql也可支持FAT32格式,只是在安装过程中无法初始化数据,需要后期手工配置。查询资料后实现如下:

%SystemRoot%\system32\net.exe user postgres /delete 如果已经存在此用户,需要删除

%SystemRoot%\system32\net.exe user postgres /add 增加postgresql用户

Postgresql-8.0-int.msi" /qn INTERNALLAUNCH=1 ADDLOCAL=server,psql SERVICEDOMAIN=%COMPUTERNAME% SUPERPASSWORD=icool SERVICENAME="PostgreSQL Database Server 8.0" SERVICEPASSWORD=icool BASEDIR="C:\postgresql8.0" DOINITDB="1" -li 0.log

执行安装,仅安装核心部分,不安装可视化配置工具及其他,以服务形式安装。

%SystemRoot%\system32\net.exe  stop pgsql-8.0

安装后停止postgresql服务

xcopy/EQIY data C:\postgresql8.0\data

拷贝初始化数据到目录下

%SystemRoot%\system32\net.exe  start pgsql-8.0

重新启动postgresql服务

以下内容的出处已经忘记了,后来通过搜索查询也未找到,如果是侵犯了您的权力,我深感抱歉并请马上通知我撤掉此信息,谢谢!

附:postgresql安装参数配置说明

Silent install of PostgreSQL on Windows

As the PostgreSQL installer for Windows uses Windows Installer (MSI) technology, performing a silent or semi-silent install works the same way as with any MSI installer. It is all done using commandline options to msiexec, which are used to:

All installation is done using the postgresql-<ver>-int.msi file. The main MSI file is just a wrapper around this file that sets some required properties.

Note that the following functions are not available when running a silent install:

  • Verification of service account and password. If you specify an invalid account or password, the installation will proceed most of the way, then fail and rollback at the end because of login failures.
  • Verification of data directory location. The directory specified as data directory must either not exist or be empty before you run the installation, if you want initdb to run.
  • Verification of DLL versions. You will need to verify SSL library version as well as PL dependency DLLs manually if you want this check.

If you have any questions regarding silent installations, please use the pginstaller-devel mailinglist available from the pgFoundry page.

Specifying desired user interface level

The following user interface levels are available:

Name Commandline Description
Normal none Normal interactive user installation
Reduced
/qr
No user interaction. "Full size" progress window including progress descriptions.
Basic
/qb
No user interaction. Just a basic progressbar and not full descriptions. You can also remove the cancel button using
/qb!
Silent
/qn
No user information at all.

Specifying features to install

Features to install are specified by adding:

ADDLOCAL=feature1,feature2...

to the commandline. If the ADDLOCAL parameter is not set, the default set of options will be installed.

The following features are available for install (see the wxs/pginst.wxs source for an up-to-date list. This list is accurate per RC1):

Id Description
server Database server
nls Natural Language Support
postgis (8.1 only) PostGIS Spatial Extensions
pljava (8.1 only) PL/Java
psql psql commandline utility
pgadmin pgAdmin III
jdbc JDBC driver
npgsql NPgSql .Net Data Provider
psqlodbc ODBC driver
pgoledb OLE DB provider
docs (8.0 only) HTML format documentation. 8.1 will always install CHM format documentation.
includefiles C/C++ include files
libfiles C/C++ library files
msvclibs C/C++ library files for MS Visual C++
pgxs PGXS
binfiles Development tools and utilities, such as ecpg

Specifying values for properties

Property values are fixed if using any other UI level than Normal. When using Normal, they are taken as default values in the dialogs. Note that string parameters may require quotes (") around the value.

The following properties are available:

Id Default Description
INTERNALLAUNCH 0 This must be set to 1 to be able to use the -int MSI file.
DOSERVICE 1 Install running as a service.
DOINITDB 1 Run initdb on installed system. Only available when installing service. Not available on NT4.
SERVICEDOMAIN . Domain name for service user. For local user, use the name of the computer (%COMPUTERNAME%)
SERVICEACCOUNT postgres Name of service user, excluding domain name.
SERVICEPASSWORD   Password for service account. The account must already have this password; the installer will not change it.
CREATESERVICEUSER (8.1 only) 0 Set to 1 have the service user created during installation, with the specified username and password.
SERVICENAME PostgreSQL Database Server <ver> Name of service in the service control manager. Must be unique on system.
SUPERUSER postgres Account name for default user in database. Only used when running initdb.
SUPERPASSWORD   Password for default user in database. Only used when running initdb.
LOCALE C Locale for database. Only used when running initdb.
ENCODING SQL_ASCII Encoding for database. Only used when running initdb.
LISTENPORT 5432 TCP port to listen for connections on. Only used when running initdb.
PERMITREMOTE   Permit connections from non-localhost machines (set to 1 to enable). Only used when running initdb.
PL_PGSQL 1 Install PL/PGSQL procedural language.
PL_PERL   Install PL/PERL procedural language. Make sure you have the correct perl58.dll available in the system path.
PL_PERLU   Install PL/PERL untrusted procedural language. Make sure you have the correct perl58.dll available in the system path.
PL_TCL   Install PL/TCL procedural language. Make sure you have the correct tcl84.dll available in the system path.
PL_TCLU   Install PL/TCL untrusted procedural language. Make sure you have the correct tcl84.dll available in the system path.
PL_PYTHONU   Install PL/PYTHON untrusted procedural language. Make sure you have the correct python23.dll available in the system path.
PL_J***A (8.1 only)   Install PL/J***A trusted and untrusted procedural languages. Make sure you have the correct JRE available in the system path.
NOSHORTCUTS (8.1 only) 0 Don't install any startmenu shortcuts

The following properties are available to change the location of the installation. It is recommended that you only change the TARGETDIR and DATADIR properties if that is appropriate for your installation.

Id Default Description
BASEDIR automatically set by Windows Installer Root directory for entire installation.
SERVERDIR BASEDIR Location of server files.
DATADIR BASEDIR\data Location of server data files.
UIDIR BASEDIR Root directory for UI subfeatures.
CBINDIR UIDIR\bin Directory for psql.exe.
PGADMINDIR UIDIR\pgAdmin Directory for pgAdmin III.
JDBCDIR BASEDIR\jdbc Directory for JDBC driver.
NPGSQLDIR BASEDIR\Npgsql Directory for Npgsql .Net data provider. (Some files are also installed in the GAC if .Net Framework is installed)
PSQLODBCDIR BASEDIR\odbc Directory for ODBC driver.
PGOLEDBDIR BASEDIR\PgOleDb Directory for OLE DB provider.
DOCDIR (8.0 only) BASEDIR\doc Directory for documentation.
DEVDIR BASEDIR Directory for development files.

There are some further specific subdirectories available that may or may not work when changed. See wxs/pginst.wxs for a complete list.

Apart from these there is a whole set of properties for which contrib modules to enable. If you want anything other than the default, you will have to look at the source code (wxs/pginst.wxs) for a list of these.

Optionally specify language to use for user messages

To select a language other than english for installation messages, you need to apply an embedded language transform. This is done by specifying the property:
TRANSFORMS=:lang_langcode
where langcode is the language code for the messages. Available language codes can be found in lang/Makefile.lang. At the time of this writing, support exists for German (de), French (fr), Brazilian Portuguese (pt_br) and Swedish (sv).

A complete example

The following example will install the server, psql and documentation into the file c:\postgres, as a service, with specified username/password. It uses a reduced UI level so we can see the full progress indication, and sets the language to german.

msiexec /i postgresql-8.0.0-rc1-int.msi  /qr INTERNALLAUNCH=1 ADDLOCAL=server,psql,docs SERVICEDOMAIN="%COMPUTERNAME%"
        SERVICEPASSWORD="SecretWindowsPassword123" SUPERPASSWORD="VerySecret" BASEDIR="c:\postgres" TRANSFORMS=:lang_de


 

发表评论:

    昵称:
    密码:
    主页:
    标题: