Skip to content

Commit

Permalink
Add cloud storage sink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren committed Mar 28, 2019
1 parent bea9f22 commit 1e13431
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 6 deletions.
107 changes: 107 additions & 0 deletions v19.1/change-data-capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,113 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
$ ./bin/confluent stop
~~~
### Create a changefeed connected to a cloud storage sink
{{site.data.alerts.callout_info}}
`CREATE CHANGEFEED` is an [enterprise-only](enterprise-licensing.html) feature. For the core version, see [the `CHANGEFEED FOR` example above](#create-a-core-changefeed).
{{site.data.alerts.end}}
{% include {{ page.version.version }}/misc/experimental-warning.md %}
<span class="version-tag">New in v19.1:</span> In this example, you'll set up a changefeed for a single-node cluster that is connected to an AWS sink. Note that you can set up changefeeds for any of [these cloud storages](create-changefeed.html#cloud-storage-sink).
1. If you do not already have one, [request a trial enterprise license](enterprise-licensing.html).
2. In a terminal window, start `cockroach`:
{% include copy-clipboard.html %}
~~~ shell
$ cockroach start --insecure --listen-addr=localhost --background
~~~
3. As the `root` user, open the [built-in SQL client](use-the-built-in-sql-client.html):
{% include copy-clipboard.html %}
~~~ shell
$ cockroach sql --insecure
~~~
4. Set your organization name and [enterprise license](enterprise-licensing.html) key that you received via email:
{% include copy-clipboard.html %}
~~~ shell
> SET CLUSTER SETTING cluster.organization = '<organization name>';
~~~
{% include copy-clipboard.html %}
~~~ shell
> SET CLUSTER SETTING enterprise.license = '<secret>';
~~~
5. Enable the `kv.rangefeed.enabled` [cluster setting](cluster-settings.html):
{% include copy-clipboard.html %}
~~~ sql
> SET CLUSTER SETTING kv.rangefeed.enabled = true;
~~~
6. Create a database called `cdc_demo`:
{% include copy-clipboard.html %}
~~~ sql
> CREATE DATABASE cdc_demo;
~~~
7. Set the database as the default:
{% include copy-clipboard.html %}
~~~ sql
> SET DATABASE = cdc_demo;
~~~
8. Create a table and add data:
{% include copy-clipboard.html %}
~~~ sql
> CREATE TABLE office_dogs (
id INT PRIMARY KEY,
name STRING);
~~~
{% include copy-clipboard.html %}
~~~ sql
> INSERT INTO office_dogs VALUES
(1, 'Petee'),
(2, 'Carl');
~~~
{% include copy-clipboard.html %}
~~~ sql
> UPDATE office_dogs SET name = 'Petee H' WHERE id = 1;
~~~
9. Start the changefeed:
{% include copy-clipboard.html %}
~~~ sql
> CREATE CHANGEFEED FOR TABLE office_dogs INTO 'experimental-s3://test-s3encryption/test?AWS_ACCESS_KEY_ID=ABCDEFGHIJKLMNOPQ&AWS_SECRET_ACCESS_KEY=LS0tLS1CRUdJTiBDRVJUSUZ' with updated, resolved='10s';
~~~
~~~
job_id
+--------------------+
360645287206223873
(1 row)
~~~
This will start up the changefeed in the background and return the `job_id`. The changefeed writes to AWS.
10. Monitor your changefeed on the Admin UI (http://localhost:8080/#/metrics/changefeeds/cluster). For more information, see Changefeeds Dashboard.
11. When you are done, exit the SQL shell (`\q`).
12. To stop `cockroach`, run:
{% include copy-clipboard.html %}
~~~ shell
$ cockroach quit --insecure
~~~
## Known limitations
{% include {{ page.version.version }}/known-limitations/cdc.md %}
Expand Down
32 changes: 26 additions & 6 deletions v19.1/create-changefeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,28 @@ Changefeeds can only be created by superusers, i.e., [members of the `admin` rol
Parameter | Description
----------|------------
`table_name` | The name of the table (or tables in a comma separated list) to create a changefeed for.
`sink` | The location of the configurable sink. The scheme of the URI indicates the type; currently, only `kafka`. For more information, see [Kafka query parameters](#kafka-query-parameters) below.
`sink` | The location of the configurable sink. The scheme of the URI indicates the type. For more information, see [Sink URI](#sink-uri) below.
`option` / `value` | For a list of available options and their values, see [Options](#options) below.

<!-- `IF NOT EXISTS` | Create a new changefeed only if a changefeed of the same name does not already exist; if one does exist, do not return an error.
`name` | The name of the changefeed to create, which [must be unique](#create-fails-name-already-in-use) and follow these [identifier rules](keywords-and-identifiers.html#identifiers). -->

### Kafka query parameters
### Sink URI

The sink URI scheme for Kafka follows the basic format of:
The sink URI follows the basic format of:

~~~
'kafka://[host]:[port][?query_parameters]'
'[scheme]://[host]:[port]?[query_parameters]'
~~~

For example:
The `scheme` can be [`kafka`](#kafka) or any [cloud storage sink](#cloud-storage-sink).

#### Kafka

Example of a Kafka sink URI:

~~~
'kafka://broker.address.com:9092?tls_enabled=true&ca_cert=LS0tLS1CRUdJTiBDRVJUSUZ&sasl_enabled=true&sasl_user=petee&sasl_password=bones'
'kafka://broker.address.com:9092?topic_prefix=bar_&tls_enabled=true&ca_cert=LS0tLS1CRUdJTiBDRVJUSUZ&sasl_enabled=true&sasl_user=petee&sasl_password=bones'
~~~

Query parameters include:
Expand All @@ -60,6 +64,22 @@ Parameter | Value | Description
`sasl_user` | [`STRING`](string.html) | Your SASL username.
`sasl_password` | [`STRING`](string.html) | Your SASL password.

#### Cloud storage sink

Example of a cloud storage sink (i.e., AWS) URI:

~~~
'experimental-s3://test-s3encryption/test?AWS_ACCESS_KEY_ID=ABCDEFGHIJKLMNOPQ&AWS_SECRET_ACCESS_KEY=LS0tLS1CRUdJTiBDRVJUSUZ'
~~~

{{site.data.alerts.callout_info}}
The `scheme` for a cloud storage sink should be prepended with `experimental-`.
{{site.data.alerts.end}}

Any of the cloud storages below can be used as a sink:

{% include {{ page.version.version }}/misc/external-urls.md %}

### Options

Option | Value | Description
Expand Down

0 comments on commit 1e13431

Please sign in to comment.