今天cassandra无法创建表,提示错误如下:
Connected to: "Sentiment Cluster" on localhost/9160
Authenticated to keyspace: sentiment
Line 2 => Cluster schema does not yet agree
create DB error: 20120322
经常追查,反馈问题如下:
http://wiki.apache.org/cassandra/FAQ#schema_disagreement
Cassandra schema updates assume that schema changes are done one-at-a-time. If you make multiple changes at the same time, you can cause some nodes to end up with a different schema, than others. (Before 0.7.6, this can also be caused by cluster system clocks being substantially out of sync with each other.)
To fix schema disagreements, you need to force the disagreeing nodes to rebuild their schema. Here's how:
Open the cassandra-cli and run: 'connect localhost/9160;', then 'describe cluster;'. You'll see something like this:
[default@unknown] describe cluster; Cluster Information: Snitch: org.apache.cassandra.locator.SimpleSnitch Partitioner: org.apache.cassandra.dht.RandomPartitioner Schema versions: 75eece10-bf48-11e0-0000-4d205df954a7: [192.168.1.9, 192.168.1.25] 5a54ebd0-bd90-11e0-0000-9510c23fceff: [192.168.1.27]
Note which schemas are in the minority and mark down those IPs -- in the above example, 192.168.1.27. Login to each of those machines and stop the Cassandra service/process by running 'sudo service cassandra stop' or 'kill <pid>'. Remove the schema* and migration* sstables inside of your system keyspace (/var/lib/cassandra/data/system, if you're using the defaults).
After starting Cassandra again, this node will notice the missing information and pull in the correct schema from one of the other nodes.
To confirm everything is on the same schema, verify that 'describe cluster;' only returns one schema version.