Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis-cli TLS connections #2635

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions content/rs/references/cli-utilities/redis-cli/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ To learn how to install Redis and `redis-cli`, see the following installation gu

To run Redis commands with `redis-cli`, you need to connect to your Redis database.

### Connect from a node

If you have SSH access to a node in a Redis cluster, you can run `redis-cli` directly from the node:

1. Use SSH to sign in to a node in the Redis Enterprise cluster.

1. Connect to the database with `redis-cli`:

```sh
$ redis-cli -p <port>
```
You can find endpoint and port details in the **Databases** list or the database’s **Configuration** screen.

### Connect remotely

Expand All @@ -56,6 +46,29 @@ $ export REDISCLI_AUTH=<password>
$ redis-cli -h <endpoint> -p <port>
```

### Connect over TLS

To connect to a Redis Enterprise Software or Redis Enterprise Cloud database over TLS:

1. Download or copy the Redis Enterprise server (or proxy) certificates.

- For Redis Enterprise Cloud, see [Download certificates]({{<relref "/rc/security/database-security/tls-ssl#download-certificates">}}) for detailed instructions on how to download the server certificates (`redis_ca.pem`) from the [admin console](https://app.redislabs.com/).

- For Redis Enterprise Software, copy the proxy certificate from the admin console (**settings** > **general** > **Proxy Certificate**) or from a cluster node (`/etc/opt/redislabs/proxy_cert.pem`).

1. If your database doesn't require client authentication, provide the Redis Enterprise server certificate (`redis_ca.pem` for Cloud or `proxy_cert.pem` for Software) when you connect:

```sh
redis-cli -h <endpoint> -p <port> --tls --cacert <redis_cert>.pem
```

1. If your database requires client authentication, then you also need to provide your client's private and public keys:

```sh
redis-cli -h <endpoint> -p <port> --tls --cacert <redis_cert>.pem \
--cert redis_user.crt --key redis_user_private.key
```

### Connect with Docker

If your Redis database runs in a Docker container, you can use `docker exec` to run `redis-cli` commands:
Expand All @@ -69,17 +82,17 @@ $ docker exec -it <Redis container name> redis-cli -p <port>
You can run `redis-cli` commands directly from the command-line terminal:

```sh
$ redis-cli -p <port> <Redis command>
$ redis-cli -h <endpoint> -p <port> <Redis command>
```

For example, you can use `redis-cli` to test your database connection and store a new Redis string in the database:

```sh
$ redis-cli -p 12000 PING
$ redis-cli -h <endpoint> -p 12000 PING
PONG
$ redis-cli -p 12000 SET mykey "Hello world"
$ redis-cli -h <endpoint> -p 12000 SET mykey "Hello world"
OK
$ redis-cli -p 12000 GET mykey
$ redis-cli -h <endpoint> -p 12000 GET mykey
"Hello world"
```

Expand Down Expand Up @@ -107,6 +120,26 @@ OK
"Hello world"
```

## Examples

### Check slowlog

Run [`slowlog get`](https://redis.io/commands/slowlog-get/) for a list of recent slow commands:

```sh
redis-cli -h <endpoint> -p <port> slowlog get <number of entries>
```

### Scan for big keys

Scan the database for big keys:

```sh
redis-cli -h <endpoint> -p <port> --bigkeys
```

See [Scanning for big keys](https://redis.io/docs/ui/cli/#scanning-for-big-keys) for more information.

## More info

- [Redis CLI documentation](https://redis.io/docs/manual/cli/)
Expand Down
Loading