2023-09-06 12:21:47 +00:00
---
title: Set up InfluxDB Clustered
seotitle: Set up InfluxDB | Get started with InfluxDB Clustered
list_title: Set up InfluxDB
description: >
Learn how to set up InfluxDB Clustered for the "Get started with InfluxDB"
tutorial and for general use.
menu:
influxdb_clustered:
name: Set up InfluxDB
parent: Get started
identifier: get-started-set-up
weight: 101
metadata: [1 / 3]
related:
- /influxdb/clustered/admin/databases/
- /influxdb/clustered/reference/cli/influxctl/
- /influxdb/clustered/reference/api/
---
As you get started with this tutorial, do the following to make sure everything
you need is in place.
- [Install and configure your InfluxDB cluster ](#install-and-configure-your-influxdb-cluster )
- [Download, install, and configure the influxctl CLI ](#download-install-and-configure-the-influxctl-cli )
- [Create a database ](#create-a-database )
- [Create a database token ](#create-a-database-token )
- [Configure authentication credentials ](#configure-authentication-credentials )
## Install and configure your InfluxDB cluster
2024-07-02 00:49:37 +00:00
Follow the [Install InfluxDB Clustered ](/influxdb/clustered/install/ ) guide to
install prerequisites and set up your cluster.
2023-09-06 12:21:47 +00:00
## Download, install, and configure the influxctl CLI
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
The [`influxctl` CLI ](/influxdb/clustered/reference/cli/influxctl/ )
2024-07-02 00:49:37 +00:00
lets you manage your {{< product-name omit = "Clustered" > }} cluster from a
command line and perform administrative tasks such as managing
2023-09-06 12:21:47 +00:00
databases and tokens.
1. [Download and install the `influxctl` CLI ](/influxdb/clustered/reference/cli/influxctl/#download-and-install-influxctl ).
2. **Create a connection profile and provide your {{< product-name >}} connection credentials** .
The `influxctl` CLI uses [connection profiles ](/influxdb/clustered/reference/cli/influxctl/#configure-connection-profiles )
to connect to and authenticate with your {{< product-name omit = "Clustered" > }} cluster.
Create a file named `config.toml` at the following location depending on
your operating system.
| Operating system | Default profile configuration file path |
| :--------------- | :---------------------------------------------------- |
| Linux | `~/.config/influxctl/config.toml` |
| macOS | `~/Library/Application Support/influxctl/config.toml` |
| Windows | `%APPDATA%\influxctl\config.toml` |
{{% note %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
If stored at a non-default location, include the `--config` flag with each
`influxctl` command and provide the path to your profile configuration file.
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /note %}}
2024-07-02 00:49:37 +00:00
1. **Copy and paste the sample configuration profile code** into your `config.toml` :
2023-09-06 12:21:47 +00:00
2024-02-20 19:56:12 +00:00
{{% code-placeholders "PORT|OAUTH_TOKEN_URL|OAUTH_DEVICE_URL|OAUTH_CLIENT_ID" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```toml
[[profile]]
name = "default"
product = "clustered"
host = "{{< influxdb / host > }}"
port = "PORT"
[profile.auth.oauth2]
client_id = "OAUTH_CLIENT_ID"
scopes = [""]
token_url = "OAUTH_TOKEN_URL"
device_url = "OAUTH_DEVICE_URL"
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
2023-12-18 15:25:12 +00:00
Replace the following with your {{< product-name > }} credentials:
2024-07-02 00:49:37 +00:00
- {{% code-placeholder-key %}}`PORT`{{% /code-placeholder-key %}}: the port to use to access your InfluxDB cluster
- {{% code-placeholder-key %}}`OAUTH_CLIENT_ID`{{% /code-placeholder-key %}}: the client URL of your OAuth2 provider
(for example: `https://identityprovider/oauth2/v2/token` )
- {{% code-placeholder-key %}}`OAUTH_DEVICE_ID`{{% /code-placeholder-key %}}: the device URL of your OAuth2 provider
(for example: `https://identityprovider/oauth2/v2/auth/device` )
2023-12-18 15:25:12 +00:00
2023-09-06 12:21:47 +00:00
_For detailed information about `influxctl` profiles, see
[Configure connection profiles ](/influxdb/clustered/reference/cli/influxctl/#configure-connection-profiles )_.
## Create a database
2024-07-02 00:49:37 +00:00
Use the
[`influxctl database create` command ](/influxdb/clustered/reference/cli/influxctl/database/create/ )
2023-09-06 12:21:47 +00:00
to create a database. You can use an existing database or create a new one
specifically for this getting started tutorial.
2024-07-02 00:49:37 +00:00
_Examples in this getting started tutorial assume a database named `get-started` ._
2023-09-06 12:21:47 +00:00
{{% note %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
#### Authenticate with your cluster
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
The first time you run an `influxctl` CLI command, you are directed
to login to your **OAuth provider** . Once logged in, your OAuth provider issues
a short-lived (1 hour) management token for the `influxctl` CLI that grants
administrative access to your {{< product-name omit = "Clustered" > }} cluster.
{{% /note %}}
Provide the following:
- Database name.
2024-07-02 00:49:37 +00:00
- _Optional:_ Database
[retention period ](/influxdb/clustered/admin/databases/#retention-periods )
2023-09-06 12:21:47 +00:00
as a duration value. If no retention period is specified, the default is infinite.
2024-07-02 00:49:37 +00:00
<!-- Skip tests for database create and delete: namespaces aren't reusable -->
<!-- pytest.mark.skip -->
2023-09-06 12:21:47 +00:00
{{% code-placeholders "get-started|1y" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```sh
influxctl database create --retention-period 1y get-started
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
## Create a database token
2024-07-02 00:49:37 +00:00
Use the
[`influxctl token create` command ](/influxdb/clustered/reference/cli/influxctl/token/create/ )
2023-09-06 12:21:47 +00:00
to create a database token with read and write permissions for your database.
Provide the following:
- Permission grants
- `--read-database` : Grants read access to a database
- `--write-database` Grants write access to a database
- Token description
2024-07-02 00:49:37 +00:00
<!-- Skip database create and delete tests: namespaces aren't reusable -->
<!-- pytest.mark.skip -->
2023-09-06 12:21:47 +00:00
{{% code-placeholders "get-started" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```sh
influxctl token create \
--read-database get-started \
--write-database get-started \
"Read/write token for get-started database"
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
2024-07-02 00:49:37 +00:00
<!-- actual test
```sh
# Test the preceding command outside of the code block.
# influxctl authentication requires TTY interaction--
# output the auth URL to a file that the host can open.
TOKEN_NAME=token_TEST_RUN
script -q /dev/null -c "influxctl token list > /shared/urls.txt \
& & influxctl token create \
--read-database DATABASE_NAME \
--write-database DATABASE_NAME \
\"Read/write token ${TOKEN_NAME} for DATABASE_NAME database\" > /shared/tokens.txt
& & influxctl token revoke $(head /shared/tokens.txt) \
& & rm /shared/tokens.txt"
```
-->
2023-09-06 12:21:47 +00:00
The command returns the token ID and the token string.
Store the token string in a safe place.
You'll need it later.
**This is the only time the token string is available in plain text.**
{{% note %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
#### Store secure tokens in a secret store
Token strings are returned _only_ on token creation.
We recommend storing database tokens in a **secure secret store** .
For example, see how to [authenticate Telegraf using tokens in your OS secret store ](https://github.com/influxdata/telegraf/tree/master/plugins/secretstores/os ).
{{% /note %}}
## Configure authentication credentials
Code samples in later sections assume you assigned the token string to an
`INFLUX_TOKEN` environment variable--for example:
{{< tabs-wrapper > }}
{{% tabs %}}
2024-07-02 00:49:37 +00:00
[MacOS and Linux ](# )
2023-09-06 12:21:47 +00:00
[PowerShell ](# )
[CMD ](# )
{{% /tabs %}}
{{% tab-content %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
<!-- Using tabs - wrapper b/c code - tabs - wrapper breaks here. -->
<!-- BEGIN MACOS/LINUX -->
{{% code-placeholders "DATABASE_TOKEN" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```sh
export INFLUX_TOKEN=DATABASE_TOKEN
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
<!-- END MACOS/LINUX -->
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /tab-content %}}
{{% tab-content %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
<!-- BEGIN POWERSHELL -->
{{% code-placeholders "DATABASE_TOKEN" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```powershell
$env:INFLUX_TOKEN = "DATABASE_TOKEN"
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
<!-- END POWERSHELL -->
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /tab-content %}}
{{% tab-content %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
<!-- BEGIN CMD -->
{{% code-placeholders "DATABASE_TOKEN" %}}
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
```sh
set INFLUX_TOKEN=DATABASE_TOKEN
# Make sure to include a space character at the end of this command.
```
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /code-placeholders %}}
<!-- END CMD -->
2024-07-02 00:49:37 +00:00
2023-09-06 12:21:47 +00:00
{{% /tab-content %}}
{{< / tabs-wrapper > }}
2023-12-18 15:25:12 +00:00
Replace {{% code-placeholder-key %}}`DATABASE_TOKEN`{{% /code-placeholder-key %}}
with your [database token ](#create-a-database-token ) string.
2023-09-06 12:21:47 +00:00
{{< page-nav prev = "/influxdb/clustered/get-started/" next = "/influxdb/clustered/get-started/write/" keepTab = true > }}