Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #641 from google/postgres_upgrade
Browse files Browse the repository at this point in the history
* Upgrades PostGRES and PostGIS bundled utilities and libraries to newer versions.
  • Loading branch information
tst-ppenev authored Jan 9, 2018
2 parents 35bc306 + 8185820 commit f7a6442
Show file tree
Hide file tree
Showing 33 changed files with 485 additions and 1,027 deletions.
4 changes: 1 addition & 3 deletions earth_enterprise/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ installdirs = {
'server_lib': inst_server_dir('lib'),
'server_root': Dir('server/', installdir),
'server_share': inst_server_dir('share'),
'server_sql': inst_server_dir('share/opengee-server/sql'),

'httpd': inst_server_dir('gehttpd'),
'httpdmodules': inst_server_dir('gehttpd/modules'),
Expand All @@ -100,9 +101,6 @@ installdirs = {
'maps': inst_server_dir('gehttpd/htdocs/maps'),
'httpddocs': inst_server_dir('gehttpd/htdocs/shared_assets/docs'),


'getomcat_webapps': inst_server_dir('getomcat/webapps'),
'getomcat_lib': inst_server_dir('getomcat/lib'),
'search_plugins': inst_server_dir('search/plugins'),
'search_tabs': inst_server_dir('search/tabs'),
'search_api': inst_server_dir('search/api'),
Expand Down
20 changes: 20 additions & 0 deletions earth_enterprise/Upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Upgrading Earth Enterprise Fusion and Server to version 5.2.1

Upgrading to GEE 5.2.1 is supported from Earth Enterprise 5.2.0 version using the following steps:

1. Do NOT uninstall GEE 5.2.0. We recommend that you upgrade GEE 5.2.0 by simply installing GEE 5.2.1. Installing GEE 5.2.1 on top of GEE 5.2.0 will ensure that your PostgreSQL databases are backed up and upgraded correctly to the new PostgreSQL version used by GEE 5.2.1. [Install Fusion or Earth Server](https://github.com/google/earthenterprise/wiki/Install-Fusion-or-Earth-Server). This can be achieved by running the scripts to install fusion and earth server:

```bash
cd earth_enterprise/src/installer
sudo ./install_fusion.sh
sudo ./install_server.sh
```

Alternatively, instead of using scripts, on Redhat and Centos, you can upgrade GEE 5.2.0 to GEE 5.2.1 using [RPM packages](https://github.com/google/earthenterprise/blob/master/earth_enterprise/BUILD_RPMS.md)

1. If you decide that you want to uninstall GEE 5.2.0 before installing GEE 5.2.1, first make sure to backup your PostgreSQL databases. Please keep in mind that the database backup, made by 5.2.0, would not be compatible with GEE 5.2.1 PostgreSQL databases.

* Create a backup folder: `mkdir -p /tmp/MyBackupFolder`
* Make gepguser owner of the created folder: `chown gepguser /tmp/MyBackupFolder`
* Dump PostGreSQL databases using '/opt/google/bin/geresetpgdb' script. This script needs to be run under user 'gepguser'.
This can be achieved by switching to user 'gepguser' then executing: `/opt/google/bin/geresetpgdb backup /tmp/MyBackupFolder`
6 changes: 2 additions & 4 deletions earth_enterprise/geplaces/geplaces
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ then
exit 0
fi
$BINDIR/createdb -U geuser --owner=geuser geplaces
$BINDIR/createlang -U geuser plpgsql geplaces
$BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/postgis.sql 2>/dev/null >/dev/null
# $BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/postgis_upgrade.sql 2>/dev/null >/dev/null
$BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/spatial_ref_sys.sql 2>/dev/null >/dev/null
$BINDIR/psql -U geuser -d geplaces -c "CREATE EXTENSION postgis"

zcat $SHAREDIR/geplaces/geplaces_db.gz | $BINDIR/psql -q -U geuser -d geplaces 2>/dev/null >/dev/null

# Create new cities view
Expand Down
4 changes: 2 additions & 2 deletions earth_enterprise/geplaces/geplaces_db.gz
Git LFS file not shown
14 changes: 11 additions & 3 deletions earth_enterprise/rpms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def stagedInstallDir_server_geplaces =
new File(stagedInstallDir, 'geplaces/opt/google/share/geplaces')
def stagedInstallDir_server_user_magic =
new File(stagedInstallDir, 'server/user_magic')
def stagedInstallDir_server_version =
new File(stagedInstallDir, 'server/opt/google/gehttpd/htdocs/earth/gee_long_version.txt')
def stagedInstallDir_fusion = new File(stagedInstallDir, 'fusion')
def packageInstallRootDir = new File('/')

Expand Down Expand Up @@ -139,7 +141,7 @@ task stageOpenGeeInstall(type: Exec, dependsOn: 'compileOpenGee') {
task openGeePostGisRpm(type: GeeRpm) {
packageName = 'opengee-postgis'
release = "1.${rpmPlatformString}"
version = '1.5.8'
version = '2.3.4'
user = 'root'
permissionGroup = 'root'
packageGroup = 'Application/Productivity'
Expand Down Expand Up @@ -269,6 +271,8 @@ task openGeeCommonRpm(type: GeeRpm, dependsOn: openGeeSharedFiles) {
requires('chkconfig')
requires('shadow-utils')
requires('sudo')
conflicts('opengee-postgis', '2.0', LESS )
conflicts('opengee-postgis', '2.4', GREATER | EQUAL)

requiresCommands(packageSharedCommands +
['cat', 'cut', 'getent', 'grep' ])
Expand Down Expand Up @@ -341,8 +345,9 @@ task openGeeServerRpm (type: GeeRpm, dependsOn: openGeeSharedFiles) {
autoFindProvides = true
autoFindRequires = true

requires('opengee-postgis', '1.5.8', GREATER | EQUAL)
conflicts('opengee-postgis', '2.0', GREATER | EQUAL)
requires('opengee-postgis', '2.3.4', GREATER | EQUAL)
conflicts('opengee-postgis', '2.0', LESS )
conflicts('opengee-postgis', '2.4', GREATER | EQUAL)
requires('opengee-common', openGeeVersion, GREATER | EQUAL)
requiresPre('opengee-common', openGeeVersion, GREATER | EQUAL)

Expand All @@ -358,6 +363,9 @@ task openGeeServerRpm (type: GeeRpm, dependsOn: openGeeSharedFiles) {
// Prefix variable definitions to all install scripts:
installUtils = file('build/shared/install-utils.sh')

// Add geresetpgdb script:
installUtils = file(new File(stagedInstallDir_server_opt, 'google/bin/gepgcommon'))

preInstall = file('opengee-server/pre-install.sh')
postInstall = file('opengee-server/post-install.sh')
preUninstall = file('opengee-server/pre-uninstall.sh')
Expand Down
11 changes: 10 additions & 1 deletion earth_enterprise/rpms/opengee-server/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ umask 002
# Definitions
PUBLISHER_ROOT="/gevol/published_dbs"
INITSCRIPTUPDATE="/usr/sbin/update-rc.d"
PGSQL="/var/opt/google/pgsql"
PGSQL_DATA="/var/opt/google/pgsql/data"
PGSQL_LOGS="/var/opt/google/pgsql/logs"
PGSQL_PROGRAM="/opt/google/bin/pg_ctl"
Expand Down Expand Up @@ -170,7 +171,15 @@ fix_postinstall_filepermissions()
reset_pgdb()
{
# a) Always do an upgrade of the psql db
echo 2 | run_as_user "$GEPGUSER" "/opt/google/bin/geresetpgdb upgrade"
DB_BACKUP=""
DB_BACKUP_LATEST="$(ls -td -- $PGSQL/data.backup_dump*/ | head -n 1)"
echo "Latest backup: $DB_BACKUP_LATEST"
if [ -d "$DB_BACKUP_LATEST" ]; then
DB_BACKUP="$DB_BACKUP_LATEST"
echo "Restoring data backup from: $DB_BACKUP"
fi

echo 2 | run_as_user "$GEPGUSER" "/opt/google/bin/geresetpgdb upgrade $DB_BACKUP"
echo -e "upgrade done"

# b) Check for Success of PostGresDb
Expand Down
14 changes: 14 additions & 0 deletions earth_enterprise/rpms/opengee-server/pre-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ main_preinstall()
if [ "$NEW_INSTALL" = "true" ] ; then
check_username "$GEAPACHEUSER"
check_username "$GEPGUSER"

fi

# Dump database if it exists
database_backup

}

#-----------------------------------------------------------------
Expand All @@ -54,6 +59,15 @@ check_username()
# user already exists -- update primary group
usermod -g "$GEGROUP" "$1"
fi

}

database_backup()
{
# If the GEE data directory exists and PostgreSQL is installed
if [ -d "$BASEINSTALLDIR_VAR/pgsql/data" ] && [ -f "$BASEINSTALLDIR_OPT/bin/psql" ]; then
do_dump
fi
}

#-----------------------------------------------------------------
Expand Down
5 changes: 1 addition & 4 deletions earth_enterprise/searchexample/searchexample
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ then
exit 0
fi
$BINDIR/createdb -U geuser --owner=geuser searchexample
$BINDIR/createlang -U geuser plpgsql searchexample
$BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/postgis.sql 2>/dev/null >/dev/null
# $BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/postgis_upgrade.sql 2>/dev/null >/dev/null
$BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/spatial_ref_sys.sql 2>/dev/null >/dev/null
$BINDIR/psql -U geuser -d searchexample -c "CREATE EXTENSION postgis"
zcat $SHAREDIR/searchexample/searchexample_db.gz | $BINDIR/psql -q -U geuser -d searchexample 2>/dev/null >/dev/null
else
if [ $1 == "delete" ]
Expand Down
4 changes: 2 additions & 2 deletions earth_enterprise/searchexample/searchexample_db.gz
Git LFS file not shown
1 change: 1 addition & 0 deletions earth_enterprise/src/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ installdirs = {
'server_root': Dir('server/', installdir),
'server_share': InstServerDir('share'),
'server_search': InstServerDir('search'),
'server_sql': InstServerDir('share/opengee-server/sql'),

'httpd': InstServerDir('gehttpd'),
'httpdmodules': InstServerDir('gehttpd/modules'),
Expand Down
Loading

0 comments on commit f7a6442

Please sign in to comment.