You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/current/v26.2/connection-parameters.md
+73-8Lines changed: 73 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,24 +128,89 @@ SQL driver to determine whether these options are supported.
128
128
129
129
### Convert a URL for different drivers
130
130
131
-
The subcommand `cockroach convert-url` converts a connection URL, such as those printed out by [`cockroach start`]({% link {{ page.version.version }}/cockroach-start.md %}) or included in the online documentation, to the syntax recognized by various [client drivers]({% link {{ page.version.version }}/third-party-database-tools.md %}#drivers). For example:
131
+
The subcommand `cockroach convert-url` converts a connection URL, such as those printed out by [`cockroach start`]({% link {{ page.version.version }}/cockroach-start.md %}) or included in the online documentation, to the syntax recognized by various [client drivers]({% link {{ page.version.version }}/third-party-database-tools.md %}#drivers).
132
+
133
+
{{site.data.alerts.callout_info}}
134
+
The `cockroach encode-uri` command has been deprecated and merged into `cockroach convert-url`. Use `cockroach convert-url --format crdb` instead. The `encode-uri` command will be removed in a future release.
135
+
{{site.data.alerts.end}}
136
+
137
+
#### Basic usage
138
+
139
+
By default, `convert-url` outputs the URL in multiple formats:
`pq` | Connection URL for libpq (C/C++), psycopg (Python), lib/pq & pgx (Go), node-postgres (JS), and most pq-compatible drivers
178
+
`dsn` | Data Source Name for Postgres drivers that accept DSNs and ODBC
179
+
`jdbc` | Connection URL for JDBC (Java and JVM-based languages)
180
+
`crdb` | CockroachDB-specific URL format with inlined certificates for [Physical Cluster Replication]({% link {{ page.version.version }}/physical-cluster-replication-overview.md %}) and [Logical Data Replication]({% link {{ page.version.version }}/logical-data-replication-overview.md %})
181
+
182
+
#### Generate URLs for replication
183
+
184
+
To generate a connection URL for [Physical Cluster Replication]({% link {{ page.version.version }}/physical-cluster-replication-overview.md %}) or [Logical Data Replication]({% link {{ page.version.version }}/logical-data-replication-overview.md %}), use the `--format crdb` flag with the `--inline` flag to inline certificates directly into the URL:
185
+
186
+
{% include_cached copy-clipboard.html %}
187
+
~~~shell
188
+
cockroach convert-url --url "postgresql://{user}:{password}@{node IP}:26257" --format crdb --ca-cert {path to CA certificate} --inline
147
189
~~~
148
190
191
+
The `--inline` flag automatically sets `--format crdb`, so you can also use:
192
+
193
+
{% include_cached copy-clipboard.html %}
194
+
~~~shell
195
+
cockroach convert-url --url "postgresql://{user}:{password}@{node IP}:26257" --ca-cert {path to CA certificate} --inline
196
+
~~~
197
+
198
+
#### Additional flags
199
+
200
+
Flag | Description
201
+
-----|------------
202
+
`--url` | Connection URL to convert (required)
203
+
`--format` | Output format: `pq`, `dsn`, `jdbc`, or `crdb`
204
+
`--inline` | Inline certificates into the URL (automatically sets `--format crdb`)
205
+
`--database` | Database name
206
+
`--user` | Username
207
+
`--password` | Password
208
+
`--cluster` | Cluster name (sets `options=-ccluster=<name>`)
209
+
`--certs-dir` | Path to certificates directory
210
+
`--ca-cert` | Path to CA certificate
211
+
`--cert` | Path to client certificate
212
+
`--key` | Path to client private key
213
+
149
214
### Example URL for an insecure connection
150
215
151
216
The following URL is suitable to connect to a CockroachDB node using an insecure connection:
Copy file name to clipboardExpand all lines: src/current/v26.2/failover-replication.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,11 +207,11 @@ This section illustrates the steps to fail back to the original primary cluster
207
207
ALTER VIRTUAL CLUSTER {cluster_a} STOP SERVICE;
208
208
~~~
209
209
210
-
1. Open another terminal window and generate a connection string for **Cluster B** using [`cockroach encode-uri`]({% link {{ page.version.version }}/set-up-physical-cluster-replication.md %}#step-3-manage-cluster-certificates-and-generate-connection-strings):
210
+
1. Open another terminal window and generate a connection string for **Cluster B** using [`cockroach convert-url`]({% link {{ page.version.version }}/set-up-physical-cluster-replication.md %}#step-3-manage-cluster-certificates-and-generate-connection-strings):
211
211
212
212
{% include_cached copy-clipboard.html %}
213
213
~~~ shell
214
-
cockroach encode-uri {replication user}:{password}@{cluster B node IP or hostname}:26257--ca-cert certs/ca.crt --inline
214
+
cockroach convert-url --url "postgresql://{replication user}:{password}@{cluster B node IP or hostname}:26257" --format crdb --ca-cert certs/ca.crt --inline
215
215
~~~
216
216
217
217
Copy the output ready for starting the PCR stream, which requires the connection string to **Cluster B**:
Copy file name to clipboardExpand all lines: src/current/v26.2/set-up-logical-data-replication.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,13 +181,13 @@ To change the password later, refer to [`ALTER USER`]({% link {{ page.version.ve
181
181
182
182
In this step, you'll set up [external connection(s)]({% link {{ page.version.version }}/create-external-connection.md %}) to store the connection string for one or both clusters. Depending on how you manage certificates, you must ensure that all nodes between the clusters have access to the certificate of the other cluster.
183
183
184
-
You can use the `cockroach encode-uri`command to generate a connection string containing a cluster's certificate.
184
+
You can use the `cockroach convert-url`command to generate a connection string containing a cluster's certificate.
185
185
186
-
1. On the **source** cluster in a new terminal window, generate a connection string, by passing the replication user, node IP, and port, along with the directory to the source cluster's CA certificate:
186
+
1. On the **source** cluster in a new terminal window, generate a connection string by passing the connection URL for the replication user, along with the path to the source cluster's CA certificate:
187
187
188
188
{% include_cached copy-clipboard.html %}
189
189
~~~ shell
190
-
cockroach encode-uri postgresql://{user}:{password}@{node IP}:26257 --ca-cert {path to CA certificate} --inline
190
+
cockroach convert-url --url "postgresql://{user}:{password}@{node IP}:26257" --format crdb --ca-cert {path to CA certificate} --inline
191
191
~~~
192
192
193
193
The connection string output contains the source cluster's certificate:
@@ -224,7 +224,7 @@ Once the source cluster has made a connection to the destination cluster, the de
224
224
225
225
{% include_cached copy-clipboard.html %}
226
226
~~~ shell
227
-
cockroach encode-uri postgresql://{user}:{password}@{node IP}:26257 --ca-cert {path to CA certificate} --inline
227
+
cockroach convert-url --url "postgresql://{user}:{password}@{node IP}:26257" --format crdb --ca-cert {path to CA certificate} --inline
228
228
~~~
229
229
230
230
The connection string output contains the source cluster's certificate:
Copy file name to clipboardExpand all lines: src/current/v26.2/set-up-physical-cluster-replication.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,11 +253,11 @@ To create certificates signed by an external certificate authority, refer to [Cr
253
253
254
254
At this point, the primary and standby clusters are both running. The next step creates a connection URI with the certifications needed to connect the two clusters. In most cases, we recommend ensuring that all nodes on the primary cluster have access to the certificate of the standby cluster, and vice versa. This ensures that PCR is able to parallelize the work.
255
255
256
-
Use the `cockroach encode-uri`command to generate a connection string containing a cluster's certificate for any [PCR statements]({% link {{ page.version.version }}/physical-cluster-replication-overview.md %}#manage-replication-in-the-sql-shell) that require a connection string. Pass the replication user, IP and port, along with the path to the certificate for the **primary cluster**, into the `encode-uri` command:
256
+
Use the `cockroach convert-url`command to generate a connection string containing a cluster's certificate for any [PCR statements]({% link {{ page.version.version }}/physical-cluster-replication-overview.md %}#manage-replication-in-the-sql-shell) that require a connection string. Pass the connection URL for the replication user, along with the path to the certificate for the **primary cluster**, into the `convert-url` command:
257
257
258
258
{% include_cached copy-clipboard.html %}
259
259
~~~ shell
260
-
cockroach encode-uri {replication user}:{password}@{node IP or hostname}:26257 --ca-cert {path to certs directory}/certs/ca.crt --inline
260
+
cockroach convert-url --url "postgresql://{replication user}:{password}@{node IP or hostname}:26257" --format crdb --ca-cert {path to certs directory}/certs/ca.crt --inline
261
261
~~~
262
262
263
263
The connection string output contains the primary cluster's certificate:
@@ -404,7 +404,7 @@ Before you begin, you will need:
404
404
(1 row)
405
405
~~~
406
406
407
-
1. To create the replication job, you will need a connection string for the **primary cluster** containing its CA certificate. For steps to generate a connection string with `cockroach encode-uri`, refer to [Step 3. Manage cluster certificates and generate connection strings](#step-3-manage-cluster-certificates-and-generate-connection-strings).
407
+
1. To create the replication job, you will need a connection string for the **primary cluster** containing its CA certificate. For steps to generate a connection string with `cockroach convert-url`, refer to [Step 3. Manage cluster certificates and generate connection strings](#step-3-manage-cluster-certificates-and-generate-connection-strings).
408
408
409
409
1. If you would like to run a test workload on your existing **primary cluster**, you can use [`cockroach workload`]({% link {{ page.version.version }}/cockroach-workload.md %}) like the following:
Primary | System | Set up a replication user and view running virtual clusters. Connect with [`cockroach sql`]({% link {{ page.version.version }}/cockroach-sql.md %}). | `"postgresql://root@{node IP or hostname}:{26257}?options=-ccluster=system&sslmode=verify-full"`<ul><li>`options=-ccluster=system`</li><li>`sslmode=verify-full`</li></ul>Use the `--certs-dir` flag to specify the path to your certificate.
469
469
Primary | Main | Add and run a workload with [`cockroach workload`]({% link {{ page.version.version }}/cockroach-workload.md %}). | `"postgresql://root@{node IP or hostname}:{26257}?options=-ccluster=main&sslmode=verify-full&sslrootcert=certs/ca.crt&sslcert=certs/client.root.crt&sslkey=certs/client.root.key"`<br><br>{% include {{ page.version.version }}/connect/cockroach-workload-parameters.md %} As a result, for the example in this tutorial, you will need:<ul><li>`options=-ccluster={virtual_cluster_name}`</li><li>`sslmode=verify-full`</li><li>`sslrootcert={path}/certs/ca.crt`</li><li>`sslcert={path}/certs/client.root.crt`</li><li>`sslkey={path}/certs/client.root.key`</li></ul>
470
470
Standby | System | Manage the replication stream. Connect with [`cockroach sql`]({% link {{ page.version.version }}/cockroach-sql.md %}). | `"postgresql://root@{node IP or hostname}:{26257}?options=-ccluster=system&sslmode=verify-full"`<ul><li>`options=-ccluster=system`</li><li>`sslmode=verify-full`</li></ul>Use the `--certs-dir` flag to specify the path to your certificate.
471
-
Standby/Primary | System | Connect to the other cluster. | `"postgresql://{replication user}:{password}@{node IP or hostname}:{26257}/defaultdb?options=-ccluster%3Dsystem&sslinline=true&sslmode=verify-full&sslrootcert=-----BEGIN+CERTIFICATE-----{encoded_cert}-----END+CERTIFICATE-----%0A"`<br><br>Generate the connection string with [`cockroach encode-uri`](#step-3-manage-cluster-certificates-and-generate-connection-strings). Use the generated connection string in:<ul><li>`CREATE VIRTUAL CLUSTER` statements to [start the replication stream](#step-4-start-replication).</li><li>`ALTER VIRTUAL CLUSTER` statements to [fail back to the primary cluster]({% link {{ page.version.version }}/failover-replication.md %}#failback).</li></ul>
472
-
Standby/Primary | System | Connect to the other cluster through its load balancer | `"postgresql://{replication user}:{password}@{node IP or hostname}:{26257}/defaultdb?options=-ccluster%3Dsystem&crdb_route=gateway&sslinline=true&sslmode=verify-full&sslrootcert=-----BEGIN+CERTIFICATE-----{encoded_cert}-----END+CERTIFICATE-----%0A"`<br><br>Generate the connection string with [`cockroach encode-uri`](#step-3-manage-cluster-certificates-and-generate-connection-strings) and manually add the `&crdb_route=gateway` parameter. Recommended only when nodes do not share the same network. Use the generated connection string in:<ul><li>`CREATE VIRTUAL CLUSTER` statements to [start the replication stream](#step-4-start-replication).</li><li>`ALTER VIRTUAL CLUSTER` statements to [fail back to the primary cluster]({% link {{ page.version.version }}/failover-replication.md %}#failback).</li></ul>
471
+
Standby/Primary | System | Connect to the other cluster. | `"postgresql://{replication user}:{password}@{node IP or hostname}:{26257}/defaultdb?options=-ccluster%3Dsystem&sslinline=true&sslmode=verify-full&sslrootcert=-----BEGIN+CERTIFICATE-----{encoded_cert}-----END+CERTIFICATE-----%0A"`<br><br>Generate the connection string with [`cockroach convert-url`](#step-3-manage-cluster-certificates-and-generate-connection-strings). Use the generated connection string in:<ul><li>`CREATE VIRTUAL CLUSTER` statements to [start the replication stream](#step-4-start-replication).</li><li>`ALTER VIRTUAL CLUSTER` statements to [fail back to the primary cluster]({% link {{ page.version.version }}/failover-replication.md %}#failback).</li></ul>
472
+
Standby/Primary | System | Connect to the other cluster through its load balancer | `"postgresql://{replication user}:{password}@{node IP or hostname}:{26257}/defaultdb?options=-ccluster%3Dsystem&crdb_route=gateway&sslinline=true&sslmode=verify-full&sslrootcert=-----BEGIN+CERTIFICATE-----{encoded_cert}-----END+CERTIFICATE-----%0A"`<br><br>Generate the connection string with [`cockroach convert-url`](#step-3-manage-cluster-certificates-and-generate-connection-strings) and manually add the `&crdb_route=gateway` parameter. Recommended only when nodes do not share the same network. Use the generated connection string in:<ul><li>`CREATE VIRTUAL CLUSTER` statements to [start the replication stream](#step-4-start-replication).</li><li>`ALTER VIRTUAL CLUSTER` statements to [fail back to the primary cluster]({% link {{ page.version.version }}/failover-replication.md %}#failback).</li></ul>
473
473
Standby | Read only | Run read queries on the standby's replicating virtual cluster |`"postgresql://root@{node IP or hostname}:{26257}?options=-ccluster=main-readonly&sslmode=verify-full"`<ul><li>`options=-ccluster=main-readonly`</li><li>`sslmode=verify-full`</li></ul>Use the `--certs-dir` flag to specify the path to your certificate.
0 commit comments