1.查看已安装版本
$ yum list installed cassandra
$ yum list installed datastax-ddc
2.备份配置文件\keyspace\schema
备份schema
$ cqlsh -e "DESCRIBE project_statsys;" > /home/deploy/demouser/cassandra_backup/project_statsys_schema.cql
备份数据
$ cp -R /etc/cassandra /home/deploy/demouser/cassandra_backup/
cd /var/lib/cassandra/data/
tar -zcvf project_statsys.tar.gz project_statsys
3.删除旧版cassandra
$ sudo yum remove datastax-ddc
4.安装新版的cassandra
$ sudo yum install datastax-ddc
5.修改配置文件
修改cassandra配置/etc/cassandra/conf/cassandra.yaml
,修改下面参数
enable_user_defined_functions=true //支持用户自定义函数
6.启动cassandra
$ sudo /etc/init.d/cassandra start
7.cassandra数据库创建:
> CREATE KEYSPACE project_statsys WITH replication = {'class':'SimpleStrategy','replication_factor' : 1};
新建schema
$ cqlsh < project_statsys_schema.cql
使用sstableloader
还原备份数据
格式:sstableloader -d 127.0.0.1 <备份keyspace路径>/<tablename>
示例:
$ sstableloader -d 127.0.0.1 /home/deploy/demouser/cassandra_backup/project_statsys/app_func_event_records-a5aa972005ec11e691fb7f03cfc334ff
8.还原备份的数据
$ tar -zxf /home/db_backup/project_statsys.tar.gz /var/lib/cassandra/data/
9.重启cassandra
$ sudo /etc/init.d/cassandra start
参考文档:http://docs.datastax.com/en/latest-upgrade/upgrade/cassandra/upgdCassandra.html