Skip to content

Commit dc12889

Browse files
author
Jesse Seldess
authored
Merge pull request cockroachdb#3120 from vgiurgiu/patch-1
cockroachdb#3038 - Add copy-to-clipboard function to Getting Started
2 parents 9d37559 + b71c5f1 commit dc12889

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

v2.0/secure-a-cluster.md

+39
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,37 @@ Also, feel free to watch this process in action before going through the steps y
3030

3131
You can use either `cockroach cert` commands or [`openssl` commands](create-security-certificates-openssl.html) to generate security certificates. This section features the `cockroach cert` commands.
3232

33+
{% include copy-clipboard.html %}
3334
~~~ shell
3435
# Create a certs directory and safe directory for the CA key.
3536
# If using the default certificate directory (`${HOME}/.cockroach-certs`), make sure it is empty.
3637
$ mkdir certs
38+
~~~
39+
40+
{% include copy-clipboard.html %}
41+
~~~
3742
$ mkdir my-safe-directory
43+
~~~
3844

45+
{% include copy-clipboard.html %}
46+
~~~ shell
3947
# Create the CA key pair:
4048
$ cockroach cert create-ca \
4149
--certs-dir=certs \
4250
--ca-key=my-safe-directory/ca.key
51+
~~~
4352

53+
{% include copy-clipboard.html %}
54+
~~~ shell
4455
# Create a client key pair for the root user:
4556
$ cockroach cert create-client \
4657
root \
4758
--certs-dir=certs \
4859
--ca-key=my-safe-directory/ca.key
60+
~~~
4961

62+
{% include copy-clipboard.html %}
63+
~~~ shell
5064
# Create a key pair for the nodes:
5165
$ cockroach cert create-node \
5266
localhost \
@@ -62,6 +76,7 @@ $(hostname) \
6276

6377
## Step 2. Start the first node
6478

79+
{% include copy-clipboard.html %}
6580
~~~ shell
6681
$ cockroach start \
6782
--certs-dir=certs \
@@ -95,6 +110,7 @@ At this point, your cluster is live and operational. With just one node, you can
95110

96111
In a new terminal, add the second node:
97112

113+
{% include copy-clipboard.html %}
98114
~~~ shell
99115
$ cockroach start \
100116
--certs-dir=certs \
@@ -108,6 +124,7 @@ $ cockroach start \
108124

109125
In a new terminal, add the third node:
110126

127+
{% include copy-clipboard.html %}
111128
~~~ shell
112129
$ cockroach start \
113130
--certs-dir=certs \
@@ -127,6 +144,7 @@ Now that you've scaled to 3 nodes, you can use any node as a SQL gateway to the
127144

128145
{{site.data.alerts.callout_info}}The SQL client is built into the <code>cockroach</code> binary, so nothing extra is needed.{{site.data.alerts.end}}
129146

147+
{% include copy-clipboard.html %}
130148
~~~ shell
131149
$ cockroach sql \
132150
--certs-dir=certs
@@ -137,13 +155,23 @@ $ cockroach sql \
137155

138156
Run some basic [CockroachDB SQL statements](learn-cockroachdb-sql.html):
139157

158+
{% include copy-clipboard.html %}
140159
~~~ sql
141160
> CREATE DATABASE bank;
161+
~~~
142162

163+
{% include copy-clipboard.html %}
164+
~~~ sql
143165
> CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
166+
~~~
144167

168+
{% include copy-clipboard.html %}
169+
~~~ sql
145170
> INSERT INTO bank.accounts VALUES (1, 1000.50);
171+
~~~
146172

173+
{% include copy-clipboard.html %}
174+
~~~ sql
147175
> SELECT * FROM bank.accounts;
148176
~~~
149177

@@ -158,12 +186,14 @@ Run some basic [CockroachDB SQL statements](learn-cockroachdb-sql.html):
158186

159187
Exit the SQL shell on node 1:
160188

189+
{% include copy-clipboard.html %}
161190
~~~ sql
162191
> \q
163192
~~~
164193

165194
Then connect the SQL shell to node 2, this time specifying the node's non-default port:
166195

196+
{% include copy-clipboard.html %}
167197
~~~ shell
168198
$ cockroach sql \
169199
--certs-dir=certs \
@@ -177,6 +207,7 @@ $ cockroach sql \
177207

178208
Now run the same `SELECT` query:
179209

210+
{% include copy-clipboard.html %}
180211
~~~ sql
181212
> SELECT * FROM bank.accounts;
182213
~~~
@@ -194,6 +225,7 @@ As you can see, node 1 and node 2 behaved identically as SQL gateways.
194225

195226
Exit the SQL shell on node 2:
196227

228+
{% include copy-clipboard.html %}
197229
~~~ sql
198230
> \q
199231
~~~
@@ -222,6 +254,7 @@ Once you're done with your test cluster, switch to the terminal running the firs
222254

223255
At this point, with 2 nodes still online, the cluster remains operational because a majority of replicas are available. To verify that the cluster has tolerated this "failure", connect the built-in SQL shell to nodes 2 or 3. You can do this in the same terminal or in a new terminal.
224256

257+
{% include copy-clipboard.html %}
225258
~~~ shell
226259
$ cockroach sql \
227260
--certs-dir=certs \
@@ -231,6 +264,7 @@ $ cockroach sql \
231264
# To exit: CTRL + D.
232265
~~~
233266

267+
{% include copy-clipboard.html %}
234268
~~~ sql
235269
> SELECT * FROM bank.accounts;
236270
~~~
@@ -246,6 +280,7 @@ $ cockroach sql \
246280

247281
Exit the SQL shell:
248282

283+
{% include copy-clipboard.html %}
249284
~~~ sql
250285
> \q
251286
~~~
@@ -256,6 +291,7 @@ Now stop nodes 2 and 3 by switching to their terminals and pressing **CTRL-C**.
256291

257292
If you don't plan to restart the cluster, you may want to remove the nodes' data stores:
258293

294+
{% include copy-clipboard.html %}
259295
~~~ shell
260296
$ rm -rf cockroach-data node2 node3
261297
~~~
@@ -266,6 +302,7 @@ If you decide to use the cluster for further testing, you'll need to restart at
266302

267303
Restart the first node from the parent directory of `cockroach-data/`:
268304

305+
{% include copy-clipboard.html %}
269306
~~~ shell
270307
$ cockroach start \
271308
--certs-dir=certs \
@@ -278,6 +315,7 @@ $ cockroach start \
278315

279316
In a new terminal, restart the second node from the parent directory of `node2/`:
280317

318+
{% include copy-clipboard.html %}
281319
~~~ shell
282320
$ cockroach start \
283321
--certs-dir=certs \
@@ -291,6 +329,7 @@ $ cockroach start \
291329

292330
In a new terminal, restart the third node from the parent directory of `node3/`:
293331

332+
{% include copy-clipboard.html %}
294333
~~~ shell
295334
$ cockroach start \
296335
--certs-dir=certs \

0 commit comments

Comments
 (0)