Omaha #3475 - PostgreSQL Upgrade.
amend: vacuum databases after upgrade due to: http://www.postgresql.org/docs/9.3/static/release-9-3-2.html E.4.2 VACUUM tests amend: update viz xdat to use the newer PostgreSQL jdbc driver amend: fix formatting Change-Id: Icda3348eea3e5edd879acb3a897bc530e73fb7f3 Former-commit-id:b805f1db0d
[formerly3d68ae0c78
] [formerlyf6bc96829e
] [formerlya2be914331
[formerlyf6bc96829e
[formerly 426a8c8863ea6be7d6795ace387c214ce3b36790]]] Former-commit-id:a2be914331
Former-commit-id: 7264efe3b00ab6cbe7db1240eea4304e54781900 [formerly0894026a79
] Former-commit-id:c15190b7f6
This commit is contained in:
parent
7a20ac041a
commit
69a0dce7cb
23 changed files with 468 additions and 52 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#Thu Mar 26 11:17:23 CDT 2009
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
|
@ -10,9 +10,9 @@ Require-Bundle: org.eclipse.ui,
|
||||||
com.raytheon.uf.viz.core,
|
com.raytheon.uf.viz.core,
|
||||||
com.raytheon.viz.ui,
|
com.raytheon.viz.ui,
|
||||||
com.raytheon.viz.hydrocommon;bundle-version="1.10.13",
|
com.raytheon.viz.hydrocommon;bundle-version="1.10.13",
|
||||||
org.postgres;bundle-version="1.0.0"
|
org.postgres;bundle-version="9.3.5"
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||||
Import-Package: com.raytheon.uf.common.ohd,
|
Import-Package: com.raytheon.uf.common.ohd,
|
||||||
com.raytheon.uf.common.time,
|
com.raytheon.uf.common.time,
|
||||||
com.raytheon.uf.common.util
|
com.raytheon.uf.common.util
|
||||||
|
|
|
@ -59,6 +59,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
|
||||||
* 16 Jan 2009 1883 Venable & Updated database calls and query methods.
|
* 16 Jan 2009 1883 Venable & Updated database calls and query methods.
|
||||||
* Duff
|
* Duff
|
||||||
* 10 Feb 2009 wkwock Added functions and clean up.
|
* 10 Feb 2009 wkwock Added functions and clean up.
|
||||||
|
* 12 Aug 2014 3049 bkowal Close the BufferedReader when finished.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author wkwock
|
* @author wkwock
|
||||||
|
@ -708,13 +709,12 @@ public class XdatDB {
|
||||||
if (peMap == null) {
|
if (peMap == null) {
|
||||||
peMap = new HashMap<String, String>();
|
peMap = new HashMap<String, String>();
|
||||||
String line = null;
|
String line = null;
|
||||||
|
|
||||||
String xdatDir = AppsDefaults.getInstance().getToken("xdat_params");
|
String xdatDir = AppsDefaults.getInstance().getToken("xdat_params");
|
||||||
File file = new File(xdatDir + File.separator + "pe_map");
|
File file = new File(xdatDir + File.separator + "pe_map");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try (BufferedReader br = new BufferedReader(
|
||||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
new FileReader(file));) {
|
||||||
|
|
||||||
while (null != (line = br.readLine())) {
|
while (null != (line = br.readLine())) {
|
||||||
if (line.trim().equals("")) {
|
if (line.trim().equals("")) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -726,8 +726,8 @@ public class XdatDB {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statusHandler.handle(Priority.ERROR, "pe_map file not found. " +
|
statusHandler.handle(Priority.ERROR, "pe_map file not found. "
|
||||||
"Check for file in " + file.getParent());
|
+ "Check for file in " + file.getParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,226 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source settings.sh
|
||||||
|
|
||||||
|
if [ -z "${AWIPS2_DATA_DIRECTORY}" ]; then
|
||||||
|
echo "ERROR: AWIPS2_DATA_DIRECTORY must be set in settings.sh!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SQL_SHARE_DIR=${DATABASE_INSTALL}/sqlScripts/share/sql
|
||||||
|
SQL_MAPS_SHARE_DIR=${SQL_SHARE_DIR}/maps
|
||||||
|
|
||||||
|
# This Is The Log File That We Will Use To Log All SQL Interactions.
|
||||||
|
SQL_LOG=${SQL_SHARE_DIR}/sql_upgrade.log
|
||||||
|
|
||||||
|
# Add The PostgreSQL Libraries And The PSQL Libraries To LD_LIBRARY_PATH.
|
||||||
|
export LD_LIBRARY_PATH=${POSTGRESQL_INSTALL}/lib:$LD_LIBRARY_PATH
|
||||||
|
export LD_LIBRARY_PATH=${PSQL_INSTALL}/lib:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
function create_sql_element()
|
||||||
|
{
|
||||||
|
# $1 == element
|
||||||
|
|
||||||
|
mkdir -p ${1}
|
||||||
|
update_owner ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_owner()
|
||||||
|
{
|
||||||
|
# $1 == element
|
||||||
|
chown ${POSTGRESQL_USER} ${1}
|
||||||
|
chgrp ${AWIPS_DEFAULT_GROUP} ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_db()
|
||||||
|
{
|
||||||
|
su ${POSTGRESQL_USER} -c \
|
||||||
|
"${POSTGRESQL_INSTALL}/bin/initdb --auth=trust --locale=en_US.UTF-8 --pgdata=${AWIPS2_DATA_DIRECTORY} --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "init_db has failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function control_pg_ctl()
|
||||||
|
{
|
||||||
|
# $1 == pg_ctl command
|
||||||
|
su ${POSTGRESQL_USER} -c \
|
||||||
|
"${POSTGRESQL_INSTALL}/bin/pg_ctl ${1} -D ${AWIPS2_DATA_DIRECTORY} -o \"-p ${POSTGRESQL_PORT}\" -w"
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_initial_sql_script()
|
||||||
|
{
|
||||||
|
# Make The Necessary Replacements In The Script.
|
||||||
|
perl -p -i -e "s/%{databaseUsername}/${POSTGRESQL_USER}/g" \
|
||||||
|
${1}
|
||||||
|
echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp
|
||||||
|
AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp`
|
||||||
|
rm -f .awips2_escape.tmp
|
||||||
|
perl -p -i -e "s/%{database_files_home}/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \
|
||||||
|
${1}
|
||||||
|
|
||||||
|
# $1 == script to execute
|
||||||
|
su ${POSTGRESQL_USER} -c \
|
||||||
|
"${PSQL_INSTALL}/bin/psql -d postgres -U ${POSTGRESQL_USER} -q -p ${POSTGRESQL_PORT} -f ${1}" \
|
||||||
|
> ${SQL_LOG} 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Initial Database Setup has failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_createDamcat()
|
||||||
|
{
|
||||||
|
echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp
|
||||||
|
AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp`
|
||||||
|
rm -f .awips2_escape.tmp
|
||||||
|
perl -p -i -e "s/%{database_files_home}%/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \
|
||||||
|
${SQL_SHARE_DIR}/createDamcat.sql
|
||||||
|
}
|
||||||
|
|
||||||
|
function createDamcatTablespace()
|
||||||
|
{
|
||||||
|
local sql_script="damcat.sql"
|
||||||
|
local current_location=`pwd`
|
||||||
|
|
||||||
|
touch ${sql_script}
|
||||||
|
|
||||||
|
echo "DROP TABLESPACE IF EXISTS damcat;" > ${sql_script}
|
||||||
|
echo "CREATE TABLESPACE damcat OWNER awips LOCATION '/awips2/data/damcat';" >> ${sql_script}
|
||||||
|
echo "COMMENT ON TABLESPACE damcat IS 'DAMCAT Database tablespace';" >> ${sql_script}
|
||||||
|
|
||||||
|
execute_psql_sql_script ${current_location}/${sql_script} postgres
|
||||||
|
|
||||||
|
rm -f ${current_location}/${sql_script}
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_createEbxml()
|
||||||
|
{
|
||||||
|
echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp
|
||||||
|
AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp`
|
||||||
|
rm -f .awips2_escape.tmp
|
||||||
|
perl -p -i -e "s/%{database_files_home}%/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \
|
||||||
|
${SQL_SHARE_DIR}/createEbxml.sql
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_createHMDB()
|
||||||
|
{
|
||||||
|
echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp
|
||||||
|
AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp`
|
||||||
|
rm -f .awips2_escape.tmp
|
||||||
|
perl -p -i -e "s/%{database_files_home}%/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \
|
||||||
|
${SQL_SHARE_DIR}/createHMDB.sql
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_createMaps()
|
||||||
|
{
|
||||||
|
echo ${AWIPS2_DATA_DIRECTORY} | sed 's/\//\\\//g' > .awips2_escape.tmp
|
||||||
|
AWIPS2_DATA_DIRECTORY_ESCAPED=`cat .awips2_escape.tmp`
|
||||||
|
rm -f .awips2_escape.tmp
|
||||||
|
# Update the sql script that creates the maps database / tables.
|
||||||
|
perl -p -i -e "s/%{database_files_home}%/${AWIPS2_DATA_DIRECTORY_ESCAPED}/g" \
|
||||||
|
${SQL_MAPS_SHARE_DIR}/createMapsDb.sql
|
||||||
|
}
|
||||||
|
|
||||||
|
function execute_psql_sql_script()
|
||||||
|
{
|
||||||
|
# $1 == script to execute
|
||||||
|
# $2 == database
|
||||||
|
|
||||||
|
su ${POSTGRESQL_USER} -c \
|
||||||
|
"${PSQL_INSTALL}/bin/psql -d ${2} -U ${POSTGRESQL_USER} -q -p ${POSTGRESQL_PORT} -f \"${1}\"" \
|
||||||
|
>> ${SQL_LOG} 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to execute SQL script: ${1}!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#temporarily relocate the PostgreSQL configuration
|
||||||
|
_BACKUP_CONF=/awips2/postgresql-configuration-bak
|
||||||
|
if [ -d ${_BACKUP_CONF} ]; then
|
||||||
|
rm -rf ${_BACKUP_CONF}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mkdir -p ${_BACKUP_CONF}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
POSTGRESQL_CONFIGURATION=( 'pg_hba.conf' 'pg_ident.conf' 'postgresql.conf' )
|
||||||
|
for configuration in ${POSTGRESQL_CONFIGURATION[*]};
|
||||||
|
do
|
||||||
|
mv ${AWIPS2_DATA_DIRECTORY}/${configuration} \
|
||||||
|
${_BACKUP_CONF}/${configuration}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# purge the existing data directory
|
||||||
|
if [ -d ${AWIPS2_DATA_DIRECTORY} ]; then
|
||||||
|
rm -rf ${AWIPS2_DATA_DIRECTORY}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mkdir ${AWIPS2_DATA_DIRECTORY}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
init_db
|
||||||
|
|
||||||
|
control_pg_ctl "start"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: Failed to start PostgreSQL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
create_sql_element ${METADATA}
|
||||||
|
create_sql_element ${IFHS}
|
||||||
|
create_sql_element ${DAMCAT}
|
||||||
|
create_sql_element ${HMDB}
|
||||||
|
create_sql_element ${EBXML}
|
||||||
|
create_sql_element ${MAPS}
|
||||||
|
|
||||||
|
execute_initial_sql_script ${SQL_SHARE_DIR}/initial_setup_server.sql
|
||||||
|
|
||||||
|
execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata
|
||||||
|
|
||||||
|
createDamcatTablespace
|
||||||
|
|
||||||
|
update_createHMDB
|
||||||
|
execute_psql_sql_script ${SQL_SHARE_DIR}/createHMDB.sql postgres
|
||||||
|
|
||||||
|
update_createEbxml
|
||||||
|
execute_psql_sql_script ${SQL_SHARE_DIR}/createEbxml.sql postgres
|
||||||
|
|
||||||
|
control_pg_ctl "stop"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "WARNING: Failed to stop PostgreSQL!"
|
||||||
|
else
|
||||||
|
sleep 20
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restore the PostgreSQL configuration
|
||||||
|
for configuration in ${POSTGRESQL_CONFIGURATION[*]};
|
||||||
|
do
|
||||||
|
mv ${_BACKUP_CONF}/${configuration} \
|
||||||
|
${AWIPS2_DATA_DIRECTORY}/${configuration}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf ${_BACKUP_CONF}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "WARNING: Failed to Remove - ${_BACKUP_CONF}!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,99 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source settings.sh
|
||||||
|
|
||||||
|
# make a temporary update to the postgresql.conf file for the db vacuums
|
||||||
|
pushd . > /dev/null 2>&1
|
||||||
|
cd ${AWIPS2_DATA_DIRECTORY}
|
||||||
|
|
||||||
|
# backup the existing postgresql.conf
|
||||||
|
cp postgresql.conf postgresql.conf.orig
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to create a temporary backup of postgresql.conf!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create an updated postgresql.conf
|
||||||
|
sed '/vacuum_freeze_table_age/d' postgresql.conf > postgresql.conf.update
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to update postgresql.conf!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "vacuum_freeze_table_age = 0" >> postgresql.conf.update
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to update postgresql.conf!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv postgresql.conf.update postgresql.conf
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to update postgresql.conf!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd > /dev/null 2>&1
|
||||||
|
|
||||||
|
# start PostgreSQL
|
||||||
|
/sbin/service edex_postgres start
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: Failed to start PostgreSQL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
# look at the standard PostgreSQL database exports
|
||||||
|
for database_export in `ls -1 *.db`;
|
||||||
|
do
|
||||||
|
echo "Restoring database '${database_export}' ..."
|
||||||
|
${PG_RESTORE} -C -d postgres -U ${POSTGRESQL_USER} ${database_export} >> errors.txt 2>&1
|
||||||
|
|
||||||
|
database=`basename ${database_export} .db`
|
||||||
|
|
||||||
|
# vaccum the database
|
||||||
|
${VACUUMDB} -d ${database} -U ${POSTGRESQL_USER} -p ${POSTGRESQL_PORT} -vz >> errors.txt 2>&1
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
# look at the postgis enabled PostgreSQL database exports
|
||||||
|
for database_export in `ls -1 *.db.postgis`;
|
||||||
|
do
|
||||||
|
echo "Performing a postgis restoration of database '${database_export}' ..."
|
||||||
|
|
||||||
|
# restore the database
|
||||||
|
${PG_RESTORE} -C -d postgres -U ${POSTGRESQL_USER} ${database_export} >> errors.txt 2>&1
|
||||||
|
# vacuum the database.
|
||||||
|
|
||||||
|
database=`basename ${database_export} .db.postgis`
|
||||||
|
|
||||||
|
# vaccum the database
|
||||||
|
${VACUUMDB} -d ${database} -U ${POSTGRESQL_USER} -p ${POSTGRESQL_PORT} -vz >> errors.txt 2>&1
|
||||||
|
|
||||||
|
/bin/bash run_postgis_upgrade.sh ${database}
|
||||||
|
done
|
||||||
|
|
||||||
|
# stop PostgreSQL
|
||||||
|
/sbin/service edex_postgres stop
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "WARNING: Failed to stop PostgreSQL."
|
||||||
|
else
|
||||||
|
sleep 20
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restore the original postgresql.conf
|
||||||
|
pushd . > /dev/null 2>&1
|
||||||
|
cd ${AWIPS2_DATA_DIRECTORY}
|
||||||
|
|
||||||
|
cp -f postgresql.conf.orig postgresql.conf
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to restore postgresql.conf. Original version is: ${AWIPS2_DATA_DIRECTORY}/postgresql.conf.orig"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f postgresql.conf.orig
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to remove backup postgresql.conf. Backup is: ${AWIPS2_DATA_DIRECTORY}/postgresql.conf.orig"
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd > /dev/null 2>&1
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source settings.sh
|
||||||
|
|
||||||
|
# start PostgreSQL
|
||||||
|
/sbin/service edex_postgres start
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: Failed to start PostgreSQL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
# get a list of the databases
|
||||||
|
|
||||||
|
# consider using the SQL query? ...
|
||||||
|
dbList=( $( psql --tuples-only -U awips -l | cut -f1 -d'|' | sed -e "s/^[[:space:]]*//g" -e "s/[[:space:]]*$//g" | grep -vE "template[01]|postgres|awips" ) )
|
||||||
|
|
||||||
|
# export the databases
|
||||||
|
for database in ${dbList[*]};
|
||||||
|
do
|
||||||
|
echo "exporting database '${database}' ..."
|
||||||
|
|
||||||
|
# determine if the database is postgis-enabled?
|
||||||
|
# postgis-enabled PostgreSQL databases include one or both of the following tables:
|
||||||
|
# { spatial_ref_sys, geometry_columns }
|
||||||
|
_SQL_="SELECT COUNT(*) FROM pg_catalog.pg_tables WHERE tablename IN ( 'spatial_ref_sys', 'geometry_columns' );"
|
||||||
|
COUNT=`${PSQL} -U ${POSTGRESQL_USER} -p ${POSTGRESQL_PORT} -d ${database} -t -c "${_SQL_}"`
|
||||||
|
|
||||||
|
# determine the suffix of the database export
|
||||||
|
_export_suffix=".db"
|
||||||
|
if [ ${COUNT} -ne 0 ]; then
|
||||||
|
_export_suffix="${_export_suffix}.postgis"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${PG_DUMP} -Fc ${database} -U ${POSTGRESQL_USER} -p ${POSTGRESQL_PORT} > ${database}${_export_suffix}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# at this point, we know that the database export was successful; so, we will now be dropping
|
||||||
|
# every database that was previously identified.
|
||||||
|
for database in ${dbList[*]};
|
||||||
|
do
|
||||||
|
echo "dropping database '${database}' ..."
|
||||||
|
|
||||||
|
${DROPDB} ${database} -U ${POSTGRESQL_USER} -p ${POSTGRESQL_PORT}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# start PostgreSQL
|
||||||
|
/sbin/service edex_postgres stop
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "WARNING: Failed to stop PostgreSQL."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
sleep 20
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source settings.sh
|
||||||
|
|
||||||
|
POSTGIS_UPGRADE=${POSTGIS_CONTRIB}/postgis_upgrade_20_minor.sql
|
||||||
|
RTPOSTGIS_UPGRADE=${POSTGIS_CONTRIB}/rtpostgis_upgrade_20_minor.sql
|
||||||
|
TOPOLOGY_UPGRADE=${POSTGIS_CONTRIB}/topology_upgrade_20_minor.sql
|
||||||
|
|
||||||
|
echo "=== postgis upgrade ===" >> errors.txt
|
||||||
|
${PSQL} -U ${POSTGRESQL_USER} -f ${POSTGIS_UPGRADE} -d ${1} >> errors.txt 2>&1
|
||||||
|
|
||||||
|
echo "=== rtpostgis upgrade ===" >> errors.txt
|
||||||
|
${PSQL} -U ${POSTGRESQL_USER} -f ${RTPOSTGIS_UPGRADE} -d ${1} >> errors.txt 2>&1
|
||||||
|
|
||||||
|
echo "=== topology upgrade ===" >> errors.txt
|
||||||
|
${PSQL} -U ${POSTGRESQL_USER} -f ${TOPOLOGY_UPGRADE} -d ${1} >> errors.txt 2>&1
|
||||||
|
|
||||||
|
exit 0
|
30
deltaScripts/14.4.1/DR3049/postgresql9.3-upgrade/settings.sh
Normal file
30
deltaScripts/14.4.1/DR3049/postgresql9.3-upgrade/settings.sh
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# database ownership
|
||||||
|
POSTGRESQL_PORT=5432
|
||||||
|
POSTGRESQL_USER=awips
|
||||||
|
AWIPS_DEFAULT_GROUP="fxalpha"
|
||||||
|
|
||||||
|
# AWIPS II installations
|
||||||
|
POSTGRESQL_INSTALL="/awips2/postgresql"
|
||||||
|
PSQL_INSTALL="/awips2/psql"
|
||||||
|
AWIPS2_DATA_DIRECTORY="/awips2/data"
|
||||||
|
DATABASE_INSTALL="/awips2/database"
|
||||||
|
|
||||||
|
# SQL Data Directories
|
||||||
|
METADATA=${AWIPS2_DATA_DIRECTORY}/metadata
|
||||||
|
IFHS=${AWIPS2_DATA_DIRECTORY}/pgdata_ihfs
|
||||||
|
MAPS=${AWIPS2_DATA_DIRECTORY}/maps
|
||||||
|
DAMCAT=${AWIPS2_DATA_DIRECTORY}/damcat
|
||||||
|
HMDB=${AWIPS2_DATA_DIRECTORY}/hmdb
|
||||||
|
EBXML=${AWIPS2_DATA_DIRECTORY}/ebxml
|
||||||
|
|
||||||
|
# paths
|
||||||
|
POSTGIS_CONTRIB=${POSTGRESQL_INSTALL}/share/contrib/postgis-2.0
|
||||||
|
|
||||||
|
# executables
|
||||||
|
PERL=/usr/bin/perl
|
||||||
|
PG_RESTORE=${POSTGRESQL_INSTALL}/bin/pg_restore
|
||||||
|
PG_DUMP=${POSTGRESQL_INSTALL}/bin/pg_dump
|
||||||
|
DROPDB=${POSTGRESQL_INSTALL}/bin/dropdb
|
||||||
|
VACUUMDB=${POSTGRESQL_INSTALL}/bin/vacuumdb
|
||||||
|
POSTGIS_RESTORE=${POSTGIS_CONTRIB}/postgis_restore.pl
|
||||||
|
PSQL=${PSQL_INSTALL}/bin/psql
|
|
@ -49,8 +49,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${PSQLBINDIR}/psql -d postgres -U $PGUSER -q -p $PGPORT -f ${DATABASEDIR}/createMapsDb.sql
|
${PSQLBINDIR}/psql -d postgres -U $PGUSER -q -p $PGPORT -f ${DATABASEDIR}/createMapsDb.sql
|
||||||
${PSQLBINDIR}/psql -d maps -U $PGUSER -q -p $PGPORT -f ${POSTGIS_CONTRIB}/postgis.sql
|
${PSQLBINDIR}/psql -d maps -U $PGUSER -q -p $PGPORT -c "CREATE EXTENSION postgis;"
|
||||||
${PSQLBINDIR}/psql -d maps -U $PGUSER -q -p $PGPORT -f ${POSTGIS_CONTRIB}/spatial_ref_sys.sql
|
${PSQLBINDIR}/psql -d maps -U $PGUSER -q -p $PGPORT -c "CREATE EXTENSION postgis_topology;"
|
||||||
|
${PSQLBINDIR}/psql -d maps -U $PGUSER -q -p $PGPORT -f ${POSTGIS_CONTRIB}/legacy.sql
|
||||||
if [ -f ${DATABASEDIR}/maps.db ] ; then
|
if [ -f ${DATABASEDIR}/maps.db ] ; then
|
||||||
${PSQLBINDIR}/psql -d maps -U ${PGUSER} -q -p ${PGPORT} -c "DROP TABLE IF EXISTS mapdata.map_version"
|
${PSQLBINDIR}/psql -d maps -U ${PGUSER} -q -p ${PGPORT} -c "DROP TABLE IF EXISTS mapdata.map_version"
|
||||||
${PGBINDIR}/pg_restore -d maps -U $PGUSER -p $PGPORT -n mapdata ${DATABASEDIR}/maps.db
|
${PGBINDIR}/pg_restore -d maps -U $PGUSER -p $PGPORT -n mapdata ${DATABASEDIR}/maps.db
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
COPY stns.CPCSTNS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LONGITUDE, ELEVATION, PRI) FROM stdin with delimiter as ',';
|
COPY stns.CPCSTNS(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LONGITUDE, ELEV, PRI) FROM stdin with delimiter as ',';
|
||||||
1,ABI,72266,ABILENE,TX,US,32.5,-99.7,0,0
|
1,ABI,72266,ABILENE,TX,US,32.5,-99.7,0,0
|
||||||
2,ABQ,72365,ALBUQUERQUE_INTL,NM,US,35.05,-106.62,1620,0
|
2,ABQ,72365,ALBUQUERQUE_INTL,NM,US,35.05,-106.62,1620,0
|
||||||
3,ADK,70454,ADAK_NAS/MITCHELL,AK,US,51.88,-176.65,4,0
|
3,ADK,70454,ADAK_NAS/MITCHELL,AK,US,51.88,-176.65,4,0
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
COPY stns.DLWX(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LONGITUDE, ELEVATION, PRI) FROM stdin with delimiter as ',';
|
COPY stns.DLWX(PKEY, STATION_ID, STATION_NUM, NAME, STATE, COUNTRY, LATITUDE, LONGITUDE, ELEV, PRI) FROM stdin with delimiter as ',';
|
||||||
1,EYW,722010,KEY_WEST_INTL_ARPT_(ASOS),FL,US,24.55,-81.75,6,99
|
1,EYW,722010,KEY_WEST_INTL_ARPT_(ASOS),FL,US,24.55,-81.75,6,99
|
||||||
2,MIA,722020,MIAMI_INTL_AIRPORT_(ASOS),FL,US,25.82,-80.28,4,99
|
2,MIA,722020,MIAMI_INTL_AIRPORT_(ASOS),FL,US,25.82,-80.28,4,99
|
||||||
3,MCO,722050,ORLANDO_JETPORT___(ASOS),FL,US,28.43,-81.32,32,99
|
3,MCO,722050,ORLANDO_JETPORT___(ASOS),FL,US,28.43,-81.32,32,99
|
||||||
|
|
|
@ -268,9 +268,8 @@ fi
|
||||||
|
|
||||||
execute_initial_sql_script ${SQL_SHARE_DIR}/initial_setup_server.sql
|
execute_initial_sql_script ${SQL_SHARE_DIR}/initial_setup_server.sql
|
||||||
|
|
||||||
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/postgis.sql metadata
|
/awips2/psql/bin/psql -U awips -d metadata -c "CREATE EXTENSION postgis;"
|
||||||
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/spatial_ref_sys.sql metadata
|
/awips2/psql/bin/psql -U awips -d metadata -c "CREATE EXTENSION postgis_topology;"
|
||||||
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/rtpostgis.sql metadata
|
|
||||||
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/legacy.sql metadata
|
execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/legacy.sql metadata
|
||||||
execute_psql_sql_script ${SQL_SHARE_DIR}/permissions.sql metadata
|
execute_psql_sql_script ${SQL_SHARE_DIR}/permissions.sql metadata
|
||||||
execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata
|
execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata
|
||||||
|
|
|
@ -168,30 +168,19 @@ if [ "${MAPS_DB_EXISTS}" = "false" ]; then
|
||||||
printFailureMessage
|
printFailureMessage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/postgis.sql"
|
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
|
"${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1
|
||||||
RC=$?
|
if [ $? -ne 0 ]; then
|
||||||
if [ ! "${RC}" -eq 0 ]; then
|
|
||||||
printFailureMessage
|
printFailureMessage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/spatial_ref_sys.sql"
|
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
|
"${PSQL} -d maps -U awips -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1
|
||||||
RC=$?
|
if [ $? -ne 0 ]; then
|
||||||
if [ ! "${RC}" -eq 0 ]; then
|
|
||||||
printFailureMessage
|
|
||||||
fi
|
|
||||||
|
|
||||||
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/rtpostgis.sql"
|
|
||||||
su ${DB_OWNER} -c \
|
|
||||||
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
|
|
||||||
RC=$?
|
|
||||||
if [ ! "${RC}" -eq 0 ]; then
|
|
||||||
printFailureMessage
|
printFailureMessage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Do we still need legacy?
|
||||||
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/legacy.sql"
|
SQL_FILE="/awips2/postgresql/share/contrib/postgis-2.0/legacy.sql"
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
|
"${PSQL} -d maps -U awips -q -p 5432 -f ${SQL_FILE}" >> ${SQL_LOG} 2>&1
|
||||||
|
|
|
@ -71,7 +71,6 @@ if [ "${1}" = "2" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
POSTGRESQL_INSTALL="/awips2/postgresql"
|
POSTGRESQL_INSTALL="/awips2/postgresql"
|
||||||
# Need this for the lwpostgis.sql and spatial_ref_sys.sql scripts
|
|
||||||
DATABASE_INSTALL="/awips2/database"
|
DATABASE_INSTALL="/awips2/database"
|
||||||
AWIPS2_DATA_DIRECTORY="/awips2/data"
|
AWIPS2_DATA_DIRECTORY="/awips2/data"
|
||||||
PSQL_INSTALL="/awips2/psql"
|
PSQL_INSTALL="/awips2/psql"
|
||||||
|
@ -86,8 +85,6 @@ DB_OWNER=`ls -ld ${AWIPS2_DATA_DIRECTORY} | grep -w 'data' | awk '{print $3}'`
|
||||||
# Our log file
|
# Our log file
|
||||||
SQL_LOG="${DATABASE_INSTALL}/sqlScripts/share/sql/ncep/ncep_sql_install.log"
|
SQL_LOG="${DATABASE_INSTALL}/sqlScripts/share/sql/ncep/ncep_sql_install.log"
|
||||||
SQL_SHARE_DIR="${DATABASE_INSTALL}/sqlScripts/share/sql/ncep"
|
SQL_SHARE_DIR="${DATABASE_INSTALL}/sqlScripts/share/sql/ncep"
|
||||||
LWPOSTGIS_SQL="/awips2/postgresql/share/contrib/postgis-2.0/postgis.sql"
|
|
||||||
SPATIAL_SQL="/awips2/postgresql/share/contrib/postgis-2.0/spatial_ref_sys.sql"
|
|
||||||
LEGACY_SQL="/awips2/postgresql/share/contrib/postgis-2.0/legacy.sql"
|
LEGACY_SQL="/awips2/postgresql/share/contrib/postgis-2.0/legacy.sql"
|
||||||
|
|
||||||
# Determine if PostgreSQL is running.
|
# Determine if PostgreSQL is running.
|
||||||
|
@ -149,12 +146,12 @@ su ${DB_OWNER} -c \
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepSchemas.sql" \
|
"${PSQL} -d postgres -U awips -q -p 5432 -f ${SQL_SHARE_DIR}/createNcepSchemas.sql" \
|
||||||
>> ${SQL_LOG} 2>&1
|
>> ${SQL_LOG} 2>&1
|
||||||
|
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d ncep -U awips -q -p 5432 -f ${LWPOSTGIS_SQL}" \
|
"${PSQL} -d ncep -U awips -q -p 5432 -c \"CREATE EXTENSION postgis;\"" >> ${SQL_LOG} 2>&1
|
||||||
>> ${SQL_LOG} 2>&1
|
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d ncep -U awips -q -p 5432 -f ${SPATIAL_SQL}" \
|
"${PSQL} -d ncep -U awips -q -p 5432 -c \"CREATE EXTENSION postgis_topology;\"" >> ${SQL_LOG} 2>&1
|
||||||
>> ${SQL_LOG} 2>&1
|
|
||||||
su ${DB_OWNER} -c \
|
su ${DB_OWNER} -c \
|
||||||
"${PSQL} -d ncep -U awips -q -p 5432 -f ${LEGACY_SQL}" \
|
"${PSQL} -d ncep -U awips -q -p 5432 -f ${LEGACY_SQL}" \
|
||||||
>> ${SQL_LOG} 2>&1
|
>> ${SQL_LOG} 2>&1
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
%define _build_arch %(uname -i)
|
%define _build_arch %(uname -i)
|
||||||
%define _pgadmin3_version 1.16.1
|
%define _pgadmin3_version 1.18.1
|
||||||
%define _pgadmin3_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
%define _pgadmin3_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Binary file not shown.
BIN
rpms/awips2.core/Installer.postgres/SOURCES/postgis-2.0.6.tar.gz
Normal file
BIN
rpms/awips2.core/Installer.postgres/SOURCES/postgis-2.0.6.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
%define _build_arch %(uname -i)
|
%define _build_arch %(uname -i)
|
||||||
%define _postgresql_version 9.2.4
|
%define _postgresql_version 9.3.5
|
||||||
%define _postgres_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
%define _postgres_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
#
|
#
|
||||||
# AWIPS II PostgreSQL Spec File
|
# AWIPS II PostgreSQL Spec File
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
Name: awips2-postgresql
|
Name: awips2-postgresql
|
||||||
Summary: AWIPS II PostgreSQL Distribution
|
Summary: AWIPS II PostgreSQL Distribution
|
||||||
Version: %{_postgresql_version}
|
Version: %{_postgresql_version}
|
||||||
Release: 2.el6
|
Release: 1.el6
|
||||||
Group: AWIPSII
|
Group: AWIPSII
|
||||||
BuildRoot: %{_build_root}
|
BuildRoot: %{_build_root}
|
||||||
BuildArch: %{_build_arch}
|
BuildArch: %{_build_arch}
|
||||||
|
@ -149,13 +149,13 @@ fi
|
||||||
|
|
||||||
SRC_DIR="%{_baseline_workspace}/rpms/awips2.core/Installer.postgres/SOURCES"
|
SRC_DIR="%{_baseline_workspace}/rpms/awips2.core/Installer.postgres/SOURCES"
|
||||||
PROJ_SRC="proj-4.8.0.zip"
|
PROJ_SRC="proj-4.8.0.zip"
|
||||||
POSTGIS_SRC="postgis-2.0.2.tar.gz"
|
POSTGIS_SRC="postgis-2.0.6.tar.gz"
|
||||||
GEOS_SRC="geos-3.3.7.tar.bz2"
|
GEOS_SRC="geos-3.3.7.tar.bz2"
|
||||||
GDAL_SRC="gdal192.zip"
|
GDAL_SRC="gdal192.zip"
|
||||||
|
|
||||||
# The directory that the src will be in after the tars are unzipped.
|
# The directory that the src will be in after the tars are unzipped.
|
||||||
PROJ_SRC_DIR="proj-4.8.0"
|
PROJ_SRC_DIR="proj-4.8.0"
|
||||||
POSTGIS_SRC_DIR="postgis-2.0.2"
|
POSTGIS_SRC_DIR="postgis-2.0.6"
|
||||||
GEOS_SRC_DIR="geos-3.3.7"
|
GEOS_SRC_DIR="geos-3.3.7"
|
||||||
GDAL_SRC_DIR="gdal-1.9.2"
|
GDAL_SRC_DIR="gdal-1.9.2"
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
20140430
|
20140807
|
||||||
|
|
Loading…
Add table
Reference in a new issue