Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Cassandra without losing the current data

Tags:

cassandra

My current version of Cassandra is 2.2.4 and I want to upgrade it to 3.0.10 with out losing any data. How is it possible?

My cluster consist of 3 nodes with replication factor of 2. Will this update affect my cluster architecture?

like image 340
Mr. Sha Avatar asked May 17 '17 11:05

Mr. Sha


2 Answers

I had answered a similar question on dba.stackexchange, with data based on the DataStax upgrade documentation. Yes, you can upgrade your cluster without losing existing data, and yes there is a direct upgrade path from 2.2 to 3. The idea is to use a rolling-upgrade approach. Essentially, you'll want to follow these steps to upgrade:

  1. Stop the node. Back up your configuration files. Depending on how you install the product, these files may be overwritten with default values during the installation.
  2. Install the binaries (via tarball, apt-get, yum, etc...) for the new version of Cassandra.
  3. Configure the new product. Using the backups you made of your configuration files, merge any modifications you have previously made into the new configuration files for the new version. Configuration options change often, so be sure to double check the version restrictions for additional steps and changes regarding configuration. This is necessary when upgrading to Cassandra 3, as you cannot use the existing config files from 2.2 or lower.
  4. Start the node.
  5. Upgrade the sstables on each node: $ nodetool upgradesstables

Check the logs for warnings, errors and exceptions. Repeat on each node in the cluster. The upgradesstables step can be run on each node after the fact. Cassandra can read the sstables for one version lower, but you'll need to complete that step on all nodes to get the full benefits of the new Cassandra 3 storage engine.

Edit 20170518

Can you please explain the step 2. Where to install and how to install?

Since you are upgrading, it depends on how the initial install was done, which also depends on the OS and package manager (if any) used.

  • Debian-based Linux (Debian, Ubuntu, Knoppix)

    sudo dpkg -S cassandra should tell you where it is installed.

  • Red Hat-based Linux (CentOS, Fedora, RHEL)

    sudo rpm -q cassandra should tell you where it is installed.

If neither of those work, then your nodes were probably built with the tarball install process. And seriously, that's like anybody's guess as to where the binaries were installed. Common locations are /etc/cassandra, /opt/cassandra/ and /usr/local/cassandra.

Once you figure that out, you should be able to invoke an upgrade with your package manager using apt-get (Debian):

sudo apt-get update sudo apt-get install casandra

For yum (Red Hat) right now I think you still need to download the RPM, as they don't quite have that in the correct repos yet:

sudo rpm cassandra-3.10-noarch.rpm

And if you're running on a tarball install, what I like to do is rename the directory before downloading and untaring the new binaries:

sudo mv /etc/cassandra /etc/cassandra_20170510
sudo mv ~/Downloads/apache-cassandra-3.10.tar.gz /etc/
cd /etc
sudo tar -zxvf apache-cassandra-3.10.tar.gz
sudo mv /etc/apache-cassandra-3.10 /etc/cassandra

And don't forget to change ownership on the new dir to match the previous install.

More information on the specifics behind this process (and each method) can be found on the Apache Cassandra Download page.

like image 80
Aaron Avatar answered Oct 21 '22 17:10

Aaron


Steps for upgrade cassandra version
1. Run nodetool drain before shutting down the existing Cassandra service.
nodetool drain -h hostname
2. Stop cassandra services.
service cassandra stop
3. Back up your Cassandra configuration files from the old installation to safe place.
4. Update java version.
apt-get update
apt-get install oracle-java8-set-default
java -version
5. Install the new version of Apache Cassandra.
apt-get update
apt-get install cassandra=3.7.0
If you are running Cassandra from a source you should download the latest tar.gz instead of using the package manager.
6. Configure the new product. Review, compare, merge and/or update any modifications you have previously made into the new configuration files for the new version (cassandra.yml, cassandra-env.sh, etc.).
7. Start the cassandra services.
service cassandra start
Check the logs for warnings, errors, and exceptions.
tail -f /var/logs/cassandra/system.log # or path where you set your logs.
8. Run nodetool upgradesstables
nodetool upgradesstables
9. Check the logs for warnings, errors, and exceptions.
tail -f /var/logs/cassandra/system.log # or path where you set your logs.
10. Check the status of the cluster
nodetool -h hostname status
11. Repeat theses upgrade steps on each node in the cluster.

For more details please go to the link. upgrade Cassandra to the latest version

like image 35
Anand Tagore Avatar answered Oct 21 '22 17:10

Anand Tagore