Install 32-bit PostgreSQL 8 on 64-bit CentOS 7

Recently, Alibaba Cloud urged a friend to quickly deal with system vulnerabilities, otherwise it would stop. This friend is on Alibaba Cloud and deployed 32-bit PostgreSQL 8.1 on the CentOS 6 host. He uses this.

After much deliberation, install PostgreSQL 8.1 on CentOS 7. The former is a 64-bit operating system and the latter is a 32-bit application. Can it be installed successfully? You have to try it to find out. So, I went to the PostgreSQL official website to download and found only the name, no software package, no RPM or source code. Fortunately, the friend kept a backup of the source code.

step 1

Copy the source code to a CentOS virtual machine in VMware Workstation Pro.

# tar xvf postgresql-8.1.23.tar.gz
# cd postgresql-8.1.23

Step 2

compile. What I run directly is: ./configure

In fact, looking at the compilation log config.log, the default compilation parameters are as follows:

./configure --prefix=/usr 
--mandir=/usr/share/man 
--infodir=/usr/share/info 
--with-bugurl=http://bugzilla.redhat.com/bugzilla 
--enable-bootstrap 
--enable-shared 
--enable-threads=posix 
--enable-checking=release 
--with-system-zlib 
--enable-__cxa_atexit 
--disable-libunwind-exceptions 
--enable-gnu-unique-object 
--enable-linker-build-id 
--with-linker-hash-style=gnu 
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto 
--enable-plugin 
--enable-initfini-array 
--disable-libgcj 
--with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install 
--with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function 
--with-tune=generic 
--with-arch_32=x86-64 
--build=x86_64-redhat-linux

The result shows an error: Readline library not found.

Check the installation instructions on the official website to know that Readline is an assistant for the psql command line tool, and it is installed by default. It helps to remember commands that have been run through psql, and can use the up and down arrow keys to scroll through these commands. To install two packages readline, readline-devel.

 

Step 3

Supplement missing software.

# make clean
# yum install -y bison perl python readline readline-devel readline zlib zlib-devel

Installed readline, readline-devel.

Step 4

# useradd postgres
# mkdir /usr/local/pgsql/data
# chown postgres /usr/local/pgsql/data
# /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

PostgreSQL requires the postgres user to run. So the user is added and permissions on the data directory are granted to it. In the last item above, the /usr/local/pgsql/data directory is set as the storage directory of the database, and the database is created.

Still wrong. as follows:

creating template1 database in data/base/1 ... ok
initializing pg_authid ... FATAL:  wrong number of index expressions
child process exited with exit code 1
initdb: removing contents of data directory "data"

After searching for a long time, I realized that this is because the version of gcc is too high. Special parameters are required to downgrade it during configuration.

Step 5

# ./configure CFLAGS="-fno-aggressive-loop-optimizations"
# make 
# make install

This parameter solves the problem that the previous GCC version is too high.

Step 6

Start PostgreSQL, create the database testdb, and import the previously backed up testdb.sql into testdb. Finally, set the password 123456 for the postgres user.

# /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data &
# /usr/local/pgsql/bin/createdb -U postgres testdb -E SQL_ASCII -D pg_default
# /usr/local/pgsql/bin/psql -U postgres testdb < /backup/testdb.sql
# /usr/local/pgsql/bin/psql -U postgres
postgres# alter user postgres with password '123456';
\q;

In the end there are of course a few more things to do:

1) Set the listening IP

# vim /usr/local/data/postgresql.conf

listen = "11.22.33.44"    //监听某个IP地址

或者

listen = '*'  //监听所有IP地址

2) Enable password authentication

Add the following line at the end of /usr/local/data/pg_hba.conf:


host    all         all         0.0.0.0 0.0.0.0       md5

backup database

/usr/local/pgsql/bin/pg_dump  -U postgres mydatabase > /backup/mydatabase.sql

Create database
/usr/local/pgsql/bin/createdb -U postgres mydatabase -E SQL_ASCII -D pg_default

import database
/usr/local/pgsql/bin/psql -U postgres -d mydatabase < ./backup/mydatabase .sql

drop database
/usr/local/pgsql/bin/dropdb -U postgres mydatabase

start the database

/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data

停止数据库

/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data

 

参考资料:

1、https://www.postgresql.org/docs/8.1/install-requirements.html

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324187230&siteId=291194637