README.md 2.27 KB
Newer Older
tomogoma's avatar
tomogoma committed
1
2
3
4
5
6
7
# Cockroach DB Installer #

An auto-installer of cockroach DB Beta as a service in linux systems


## Install ##

8
Currently only systemd is supported.
tomogoma's avatar
tomogoma committed
9

10
***Note***
tomogoma's avatar
tomogoma committed
11

12
13
14
15
16
17
18
19
20
21
22
23
24
If upgrading from `v < 2.0` make sure you
[log in to the SQL](https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html#step-4-test-the-cluster)
console

```bash
cockroach sql --certs-dir=/etc/cockroachdb/certs
```

...and run the below command as documented
[here](https://www.cockroachlabs.com/docs/v1.1/upgrade-cockroach-version.html#finalize-the-upgrade):

```sql
SET CLUSTER SETTING version = '1.1';
tomogoma's avatar
tomogoma committed
25
```
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

***Install***

First download the cockroachdb tarball from https://binaries.cockroachdb.com or search for it
in the website: https://www.cockroachlabs.com

Then run the following commands.

```bash
git clone https://github.com/tomogoma/cockroach-installer
cd cockroach-installer
./systemdInstaller.sh /path/to/downloaded/cockroach-tarbal.tz [username]
```

`username` is optional.
Providing it allows `@username` to quickly access the SQL console using the `cconnect`
utility command:

```bash
cconnect
```

which is equivalent to:
```bash
cockroach sql --certs-dir=/etc/cockroachdb/certs
tomogoma's avatar
tomogoma committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
```


## Install outcome ##


Start

`$ systemctl start cockroach.service`

Stop

`$ systemctl stop cockroach.service`

Check status

`$ systemctl status cockroach.service`


Install Directories

The cockroach db binary is installed into
`/usr/local/cockroachdb`

The db certs are located at
`/usr/local/cockroachdb/certs`

The data dir is located at
`/var/data/cockroachdb`

A systemd service unit file is created at
`/etc/systemd/system/cockroach.service`

## Uninstall ##

`$ cd /path/to/roach-installer`

`$ ./systemdUninstaller.sh`


## Configure a dependent systemd service ##

If your service depends on cockroach db, in the service’s unit file add the following lines:


```
[Unit]

...

After=cockroach.service

Requires=cockroach.service

...
```


## Get your app’s postgresql driver url ##

1. Start the cockroachdb service as described in Install Outcome
1. Check the status of the service as described in Install Outcome
1. Copy the url you see under the sql flag: e.g:

    `sql:       postgresql://[email protected]:26257?sslcert=%2FUsers%2F…`

    Will yield the url:

    `postgresql://[email protected]:26257?sslcert=%2FUsers%2F…`