问题
I've been using Cassandra 2.1.7 and For some reason I upgraded to 3.0.12 and later realized that some dependent apps won't work with 3.0.12 and I downgraded and using C* 2.1.7 as I was using before. But Now I'm not able to see Keyspaces in C*. (Just FYI: Data directory is same in both C*yaml files)
Do I have to make any changes?
Appreciate your help.
回答1:
When you upgrade from 2.x to 3.x you have to run upgradesstables command in nodetool. I assume this is what you did. Now when you downgraded back to 2.x Cassandra is unnable to read the newer SSTable format. Unfortunately there is no downgradesstables command so your only option is to restore a backup from when you where first running 2.x.
回答2:
If you have NOT taken backup then nothing to worry as C* 3.0 won't remove older dbs after upgrade it just updates sstable related CFS and added some more CFS for compatibility.
Here is what I've done to retain data: Since 3.0 has completely different naming conventions for DB names, we need to carefully distinguish db from both(Older vs newer).
For 2.X Cassandra dbnames have the following convention for each ks:
keyspace-ColumnFamilyName-ka-ID-Data.db
keyspace-ColumnFamilyName-ka-ID-Digest.sha1
keyspace-ColumnFamilyName-ka-ID-Filter.db
keyspace-ColumnFamilyName-ka-ID-Index.db
keyspace-ColumnFamilyName-ka-ID-Statistics.db
keyspace-ColumnFamilyName-ka-ID-Summary.db
keyspace-ColumnFamilyName-ka-ID-TOC.txt
keyspace: keyspace name
ColumnFimilyname : Name of the CF under keyspace
ka: C* Internal(Haven't explored much on this)
ID: It is incremental value I see different sets of these having different id.(looks like it is an increasing factor when it takes snapshot, not sure though)
And the last parameter is db name
So when I start with 2.1.7 I read through each and every log statement in of C* daemon and found out that the sstable_actiivity file under system keyspace is not the actual one as the size of this file is very less.
/data/system/sstable_activity-5a1ff267ace03f128563cfae6103c65e/system-sstable_activity-ka-145
So I tried to find the oldest file under system(keyspace directory i.e /data/system/) from snapshots and replace that with the above file. And the same I repeated for the "schema_keyspaces" table under system keyspace.
Now I restart cassandra daemon again, luckily I could get list of keyspaces after I run "DESC KEYSPACES" But I don't see list of tables when I execute "DESC TABLES" for my keyspace as it didn't load because files were not found by sstable_activity.
Now I kept repeating the same process for all other tables under "system" keyspace. which are as below:
schema_keyspaces
schema_columnfamilies
local
schema_columns
schema_triggers
schema_usertypes
After restarting Cassandra, I was able retrieve date that I expected for my application.
来源:https://stackoverflow.com/questions/46579495/unable-to-see-all-keyspaces-in-c-2-1-7-after-i-downgraded-from-3-0-to-2-1-7