cd /root/setup/database
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql12-server postgresql12-contrib
sudo service postgresql-12 initdb
ls /var/lib/pgsql/12/
cat /var/lib/pgsql/12/pgstartup.log
sudo service tomcat stop
su - postgres
mkdir /tmp/pgsql
/usr/pgsql-12/bin/pg_dumpall > /tmp/pgsql/db.out
exit
sudo service postgresql-9.4 stop
su - postgres
cp -pr /var/lib/pgsql/9.4 /tmp/pgsql/
/usr/pgsql-12/bin/pg_upgrade -b /usr/pgsql-9.4/bin -B /usr/pgsql-12/bin -d /var/lib/pgsql/9.4/data -D /var/lib/pgsql/12/data --check
/usr/pgsql-12/bin/pg_upgrade -v -b /usr/pgsql-9.4/bin/ -B /usr/pgsql-12/bin/ -d /var/lib/pgsql/9.4/data -D /var/lib/pgsql/12/data
Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
./analyze_new_cluster.sh
Running this script will delete the old cluster's data files:
./delete_old_cluster.sh
-bash-4.1$
diff /var/lib/pgsql/9.4/data/pg_hba.conf /var/lib/pgsql/12/data/pg_hba.conf
vi /var/lib/pgsql/12/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication all peer
#host replication all 127.0.0.1/32 ident
#host replication all ::1/128 ident
diff /var/lib/pgsql/9.4/data/postgresql.conf /var/lib/pgsql/12/data/postgresql.conf
exit
sudo chkconfig postgresql-12 on
sudo service postgresql-12 start
[root@www ~]# sudo service postgresql-12 start
正在啟動 postgresql-12 服務: [ 確定 ]
su - postgres
./analyze_new_cluster.sh
[root@www ~]# su - postgres
-bash-4.1$ ./analyze_new_cluster.sh
This script will generate minimal optimizer statistics rapidly
so your system is usable, and then gather statistics twice more
with increasing accuracy. When it is done, your system will
have the default level of optimizer statistics.
If you have used ALTER TABLE to modify the statistics target for
any tables, you might want to remove them and restore them after
running this script because they will delay fast statistics generation.
If you would like default statistics as quickly as possible, cancel
this script and run:
"/usr/pgsql-12/bin/vacuumdb" --all --analyze-only
....
Done
-bash-4.1$
exit
sudo service tomcat start
su - postgres
./delete_old_cluster.sh
yum remove postgresql94*
rm -rf /tmp/pgsql