4

I would like to be able to keep a schema with a fixed id even if the server is restarted.

Is it possible to persist the schemas in the Schema Registry in order to have them with the same id after the server crashes?

Otherwise, is it possible to hardcode a schema with a fixed id when the schema registry server starts?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Adrian Olosutean
  • 179
  • 1
  • 3
  • 11

1 Answers1

7

This is the purpose of schema registry: a schema has a fixed id. SchemaRegistry doesn't store anything on disk actually. It leverages on kafka to store all information in a compacted topic (on broker, _schemas by default).

So as long as you have register a schema, whenever you asked for this same schema, you will get the same id, even after crash / restart

Treziac
  • 3,056
  • 1
  • 17
  • 19
  • But I would want to be able to keep it even if all the kafka servers are down. – Adrian Olosutean Aug 01 '17 at 14:32
  • 1
    Your kafka servers are redundant - if one crash or is down, it will still works. If all your servers are down, it will rework with same id when they are online again. If you want to migrate cluster, you will have to replicate the contente from the _schemas topic to the new server - I'm not sure there are tools available for this (for the schema registry explcitily), you may want to ask to confluent support if it's your case. – Treziac Aug 01 '17 at 14:53
  • If the kafka cluster is completely down, you lose all the schemas. And therefore cannot consume the Avro data until the schema versions are restored exactly as originally defined. You can use the console consumer to backup the `_schemas` topic to a file because they are just plain-text JSON messages, then console producer to restore to a new cluster/topic – OneCricketeer Sep 30 '18 at 06:47