@ -84,36 +84,36 @@ For information about using the `influx` CLI, see the
2. Unpackage the InfluxDB binary.
Do one of the following:
Do one of the following:
- In **Finder**, double-click the downloaded package file.
- In your terminal (for example, **Terminal** or **[iTerm2](https://www.iterm2.com/)**), use `tar` to unpackage the file--for example, enter the following command to extract it into the current directory:
- In **Finder**, double-click the downloaded package file.
- In your terminal (for example, **Terminal** or **[iTerm2](https://www.iterm2.com/)**), use `tar` to unpackage the file--for example, enter the following command to extract it into the current directory:
<!--pytest-codeblocks:cont-->
<!--pytest-codeblocks:cont-->
```sh
# Unpackage contents to the current working directory
tar zxvf ~/Downloads/influxdb2-{{<latest-patch>}}_darwin_amd64.tar.gz
```
```sh
# Unpackage contents to the current working directory
tar zxvf ~/Downloads/influxdb2-{{<latest-patch>}}_darwin_amd64.tar.gz
```
3. Optional: Place the `influxd` binary in your `$PATH`--for example, copy the binary to `/usr/local/bin`:
<!--pytest.mark.skip-->
<!--pytest.mark.skip-->
```sh
# (Optional) Copy the influxd binary to your $PATH
If you choose to not move the `influxd` binary into your `$PATH`, enter the path to the binary to start the server--for example:
If you choose to not move the `influxd` binary into your `$PATH`, enter the
path to the binary to start the server--for example:
<!--pytest.mark.skip-->
<!--pytest.mark.skip-->
```sh
./influxdb2-{{<latest-patch>}}/usr/bin/influxd
```
```sh
./influxdb2-{{<latest-patch>}}/usr/bin/influxd
```
{{<expand-wrapper>}}
{{% expand "<spanclass='req'>Recommended</span>– Set appropriate directory permissions" %}}
To prevent unwanted access to data, set the permissions on the influxdb `data-dir` to not be world readable.
If installing on a server, we recommend setting a umask of `0027` to properly permission all newly created files.
To set umask, use a UMask directive in a systemd unit file or run Influxdb as a specific user that has the umask properly set--for example, enter the following command in your terminal:
To prevent unwanted access to data, set the permissions on the influxdb
`data-dir` to not be world readable.
If installing on a server, we recommend setting a umask of `0027` to properly
permission all newly created files.
To set umask, use a UMask directive in a systemd unit file or run Influxdb as a
specific user that has the umask properly set--for example, enter the following
command in your terminal:
<!--pytest.mark.skip-->
@ -386,8 +395,8 @@ To install `gpg`, see the [GnuPG installation instructions](https://gnupg.org/do
{{% expand "<spanclass='req'>Recommended</span>– Set appropriate directory permissions" %}}
To prevent unwanted access to data, we recommend setting the permissions on the influxdb `data-dir` to not be world readable--for example: enter the following commands in your terminal:
To prevent unwanted access to data, we recommend setting the permissions on the
influxdb `data-dir` to not be world readable--for example: enter the following
The following guide uses [Docker CLI commands](https://docs.docker.com/reference/cli/docker/) to set Docker and InfluxDB options, but you can also use Dockerfiles and Docker Compose.
The following steps show to use the
[Docker CLI](https://docs.docker.com/reference/cli/docker/) to set up and
1. Follow instructions to install [Docker Desktop](https://www.docker.com/get-started/) for your system.
2. Start a Docker container from the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)--for example, in your terminal, enter the `docker run influxdb:2` command with command line flags for initial setup options and file system mounts.
_The following guide uses Docker mounted
[volumes](https://docs.docker.com/storage/volumes/) to persist InfluxDB
configuration and data.
Persisting your data to a file system outside the container ensures that your
data isn't deleted if you delete the container._
The following example uses the Docker `--mount` option to persist InfluxDB configuration and data to [volumes](https://docs.docker.com/storage/volumes/).
_Persisting your data to a file system outside the container ensures that your data isn't deleted if you delete the container._
1. Install [Docker Desktop](https://www.docker.com/get-started/) for your system.
<!--pytest.mark.skip-->
2. Start a Docker container from the
[`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)--for example,
in your terminal, enter the `docker run influxdb:2` command with command line
flags for initial setup options and file system mounts.
_If you don't specify InfluxDB initial setup options, you can
[set up manually](#set-up-influxdb) later using the UI or CLI in a running
- `--publish 8086:8086`: Exposes the InfluxDB [UI](/influxdb/v2/get-started/#influxdb-user-interface-ui) and [HTTP API](/influxdb/v2/reference/api/) on the host's `8086` port.
- `--mount type=volume,source=influxdb2-data,target=/var/lib/influxdb2`: Creates a volume named `influxdb2-data` mapped to the [InfluxDB data directory](/influxdb/v2/reference/internals/file-system-layout/?t=docker#file-system-layout) to persist data outside the container.
- `--mount type=volume,source=influxdb2-config,target=/etc/influxdb2`: Creates a volume named `influxdb2-config` mapped to the [InfluxDB configuration directory](/influxdb/v2/reference/internals/file-system-layout/?t=docker#file-system-layout) to make configurations available outside the container.
- `-e DOCKER_INFLUXDB_INIT_MODE=setup`: Environment variable that invokes the automated setup of the initial organization, user, bucket, and token when creating the container.
- `-e DOCKER_INFLUXDB_INIT_<SETUP_OPTION>`: Environment variables for initial setup options--replace the following with your own values:
- `--publish 8086:8086`: Exposes the InfluxDB
[UI](/influxdb/v2/get-started/#influxdb-user-interface-ui) and
[HTTP API](/influxdb/v2/reference/api/) on the host's `8086` port.
to make configurations available outside the container.
- `--env DOCKER_INFLUXDB_INIT_MODE=setup`: Environment variable that invokes the
automated setup of the initial organization, user, bucket, and token when creating the container.
- `--env DOCKER_INFLUXDB_INIT_<SETUP_OPTION>`: Environment variables for initial
setup options--replace the following with your own values:
- {{% code-placeholder-key %}}`ADMIN_USERNAME`{{% /code-placeholder-key %}}: The username for the initial [user](/influxdb/v2/admin/users/)--an admin user with an API [Operator token](/influxdb/v2/admin/tokens/#operator-token).
- {{% code-placeholder-key %}}`ADMIN_PASSWORD`{{% /code-placeholder-key %}}: The password for the initial [user](/influxdb/v2/admin/users/).
- {{% code-placeholder-key %}}`ORG_NAME`{{% /code-placeholder-key %}}: The name for the initial [organization](/influxdb/v2/admin/organizations/).
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}}: The name for the initial [bucket](/influxdb/v2/admin/buckets/).
For more options, see the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb) documentation.
_If you don't specify InfluxDB initial setup options, you can [set up manually](#set-up-influxdb) later using the UI or CLI in a running container._
The name for the initial [bucket](/influxdb/v2/admin/buckets/).
If successful, the command starts InfluxDB initialized with the user, organization, bucket,
and _[Operator token](/influxdb/v2/admin/tokens/#operator-token)_, and logs to stdout.
You can view the Operator token in the `/etc/influxdb2/influx-configs` file and use it to authorize [creating an All Access token](#optional-create-all-access-tokens).
_To run the InfluxDB container in [detached mode](https://docs.docker.com/engine/reference/run/#detached-vs-foreground),
include the `--detach` flag in the `docker run` command._
You can view the Operator token in the `/etc/influxdb2/influx-configs` file and
use it to authorize
[creating an All Access token](#optional-create-all-access-tokens).
include the `--detach` flag in the `docker run` command._
For more InfluxDB configuration options,
see the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)
documentation.
### Run InfluxDB CLI commands in a container
When you start a container using the `influxdb` Docker Hub image, it also installs the [`influx` CLI](/influxdb/v2/tools/influx-cli/) in the container.
With InfluxDB setup and running in the container, you can use the Docker CLI [`docker exec`](https://docs.docker.com/reference/cli/docker/container/exec/) command to interact with the `influx` and `influxd` CLIs inside the container.
When you start a container using the `influxdb` Docker Hub image, it also
installs the [`influx` CLI](/influxdb/v2/tools/influx-cli/) in the container.
With InfluxDB setup and running in the container, you can use the Docker CLI
To copy files, such as the InfluxDB server `config.yml` file, between your local file system and a volume, use the [`docker container cp` command](https://docs.docker.com/reference/cli/docker/container/cp/).
To copy files, such as the InfluxDB server `config.yml` file, between your local