Chinaunix首页 | 论坛 | 博客
  • 博客访问: 787515
  • 博文数量: 129
  • 博客积分: 3477
  • 博客等级: 中校
  • 技术积分: 1329
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-30 21:53
文章分类

全部博文(129)

文章存档

2023年(10)

2022年(4)

2021年(10)

2020年(9)

2018年(1)

2017年(1)

2014年(4)

2013年(3)

2012年(12)

2011年(24)

2010年(2)

2009年(8)

2008年(6)

2007年(34)

2006年(1)

分类: 其他UNIX

2018-05-26 19:59:25

纯干货,无废话。
写在前面的话:
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、执行编译前配置

点击(此处)折叠或打开

  1. # ./configure --prefix=/usr/gnu --build=i586-sco-sysv5 --host=i586-sco-sysv5

4、编译并安装

点击(此处)折叠或打开

  1. # make
  2. # make install
5、建立连接

点击(此处)折叠或打开

  1. # cd /usr/bin
  2. # 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 目录下,并展开压缩文件:

点击(此处)折叠或打开

  1. # cd /tmp
  2. # bzip2 –d postgresql-10.4.tar.bz2
  3. # tar xvf postgresql-10.4.tar

Step 2:
修改 PostgreSQL 10.4 的安装程序源码,添加一些内容:
1、修改 postgresql-10.4/src/include/c.h 文件,在其中加入如下内容:
在:

点击(此处)折叠或打开

  1. #define C_H

下面加入:

点击(此处)折叠或打开

  1. #include <sys/time.h>

在:

点击(此处)折叠或打开

  1. #include "pg_config_manual.h" /* must be after pg_config.h */

下面加入:

点击(此处)折叠或打开

  1. #ifdef FLEXIBLE_ARRAY_MEMBER
  2. #undef FLEXIBLE_ARRAY_MEMBER
  3. #define FLEXIBLE_ARRAY_MEMBER 1
  4. #else
  5. #define FLEXIBLE_ARRAY_MEMBER 1
  6. #endif

2、在 postgresql-10.4/src/template 目录下添加文件 sco , 内容如下:

点击(此处)折叠或打开

  1. CC="$CC -b elf"

3、在 postgresql-10.4/src/template 目录下添加文件 unixware , 内容如下:

点击(此处)折叠或打开

  1. if test "$GCC" != yes; then
  2. # The -Kno_host is for a bug in the compiler. See -hackers
  3. # discussion on 7-8/Aug/2003.
  4. cat >conftest.c <<__EOF__
  5. extern char *strcpy(char *, const char *);
  6. static void f(char *p, int n){
  7. strcpy(p+n,"");
  8. }
  9. void g(void){
  10. f(0, 0);
  11. }
  12. __EOF__
  13. # Debugging and optimization are mutually exclusive
  14. if test "$enable_debug" != yes; then
  15. CFLAGS="-O"
  16. fi
  17. if $CC -c -O -Kinline conftest.c >conftest.err 2>&1; then
  18. CFLAGS="$CFLAGS -Kinline"
  19. else
  20. CFLAGS="$CFLAGS -Kinline,no_host"
  21. fi
  22. rm -f conftest.*
  23. PTHREAD_CFLAGS="-Kpthread"
  24. # The effect of doing threading for the backend does not work
  25. # because of a threading bug that appears in the regression tests:
  26. #
  27. # in make check, the plpgsql test (plpgsql.sql)
  28. # set statement_timeout to 1000;
  29. # select blockme();
  30. # reset statement_timeout;
  31. #
  32. # per report from Olivier PRENANT <ohp@pyrenet.fr>
  33. fi
  34. # Unixware's ldap library reportedly needs these too
  35. EXTRA_LDAP_LIBS="-llber -lresolv"

4、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 sco.c , 内容如下:

点击(此处)折叠或打开

  1. /*
  2. * src/backend/port/dynloader/sco.c
  3. *
  4. * Dummy file used for nothing at this point
  5. *
  6. * see sco.h
  7. */

5、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 sco.h , 内容如下:

点击(此处)折叠或打开

  1. /*-------------------------------------------------------------------------
  2. *
  3. * sco.h
  4. * port-specific prototypes for SCO 3.2v5.2
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/backend/port/dynloader/sco.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef PORT_PROTOS_H
  15. #define PORT_PROTOS_H
  16. #include <dlfcn.h>
  17. #include "utils/dynamic_loader.h" /* pgrminclude ignore */
  18. /*
  19. * Dynamic Loader on SCO 3.2v5.0.2
  20. *
  21. * this dynamic loader uses the system dynamic loading interface for shared
  22. * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
  23. * library as the file to be dynamically loaded.
  24. */
  25. /*
  26. * In some older systems, the RTLD_NOW flag isn't defined and the mode
  27. * argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
  28. * if available, but it doesn't exist everywhere.
  29. * If it doesn
6、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 unixware.c , 内容如下:

点击(此处)折叠或打开

  1. /*
  2. * src/backend/port/dynloader/unixware.c
  3. *
  4. * Dummy file used for nothing at this point
  5. *
  6. * see unixware.h
  7. */

7、在 postgresql-10.4/src/backend/port/dynloader/ 目录下添加文件 unixware.h , 内容如下:

点击(此处)折叠或打开

  1. /*
  2. * src/backend/port/dynloader/unixware.h
  3. *
  4. *-------------------------------------------------------------------------
  5. *
  6. * unixware.h
  7. * port-specific prototypes for Intel x86/UNIXWARE 7
  8. *
  9. *
  10. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  11. * Portions Copyright (c) 1994, Regents of the University of California
  12. *
  13. * unixware.h,v 1.2 1995/03/17 06:40:18 andrew Exp
  14. *
  15. *-------------------------------------------------------------------------
  16. */
  17. #ifndef PORT_PROTOS_H
  18. #define PORT_PROTOS_H
  19. #include <dlfcn.h>
  20. #include "utils/dynamic_loader.h" /* pgrminclude ignore */
  21. /*
  22. * Dynamic Loader on UnixWare.
  23. *
  24. * this dynamic loader uses the system dynamic loading interface for shared
  25. * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
  26. * library as the file to be dynamically loaded.
  27. */
  28. /*
  29. * In some older systems, the RTLD_NOW flag isn't defined and the mode
  30. * argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted
  31. * if available, but it doesn't exist everywhere.
  32. * If it doesn't exist, set it to 0 so it has no effect.
  33. */
  34. #ifndef RTLD_NOW
  35. #define RTLD_NOW 1
  36. #endif
  37. #ifndef RTLD_GLOBAL
  38. #define RTLD_GLOBAL 0
  39. #endif
  40. #define pg_dlopen(f) dlopen((f), RTLD_NOW | RTLD_GLOBAL)
  41. #define pg_dlsym dlsym
  42. #define pg_dlclose dlclose
  43. #define pg_dlerror dlerror
  44. #endif /* PORT_PROTOS_H */


8、在 postgresql-10.4/src/include/port/ 目录下添加文件 sco.h , 内容如下:

点击(此处)折叠或打开

  1. /*
  2. * src/include/port/sco.h
  3. *
  4. * see src/backend/libpq/pqcomm.c */
  5. #define SCO_ACCEPT_BUG
  6. #define USE_UNIVEL_CC

9、在 postgresql-10.4/src/include/port/ 目录下添加文件 unixware.h , 内容如下:

点击(此处)折叠或打开

  1. /*
  2. * src/include/port/unixware.h
  3. *
  4. * see src/backend/libpq/pqcomm.c */
  5. #define SCO_ACCEPT_BUG
  6. /***************************************
  7. * Define this if you are compiling with
  8. * the native UNIXWARE C compiler.
  9. ***************************************/
  10. #define USE_UNIVEL_CC

10、在 postgresql-10.4/src/makefiles/ 目录下添加 sco 系统的编译文件 Makefile.sco ,内容如下:

点击(此处)折叠或打开

  1. AROPT = cr
  2. export_dynamic = -Wl,-Bexport
  3. DLSUFFIX = .so
  4. ifeq ($(GCC), yes)
  5. CFLAGS_SL = -fpic
  6. else
  7. CFLAGS_SL = -K PIC
  8. endif
  9. # Rule for building a shared library from a single .o file
  10. %.so: %.o
  11. $(LD) -G -Bdynamic -o $@ $<

11、在 postgresql-10.4/src/makefiles/ 目录下添加 unixware 系统的编译文件 Makefile.unixware ,内容如下:

点击(此处)折叠或打开

  1. AROPT = crs
  2. ifeq ($(with_gnu_ld), yes)
  3. export_dynamic = -Wl,-E
  4. else
  5. export_dynamic = -Wl,-Bexport
  6. endif
  7. ifeq ($(ld_R_works), yes)
  8. ifeq ($(with_gnu_ld), yes)
  9. rpath = -Wl,-rpath,'$(rpathdir)'
  10. else
  11. rpath = -Wl,-R'$(rpathdir)'
  12. endif
  13. endif
  14. # Unixware needs threads for everything that uses libpq
  15. CFLAGS += $(PTHREAD_CFLAGS)
  16. DLSUFFIX = .so
  17. ifeq ($(GCC), yes)
  18. CFLAGS_SL = -fpic
  19. else
  20. CFLAGS_SL = -K PIC
  21. endif
  22. ifeq ($(GCC), yes)
  23. SO_FLAGS = -shared
  24. else
  25. SO_FLAGS = -G
  26. endif
  27. # Rule for building a shared library from a single .o file
  28. %.so: %.o
  29. $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) $(SO_FLAGS) -o $@ $<
  30. sqlmansect = 5sql

12、在 postgresql-10.4/configure 文件中,添加编译操作系统环境描述内容,在:

点击(此处)折叠或打开

  1. openbsd*) template=openbsd ;;

下面加入:

点击(此处)折叠或打开

  1. sco*) template=sco ;;

在:

点击(此处)折叠或打开

  1. solaris*) template=solaris ;;

下面加入:

点击(此处)折叠或打开

  1. sysv5*) template=unixware ;;

13、在 postgresql-10.4/configure.in 文件中,添加编译操作系统环境描述内容,在:

点击(此处)折叠或打开

  1. openbsd*) template=openbsd ;;

下面加入:

点击(此处)折叠或打开

  1. sco*) template=sco ;;

在:

点击(此处)折叠或打开

  1. solaris*) template=solaris ;;

下面加入:

点击(此处)折叠或打开

  1. sysv5*) template=unixware ;;

14、修改 postgresql-10.4/src/Makefile.shlib 文件,在其中加入共享库编译时的 sco 和 unixware 的支持。
在:

点击(此处)折叠或打开

  1. ifeq ($(PORTNAME), solaris)
  2. ifeq ($(GCC), yes)
  3. LINK.shared = $(COMPILER) -shared
  4. else
  5. LINK.shared = $(COMPILER) -G
  6. endif
  7. ifdef soname
  8. ifeq ($(with_gnu_ld), yes)
  9. LINK.shared += -Wl,-soname,$(soname)
  10. else
  11. LINK.shared += -h $(soname)
  12. endif
  13. endif
  14. endif

下面加入:

点击(此处)折叠或打开

  1. ifeq ($(PORTNAME), sco)
  2. ifeq ($(GCC), yes)
  3. LINK.shared = $(CC) -shared
  4. else
  5. LINK.shared = $(CC) -G
  6. endif
  7. LINK.shared += -Wl,-z,text
  8. ifdef soname
  9. LINK.shared += -Wl,-h,$(soname)
  10. endif
  11. endif
  12. ifeq ($(PORTNAME), unixware)
  13. ifeq ($(GCC), yes)
  14. LINK.shared = $(CC) -shared
  15. else
  16. LINK.shared = $(CC) -G
  17. endif
  18. LINK.shared += -Wl,-z,text
  19. ifdef soname
  20. LINK.shared += -Wl,-h,$(soname)
  21. endif
  22. endif


Step 3:开始准备编译环境:
1、创建编译目录环境,建立一个编译目录,如 /tmp/objdir
2、写编译配置文件 build.sh,内容如下:

点击(此处)折叠或打开

  1. ../postgresql-10.4/configure \
  2. --prefix=/opt/PostgreSQL/10.4 \
  3. --build=i586-sco-sysv5 \
  4. --host=i586-sco-sysv5 \
  5. --disable-spinlocks \
  6. --disable-thread-safety

3、修改其权限为 0755

点击(此处)折叠或打开

  1. # chmod 0755 build.sh

4、进入 /tmp/objdir 目录,开始编译前环境配置。

点击(此处)折叠或打开

  1. # cd /tmp/objdir
  2. # ../build.sh

Step 4:编译安装 PostgreSQL 10.4 软件
1、开始编译

点击(此处)折叠或打开

  1. # gmake
  2. # gmake install

Step 5:配置使用环境,使用 PostgreSQL 10.4
1、创建用户,进行使用前初始化。

点击(此处)折叠或打开

  1. # groupadd postgres
  2. # mkdir /home
  3. # chmod 0775 /home
  4. # useradd -d /home/postgres -g postgres -s /bin/bash -m postgres
  5. # passwd postgres

<选择 1 , 连续两次输入用户密码 >
2、编辑 /home/postgres/.bash_profile 文件,添加环境变量参数。
在:

点击(此处)折叠或打开

  1. export BASH_ENV

下面加入:

点击(此处)折叠或打开

  1. source $BASH_ENV

3、编辑 /home/postgres/.bashrc 文件,添加环境变量参数。
在文件最后,加入如下语句:

点击(此处)折叠或打开

  1. export PG_VERSION=10.4
  2. export PG_HOME=/opt/PostgreSQL/${PG_VERSION}
  3. export PGDATA=${HOME}/data
  4. export PGLOG=${PGDATA}/pg_log
  5. export PATH=$PATH:$PG_HOME/bin:.
  6. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PG_HOME/lib:.

4、切换用户到 postgres

点击(此处)折叠或打开

  1. # 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)

则表示成功了。
则表示成功了。
阅读(1175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~