[Cassandra] Cassandra3.10创建表时“Column family ID mismatch”报错解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wawa8899/article/details/84302330

记一次cassandra创建表时“Column family ID mismatch”报错解决

环境:CentOS6.7 + JDK8 + Cassandra3.10

问题:

Cassandra创建表时报错:

cassandra@cqlsh:ks_test> CREATE TABLE tb_test (id text,times int,name text,PRIMARY KEY (id,name));
ServerError: java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.cassandra.exceptions.ConfigurationException: Column family ID mismatch (found 451afd20-e175-11e8-89f6-cf9b2035bb97; expected 44760a90-e175-11e8-b219-fbb85894ce41)
cassandra@cqlsh:ks_test>

解决:

The cause of this problem is a CREATE TABLE statement collision. Do not generate tables dynamically from multiple clients, even with IF NOT EXISTS. First thing you need to do is fix your code so that this does not happen. Just create your tables manually from cqlsh allowing time for the schema to settle. Always wait for schema agreement when modifying schema.

Here's the fix:

1) Change your code to not automatically re-create tables (even with IF NOT EXISTS).

2) Run a rolling restart to ensure schema matches across nodes. Run nodetool describecluster around your cluster. Check that there is only one schema version. 

ON EACH NODE:

3) Check your filesystem and see if you have two directories for the table in question in the data directory.

If THERE ARE TWO OR MORE DIRECTORIES:

4)Identify from schema_column_families which cf ID is the "new" one (currently in use). 

cqlsh -e "select * from system.schema_column_families"|grep

5) Move the data from the "old" one to the "new" one and remove the old directory. 

6) If there are multiple "old" ones repeat 5 for every "old" directory.

7) run nodetool refresh

IF THERE IS ONLY ONE DIRECTORY:

No further action is needed.

Futures

Schema collisions will continue to be an issue until - CASSANDRA-9424

Here's an example of it occurring on Jira and closed as not a problem CASSANDRA-8387

参考:https://stackoverflow.com/questions/31576180/cassandra-2-1-system-schema-missing

猜你喜欢

转载自blog.csdn.net/wawa8899/article/details/84302330
今日推荐