写在前面的话:
PostgreSQL 数据库软件从 10 版本开始,就不再支持 SCO OpenServer6 系统了,但这并不代表我们无法在 SCO OpenServer 6 系统上安装使用 PostgreSQL 10 以上的数据库版本,只是相对麻烦一点。
因为 PostgreSQL 数据库是使用原生的 C 语言开发的,这对我们是一个很好的信号,我们有理由相信,经过简单的修改,我们是能够在 SCO OpenServer 6 系统上使用 PostgreSQL 10 的,当然,前提是你必须要有足够的耐心。
编译需要的前置条件:
1、系统必须安装开发软件包;
2、系统必须打上 SCO OpenServer Release 6.0.0 Maintenance Pack 4 (ver 1.0.0Ce) 补丁包;
3、编译必须使用 gmake 3.8 或以上版本,测试中发现 3.8 或 3.8.2 的版本最好,其他版本在编译安装 make 程序包的时候需要修改程序代码。
编译安装 make-3.8.0 的软件包方法如下。
1、展开 make-3.8.0.tar.bz2
2、进入 make-3.8.0 目录
3、执行编译前配置
点击(此处)折叠或打开
- # ./configure --prefix=/usr/gnu --build=i586-sco-sysv5 --host=i586-sco-sysv5
4、编译并安装
点击(此处)折叠或打开
- # make
- # make install
点击(此处)折叠或打开
- # cd /usr/bin
- # ln -sf /usr/gnu/bin/make gmake
PostgreSQLPostgreSQL PostgreSQL PostgreSQL PostgreSQL 10.4 10.4 10.4 在 SCO OpenServer OpenServerOpenServer 6 系统 上的安装使用
做好前置工作后,我们开始进入 PostgreSQL 10.4 的安装,过程如下:
Step 1:
下载 postgresql-10.4.tar.bz2 文件,放置在 /tmp 目录下,并展开压缩文件:
点击(此处)折叠或打开
- # cd /tmp
- # bzip2 –d postgresql-10.4.tar.bz2
- # tar xvf postgresql-10.4.tar
Step 2:
修改 PostgreSQL 10.4 的安装程序源码,添加一些内容:
1、修改 postgresql-10.4/src/include/c.h 文件,在其中加入如下内容:
在:
点击(此处)折叠或打开
- #define C_H
下面加入:
点击(此处)折叠或打开
- #include <sys/time.h>
在:
点击(此处)折叠或打开
- #include "pg_config_manual.h" /* must be after pg_config.h */
下面加入:
点击(此处)折叠或打开
- #ifdef FLEXIBLE_ARRAY_MEMBER
- #undef FLEXIBLE_ARRAY_MEMBER
- #define FLEXIBLE_ARRAY_MEMBER 1
- #else
- #define FLEXIBLE_ARRAY_MEMBER 1
- #endif
2、在 postgresql-10.4/src/template 目录下添加文件 sco , 内容如下:
点击(此处)折叠或打开
- CC="$CC -b elf"
3、在 postgresql-10.4/src/template 目录下添加文件 unixware , 内容如下:
点击(此处)折叠或打开
- if test "$GCC" != yes; then
- # The -Kno_host is for a bug in the compiler. See -hackers
- # discussion on 7-8/Aug/2003.
- cat >conftest.c <<__EOF__
- extern char *strcpy(char *, const char *);
- static void f(char *p, int n){
- strcpy(p+n,"");
- }
- void g(void){
- f(0, 0);
- }
- __EOF__
- # Debugging and optimization are mutually exclusive
- if test "$enable_debug" != yes; then
- CFLAGS="-O"
- fi
- if $CC -c -O -Kinline conftest.c >conftest.err 2>&1; then
- CFLAGS="$CFLAGS -Kinline"
- else
- CFLAGS="$CFLAGS -Kinline,no_host"
- fi
- rm -f conftest.*
- PTHREAD_CFLAGS="-Kpthread"
- # The effect of doing threading for the backend does not work
- # because of a threading bug that appears in the regression tests:
- #
- # in make check, the plpgsql test (plpgsql.sql)
- # set statement_timeout to 1000;
- # select blockme();
- # reset statement_timeout;
- #
- # per report from Olivier PRENANT <ohp@pyrenet.fr>
- fi
- # Unixware's ldap library reportedly needs these too
- EXTRA_LDAP_LIBS="-llber -lresolv"
4、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 sco.c , 内容如下:
点击(此处)折叠或打开
- /*
- * src/backend/port/dynloader/sco.c
- *
- * Dummy file used for nothing at this point
- *
- * see sco.h
- */
5、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 sco.h , 内容如下:
点击(此处)折叠或打开
- /*-------------------------------------------------------------------------
- *
- * sco.h
- * port-specific prototypes for SCO 3.2v5.2
- *
- *
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/backend/port/dynloader/sco.h
- *
- *-------------------------------------------------------------------------
- */
- #ifndef PORT_PROTOS_H
- #define PORT_PROTOS_H
- #include <dlfcn.h>
- #include "utils/dynamic_loader.h" /* pgrminclude ignore */
- /*
- * Dynamic Loader on SCO 3.2v5.0.2
- *
- * this dynamic loader uses the system dynamic loading interface for shared
- * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
- * library as the file to be dynamically loaded.
- */
- /*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
- * if available, but it doesn't exist everywhere.
- * If it doesn
点击(此处)折叠或打开
- /*
- * src/backend/port/dynloader/unixware.c
- *
- * Dummy file used for nothing at this point
- *
- * see unixware.h
- */
7、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 unixware.h , 内容如下:
点击(此处)折叠或打开
- /*
- * src/backend/port/dynloader/unixware.h
- *
- *-------------------------------------------------------------------------
- *
- * unixware.h
- * port-specific prototypes for Intel x86/UNIXWARE 7
- *
- *
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * unixware.h,v 1.2 1995/03/17 06:40:18 andrew Exp
- *
- *-------------------------------------------------------------------------
- */
- #ifndef PORT_PROTOS_H
- #define PORT_PROTOS_H
- #include <dlfcn.h>
- #include "utils/dynamic_loader.h" /* pgrminclude ignore */
- /*
- * Dynamic Loader on UnixWare.
- *
- * this dynamic loader uses the system dynamic loading interface for shared
- * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
- * library as the file to be dynamically loaded.
- */
- /*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
- * if available, but it doesn't exist everywhere.
- * If it doesn't exist, set it to 0 so it has no effect.
- */
- #ifndef RTLD_NOW
- #define RTLD_NOW 1
- #endif
- #ifndef RTLD_GLOBAL
- #define RTLD_GLOBAL 0
- #endif
- #define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
- #define pg_dlsym dlsym
- #define pg_dlclose dlclose
- #define pg_dlerror dlerror
- #endif /* PORT_PROTOS_H */
8、在 postgresql-10.4/src/include/port/ 目录下添加文件 sco.h , 内容如下:
点击(此处)折叠或打开
- /*
- * src/include/port/sco.h
- *
- * see src/backend/libpq/pqcomm.c */
- #define SCO_ACCEPT_BUG
- #define USE_UNIVEL_CC
9、在 postgresql-10.4/src/include/port/ 目录下添加文件 unixware.h , 内容如下:
点击(此处)折叠或打开
- /*
- * src/include/port/unixware.h
- *
- * see src/backend/libpq/pqcomm.c */
- #define SCO_ACCEPT_BUG
- /***************************************
- * Define this if you are compiling with
- * the native UNIXWARE C compiler.
- ***************************************/
- #define USE_UNIVEL_CC
10、在 postgresql-10.4/src/makefiles/ 目录下添加 sco 系统的编译文件 Makefile.sco ,内容如下:
点击(此处)折叠或打开
- AROPT = cr
- export_dynamic = -Wl,-Bexport
- DLSUFFIX = .so
- ifeq ($(GCC), yes)
- CFLAGS_SL = -fpic
- else
- CFLAGS_SL = -K PIC
- endif
- # Rule for building a shared library from a single .o file
- %.so: %.o
- $(LD) -G -Bdynamic -o $@ $<
11、在 postgresql-10.4/src/makefiles/ 目录下添加 unixware 系统的编译文件 Makefile.unixware ,内容如下:
点击(此处)折叠或打开
- AROPT = crs
- ifeq ($(with_gnu_ld), yes)
- export_dynamic = -Wl,-E
- else
- export_dynamic = -Wl,-Bexport
- endif
- ifeq ($(ld_R_works), yes)
- ifeq ($(with_gnu_ld), yes)
- rpath = -Wl,-rpath,'$(rpathdir)'
- else
- rpath = -Wl,-R'$(rpathdir)'
- endif
- endif
- # Unixware needs threads for everything that uses libpq
- CFLAGS += $(PTHREAD_CFLAGS)
- DLSUFFIX = .so
- ifeq ($(GCC), yes)
- CFLAGS_SL = -fpic
- else
- CFLAGS_SL = -K PIC
- endif
- ifeq ($(GCC), yes)
- SO_FLAGS = -shared
- else
- SO_FLAGS = -G
- endif
- # Rule for building a shared library from a single .o file
- %.so: %.o
- $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(SO_FLAGS) -o $@ $<
- sqlmansect = 5sql
12、在 postgresql-10.4/configure 文件中,添加编译操作系统环境描述内容,在:
点击(此处)折叠或打开
- openbsd*) template=openbsd ;;
下面加入:
点击(此处)折叠或打开
- sco*) template=sco ;;
在:
点击(此处)折叠或打开
- solaris*) template=solaris ;;
下面加入:
点击(此处)折叠或打开
- sysv5*) template=unixware ;;
13、在 postgresql-10.4/configure.in 文件中,添加编译操作系统环境描述内容,在:
点击(此处)折叠或打开
- openbsd*) template=openbsd ;;
下面加入:
点击(此处)折叠或打开
- sco*) template=sco ;;
在:
点击(此处)折叠或打开
- solaris*) template=solaris ;;
下面加入:
点击(此处)折叠或打开
- sysv5*) template=unixware ;;
14、修改 postgresql-10.4/src/Makefile.shlib 文件,在其中加入共享库编译时的 sco 和 unixware 的支持。
在:
点击(此处)折叠或打开
- ifeq ($(PORTNAME), solaris)
- ifeq ($(GCC), yes)
- LINK.shared = $(COMPILER) -shared
- else
- LINK.shared = $(COMPILER) -G
- endif
- ifdef soname
- ifeq ($(with_gnu_ld), yes)
- LINK.shared += -Wl,-soname,$(soname)
- else
- LINK.shared += -h $(soname)
- endif
- endif
- endif
下面加入:
点击(此处)折叠或打开
- ifeq ($(PORTNAME), sco)
- ifeq ($(GCC), yes)
- LINK.shared = $(CC) -shared
- else
- LINK.shared = $(CC) -G
- endif
- LINK.shared += -Wl,-z,text
- ifdef soname
- LINK.shared += -Wl,-h,$(soname)
- endif
- endif
- ifeq ($(PORTNAME), unixware)
- ifeq ($(GCC), yes)
- LINK.shared = $(CC) -shared
- else
- LINK.shared = $(CC) -G
- endif
- LINK.shared += -Wl,-z,text
- ifdef soname
- LINK.shared += -Wl,-h,$(soname)
- endif
- endif
Step 3:开始准备编译环境:
1、创建编译目录环境,建立一个编译目录,如 /tmp/objdir
2、写编译配置文件 build.sh,内容如下:
点击(此处)折叠或打开
- ../postgresql-10.4/configure \
- --prefix=/opt/PostgreSQL/10.4 \
- --build=i586-sco-sysv5 \
- --host=i586-sco-sysv5 \
- --disable-spinlocks \
- --disable-thread-safety
3、修改其权限为 0755
点击(此处)折叠或打开
- # chmod 0755 build.sh
4、进入 /tmp/objdir 目录,开始编译前环境配置。
点击(此处)折叠或打开
- # cd /tmp/objdir
- # ../build.sh
Step 4:编译安装 PostgreSQL 10.4 软件
1、开始编译
点击(此处)折叠或打开
- # gmake
- # gmake install
Step 5:配置使用环境,使用 PostgreSQL 10.4
1、创建用户,进行使用前初始化。
点击(此处)折叠或打开
- # groupadd postgres
- # mkdir /home
- # chmod 0775 /home
- # useradd -d /home/postgres -g postgres -s /bin/bash -m postgres
- # passwd postgres
2、编辑 /home/postgres/.bash_profile 文件,添加环境变量参数。
在:
点击(此处)折叠或打开
- export BASH_ENV
下面加入:
点击(此处)折叠或打开
- source $BASH_ENV
3、编辑 /home/postgres/.bashrc 文件,添加环境变量参数。
在文件最后,加入如下语句:
点击(此处)折叠或打开
- export PG_VERSION=10.4
- export PG_HOME=/opt/PostgreSQL/${PG_VERSION}
- export PGDATA=${HOME}/data
- export PGLOG=${PGDATA}/pg_log
- export PATH=$PATH:$PG_HOME/bin:.
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_HOME/lib:.
4、切换用户到 postgres
点击(此处)折叠或打开
- # su – postgres
5、创建数据库实例目录
$ mkdir data
6、初始化数据库实例
$ initdb -E utf-8 -U postgres –W
连续两次数据 postgres 密码
进入 data 目录,修改数据库配置文件
$ cd data
$ mkdir pg_log
$ chmod 0700 pg_log
$ vi pg_hba.conf
修改
local all all trust
为
local all all md5
修改
host all all 127.0.0.1/32 trust
为
host all all 127.0.0.1/32 md5
并在其下面添加
host all all 0.0.0.0/0 md5
修改 postgresql.conf 文件
$ vi postgresql.conf
修改:
#listen_addresses = 'localhost'
为
listen_addresses = '*'
修改
#port = 5432
为
port = 5432
修改
#password_encryption = on
为
password_encryption = on
启动 postgresql 数据库实例
$ pg_ctl -D ${PGDATA} -l ${PGDATA}/pg_log/startlog start
查看是否正常:
$ psql –l
$ passwd:
数据数据库用户(postgres)密码
如果显示:
如果显示:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | UTF8 | C | C |
template0 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
则表示成功了。
则表示成功了。