在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:KarelDB开源软件地址:https://gitee.com/mirrors/KarelDB开源软件介绍:KarelDB - A Relational Database Backed by Apache KafkaKarelDB is a fully-functional relational database backed by Apache Kafka. MavenReleases of KarelDB are deployed to Maven Central. <dependency> <groupId>io.kareldb</groupId> <artifactId>kareldb-core</artifactId> <version>1.0.0</version></dependency> Server ModeTo run KarelDB, download a release, unpack it, and then modify $ bin/kareldb-start config/kareldb.properties At a separate terminal, enter the following command to start up $ bin/sqllinesqlline version 1.9.0sqlline> !connect jdbc:avatica:remote:url=http://localhost:8765 admin adminsqlline> create table books (id int, name varchar, author varchar);No rows affected (0.114 seconds)sqlline> insert into books values (1, 'The Trial', 'Franz Kafka');1 row affected (0.576 seconds)sqlline> select * from books;+----+-----------+-------------+| ID | NAME | AUTHOR |+----+-----------+-------------+| 1 | The Trial | Franz Kafka |+----+-----------+-------------+1 row selected (0.133 seconds) To access a KarelDB server from a remote application, use an Avatica JDBC client. A list of Avatica JDBC clients can be found here. If multiple KarelDB servers are configured with the same cluster group ID (see Configuration), then they will form a cluster and one of them will be elected as leader, while the others will become followers (replicas). If a follower receives a request, it will be forwarded to the leader. If the leader fails, one of the followers will be elected as the new leader. Embedded ModeKarelDB can also be used in embedded mode. Here is an example: Properties properties = new Properties();properties.put("schemaFactory", "io.kareldb.schema.SchemaFactory");properties.put("parserFactory", "org.apache.calcite.sql.parser.parserextension.ExtensionSqlParserImpl#FACTORY");properties.put("schema.kind", "io.kareldb.kafka.KafkaSchema");properties.put("schema.kafkacache.bootstrap.servers", bootstrapServers);properties.put("schema.kafkacache.data.dir", "/tmp");try (Connection conn = DriverManager.getConnection("jdbc:kareldb:", properties); Statement s = conn.createStatement()) { s.execute("create table books (id int, name varchar, author varchar)"); s.executeUpdate("insert into books values(1, 'The Trial', 'Franz Kafka')"); ResultSet rs = s.executeQuery("select * from books"); ...} ANSI SQL SupportKarelDB supports ANSI SQL, using Calcite. When creating a table, the primary key constraint should be specified after the columns, like so: CREATE TABLE customers (id int, name varchar, constraint pk primary key (id)); If no primary key constraint is specified, the first column in the table will be designated as the primary key. KarelDB extends Calcite's SQL grammar by adding support for ALTER TABLE commands. alterTableStatement: ALTER TABLE tableName columnAction [ , columnAction ]* columnAction: ( ADD tableElement ) | ( DROP columnName ) KarelDB supports the following SQL types:
Basic ConfigurationKarelDB has a number of configuration properties that can be specified. When using KarelDB as an embedded database, these properties should be prefixed with
SecurityHTTPSTo use HTTPS, first configure the ssl.keystore.location=/var/private/ssl/custom.keystoressl.keystore.password=changemessl.key.password=changeme When using the Avatica JDBC client, the HTTP AuthenticationKarelDB supports both HTTP Basic Authentication and HTTP Digest Authentication, as shown below: authentication.method=BASIC # or DIGESTauthentication.roles=admin,developer,userauthentication.realm=KarelDb-Props # as specified in JAAS file In the above example, the JAAS file might look like KarelDb-Props { org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required file="/path/to/password-file" debug="false";}; The When starting KarelDB, the path to the JAAS file must be set as a system property. $ export KARELDB_OPTS=-Djava.security.auth.login.config=/path/to/the/jaas_config.file$ bin/kareldb-start config/kareldb-secure.properties When using the Avatica JDBC client, the Kafka AuthenticationAuthentication to a secure Kafka cluster is described here. Implementation NotesKarelDB stores table data in topics of the form KarelDB uses three topics to hold metadata:
Database by ComponentsKarelDB is an example of a database built mostly by assembling pre-existing components. In particular, KarelDB uses the following:
See this blog for more on the design of KarelDB. Future EnhancementsPossible future enhancements include support for secondary indices. |
请发表评论