To prepare for upgrading the HDP Stack, perform the following tasks:
Disable Security.
Important If your Stack has Kerberos Security turned on, disable Kerberos before performing the Stack upgrade. On
Ambari Web UI > Admin > Security
, click Disable Kerberos. You can re-enable Kerberos Security after performing the upgrade.Checkpoint user metadata and capture the HDFS operational state.
This step supports rollback and restore of the original state of HDFS data, if necessary.
Backup Hive and Oozie metastore databases.
This step supports rollback and restore of the original state of Hive and Oozie data, if necessary.
Stop all HDP and Ambari services.
Make sure to finish all current jobs running on the system before upgrading the stack.
Note | |
---|---|
Libraries will change during the upgrade. Any jobs remaining active that use the older version libraries will probably fail during the upgrade. |
Use Ambari Web, browse to
Services
. Go thru each service and in theService Actions
menu, selectStop All
, except for HDFS and ZooKeeper.Stop any client programs that access HDFS.
Perform steps 3 through 8 on the NameNode host. In a highly-available NameNode configuration, execute the following procedure on the primary NameNode.
Note To locate the primary NameNode in an Ambari-managed HDP cluster, browse
Ambari Web > Services > HDFS.
In Summary, click NameNode.Hosts > Summary
displays the host name FQDN.If HDFS is in a non-finalized state from a prior upgrade operation, you must finalize HDFS before upgrading further. Finalizing HDFS will remove all links to the metadata of the prior HDFS version. Do this only if you do not want to rollback to that prior HDFS version.
On the NameNode host, as the HDFS user,
su -l <HDFS_USER> hdfs dfsadmin -finalizeUpgrade
where<HDFS_USER>
is the HDFS Service user. For example, hdfs.Check the NameNode directory to ensure that there is no snapshot of any prior HDFS upgrade.
Specifically, using
Ambari Web > HDFS > Configs > NameNode
, examine the<dfs.namenode.name.dir>
or the<dfs.name.dir>
directory in the NameNode Directories property. Make sure that only a "\current" directory and no "\previous" directory exists on the NameNode host.Create the following logs and other files.
Creating these logs allows you to check the integrity of the file system, post-upgrade.
As the HDFS user,
su -l
<HDFS_USER>
where<HDFS_USER>
is the HDFS Service user. For example, hdfs.Run
fsck
with the following flags and send the results to a log.The resulting file contains a complete block map of the file system. You use this log later to confirm the upgrade.
hdfs fsck / -files -blocks -locations > dfs-old-fsck-1.log
Optional: Capture the complete namespace of the file system.
The following command does a recursive listing of the root file system:
hadoop dfs -ls -R / > dfs-old-lsr-1.log
Create a list of all the DataNodes in the cluster.
hdfs dfsadmin -report > dfs-old-report-1.log
Optional: Copy all unrecoverable data stored in HDFS to a local file system or to a backup instance of HDFS.
Save the namespace.
You must be the HDFS service user to do this and you must put the cluster in Safe Mode.
hdfs dfsadmin -safemode enter
hdfs dfsadmin -saveNamespace
Note In a highly-available NameNode configuration, the command
hdfs dfsadmin -saveNamespace
sets a checkpoint in the first NameNode specified in the configuration, indfs.ha.namenodes.[nameservice ID]
. You can also use the dfsadmin-fs
option to specify which NameNode to connect.For example, to force a checkpoint in namenode 2:
hdfs dfsadmin -fs hdfs://namenode2-hostname:namenode2-port -saveNamespace
Copy the checkpoint files located in
<dfs.name.dir/current>
into a backup directory.Find the directory, using
Ambari Web > HDFS > Configs > NameNode > NameNode Directories
on your primary NameNode host.Note In a highly-available NameNode configuration, the location of the checkpoint depends on where the saveNamespace command is sent, as defined in the preceding step.
Store the layoutVersion for the NameNode.
Make a copy of the file at
<dfs.name.dir>/current/VERSION
, where<dfs.name.dir>
is the value of the config parameter NameNode directories. This file will be used later to verify that the layout version is upgraded.Stop HDFS.
Stop ZooKeeper.
Using
Ambari Web
>Services
><service.name>
>Summary
, review each service and make sure that all services in the cluster are completely stopped.At the Hive Metastore database host, stop the Hive metastore service, if you have not done so already.
Note Make sure that the Hive metastore database is running. For more information about Administering the Hive metastore database, see the Hive Metastore Administrator documentation.
If you are upgrading Hive and Oozie, back up the Hive and Oozie metastore databases on the Hive and Oozie database host machines, respectively.
Important Make sure that your Hive database is updated to the minimum recommended version.
If you are using Hive with MySQL, we recommend upgrading your MySQL database to version 5.6.21 before upgrading the HDP Stack to v2.2.x. For specific information, see Database Requirements.
Optional - Back up the Hive Metastore database.
Note These instructions are provided for your convenience. Please check your database documentation for the latest back up instructions.
Hive Metastore Database Backup and Restore
Database Type
Backup
Restore
MySQL
mysqldump <dbname> > <outputfilename.sql>
For example:
mysqldump hive > /tmp/mydir/backup_hive.sql
mysql <dbname> < <inputfilename.sql>
For example:
mysql hive < /tmp/mydir/backup_hive.sql
Postgres
sudo -u <username> pg_dump <databasename> > <outputfilename.sql>
For example:
sudo -u postgres pg_dump hive
> /tmp/mydir/backup_hive.sql
sudo -u <username> psql <databasename> < <inputfilename.sql>
For example:
sudo -u postgres psql hive
< /tmp/mydir/backup_hive.sql
Oracle
Connect to the Oracle database using sqlplus export the database:
exp username/password@database full=yes file=output_file.dmp
Import the database:
imp username/password@database file=input_file.dmp
Optional - Back up the Oozie Metastore database.
Note These instructions are provided for your convenience. Please check your database documentation for the latest back up instructions.
Oozie Metastore Database Backup and Restore
Database Type
Backup
Restore
MySQL
mysqldump <dbname> > <outputfilename.sql>
For example:
mysqldump oozie > /tmp/mydir/backup_oozie.sql
mysql <dbname> < <inputfilename.sql>
For example:
mysql oozie < /tmp/mydir/backup_oozie.sql
Postgres
sudo -u <username> pg_dump <databasename> > <outputfilename.sql>
For example:
sudo -u postgres pg_dump oozie
> /tmp/mydir/backup_oozie.sql
sudo -u <username> psql <databasename> < <inputfilename.sql>
For example:
sudo -u postgres psql oozie
< /tmp/mydir/backup_oozie.sql
Backup Hue. If you are using the embedded SQLite database, you must perform a backup of the database before you upgrade Hue to prevent data loss. To make a backup copy of the database, stop Hue, then "dump" the database content to a file, as follows:
./etc/init.d/hue stop su $HUE_USER mkdir ~/hue_backup cd /var/lib/hue sqlite3 desktop.db .dump > ~/hue_backup/desktop.bak
For other databases, follow your vendor-specific instructions to create a backup.Stage the upgrade script.
Create an "Upgrade Folder". For example,
/work/upgrade_hdp_2
, on a host that can communicate with Ambari Server. The Ambari Server host is a suitable candidate.Copy the upgrade script to the Upgrade Folder. The script is available here:
/var/lib/ambari-server/resources/scripts/upgradeHelper.py
on the Ambari Server host.Copy the upgrade catalog to the Upgrade Folder. The catalog is available here:
/var/lib/ambari-server/resources/upgrade/catalog/UpgradeCatalog_2.1_to_2.2.x.json
.Note Make sure that Python is available on the host and that the version is 2.6 or higher:
python --version
For RHEL/Centos/Oracle Linux 5, you must use Python 2.6.
Backup current configuration settings.
Go to the Upgrade Folder you just created in step 15.
Execute the backup-configs action:
python upgradeHelper.py --hostname <HOSTNAME> --user <USERNAME> --password<PASSWORD> --clustername <CLUSTERNAME> backup-configs
Where <HOSTNAME> is the name of the Ambari Server host <USERNAME> is the admin user for Ambari Server <PASSWORD> is the password for the admin user <CLUSTERNAME> is the name of the cluster.
This step produces a set of files named TYPE_TAG, where TYPE is the configuration type and TAG is the tag. These files contain copies of the various configuration settings for the current (pre-upgrade) cluster. You can use these files as a reference later.
On the Ambari Server host, stop Ambari Server and confirm that it is stopped.
ambari-server stop
ambari-server status
Stop all Ambari Agents. On every host in your cluster known to Ambari,
ambari-agent stop