From 6c4d13557d98c0f20fd18deeddf6e2654176de64 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Fri, 15 Jun 2018 16:09:35 +0800 Subject: [PATCH] op-guide, tikv: update docker compose deployment (#496) * op-guide, tikv: update docker compose deployment Via: https://github.com/pingcap/tidb-docker-compose/pull/25 * op-guide: add the TiSpark section * op-guide: add a 5-minute tutorial link * op-guide: update wording --- op-guide/docker-compose.md | 65 +++++++++++++++++++++++++++--- tikv/deploy-tikv-docker-compose.md | 34 +++++++++++----- 2 files changed, 82 insertions(+), 17 deletions(-) diff --git a/op-guide/docker-compose.md b/op-guide/docker-compose.md index 77d442c12ef92..42e35347c3060 100644 --- a/op-guide/docker-compose.md +++ b/op-guide/docker-compose.md @@ -1,15 +1,22 @@ --- title: TiDB Docker Compose Deployment +summary: Deploy a TiDB testing cluster with a single command using Docker Compose. category: operations --- # TiDB Docker Compose Deployment -This document describes how to quickly deploy TiDB using [Docker Compose](https://docs.docker.com/compose/overview). +This document describes how to quickly deploy a TiDB testing cluster with a single command using [Docker Compose](https://docs.docker.com/compose/overview). With Docker Compose, you can use a YAML file to configure application services in multiple containers. Then, with a single command, you can create and start all the services from your configuration. -You can use Docker Compose to deploy a TiDB test cluster with a single command. It is required to use Docker 17.06.0 or later. +## Prerequisites + +Make sure you have installed the following items on your machine: + +- Docker (17.06.0 or later) +- Docker Compose +- Git ## Deploy TiDB using Docker Compose @@ -22,7 +29,8 @@ You can use Docker Compose to deploy a TiDB test cluster with a single command. 2. Create and start the cluster. ```bash - cd tidb-docker-compose && docker-compose up -d + cd tidb-docker-compose && docker-compose pull # Get the latest Docker images + docker-compose up -d ``` 3. Access the cluster. @@ -59,7 +67,7 @@ To customize the cluster, you can edit the `docker-compose.yml` file directly. I For macOS, you can also install Helm using the following command in Homebrew: - ``` + ```bash brew install kubernetes-helm ``` @@ -77,7 +85,7 @@ To customize the cluster, you can edit the `docker-compose.yml` file directly. I vim values.yaml ``` - Modify the configuration in `values.yaml`, such as the cluster size, TiDB image version, and so on. + You can modify the configuration in `values.yaml`, such as the cluster size, TiDB image version, and so on. [tidb-vision](https://github.com/pingcap/tidb-vision) is the data visualization interface of the TiDB cluster, used to visually display the PD scheduling on TiKV data. If you do not need this component, leave `tidbVision` empty. @@ -96,6 +104,7 @@ To customize the cluster, you can edit the `docker-compose.yml` file directly. I 5. Create and start the cluster using the generated `docker-compose.yml` file. ```bash + docker-compose -f generated-docker-compose.yaml pull # Get the latest Docker images docker-compose -f generated-docker-compose.yml up -d ``` @@ -111,4 +120,48 @@ To customize the cluster, you can edit the `docker-compose.yml` file directly. I - Default account name: admin - Default password: admin - If tidb-vision is enabled, you can access the cluster data visualization interface: . \ No newline at end of file + If tidb-vision is enabled, you can access the cluster data visualization interface: . + +## Access the Spark shell and load TiSpark + +Insert some sample data to the TiDB cluster: + +```bash +$ docker-compose exec tispark-master bash +$ cd /opt/spark/data/tispark-sample-data +$ mysql -h tidb -P 4000 -u root < dss.ddl +``` + +After the sample data is loaded into the TiDB cluster, you can access the Spark shell using `docker-compose exec tispark-master /opt/spark/bin/spark-shell`. + +```bash +$ docker-compose exec tispark-master /opt/spark/bin/spark-shell +... +Spark context available as 'sc' (master = local[*], app id = local-1527045927617). +Spark session available as 'spark'. +Welcome to + ____ __ + / __/__ ___ _____/ /__ + _\ \/ _ \/ _ `/ __/ '_/ + /___/ .__/\_,_/_/ /_/\_\ version 2.1.1 + /_/ + +Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172) +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import org.apache.spark.sql.TiContext +... +scala> val ti = new TiContext(spark) +... +scala> ti.tidbMapDatabase("TPCH_001") +... +scala> spark.sql("select count(*) from lineitem").show ++--------+ +|count(1)| ++--------+ +| 60175| ++--------+ +``` + +Here is [a 5-minute tutorial](https://www.pingcap.com/blog/how_to_spin_up_an_htap_database_in_5_minutes_with_tidb_tispark/) for macOS users that shows how to spin up a standard TiDB cluster using Docker Compose on your local computer. \ No newline at end of file diff --git a/tikv/deploy-tikv-docker-compose.md b/tikv/deploy-tikv-docker-compose.md index c0f2da7b8c529..3d524742aa5d8 100644 --- a/tikv/deploy-tikv-docker-compose.md +++ b/tikv/deploy-tikv-docker-compose.md @@ -1,56 +1,68 @@ --- title: Install and Deploy TiKV Using Docker Compose -category: user guide +summary: Quickly deploy a TiKV testing cluster using Docker Compose. +category: operations --- # Install and Deploy TiKV Using Docker Compose -This guide describes how to quickly deploy a TiKV cluster using [Docker Compose](https://github.com/pingcap/tidb-docker-compose/). Currently, this installation method only supports the Linux system. +This guide describes how to quickly deploy a TiKV testing cluster using [Docker Compose](https://github.com/pingcap/tidb-docker-compose/). + +> **Note:** Currently, this installation method only supports the Linux system. ## Prerequisites -- Install Docker and Docker Compose. +Make sure you have installed the following items on your machine: - ``` +- Docker (17.06.0 or later) and Docker Compose + + ```bash sudo yum install docker docker-compose ``` -- Install Helm. +- Helm - ``` + ```bash curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash ``` +- Git + + ``` + sudo yum install git + ``` + ## Install and deploy 1. Download `tidb-docker-compose`. - ``` + ```bash git clone https://github.com/pingcap/tidb-docker-compose.git ``` 2. Edit the `compose/values.yaml` file to configure `networkMode` to `host` and comment the TiDB section out. - ``` + ```bash cd tidb-docker-compose/compose networkMode: host ``` 3. Generate the `generated-docker-compose.yml` file. - ``` + ```bash helm template compose > generated-docker-compose.yml ``` 4. Create and start the cluster using the `generated-docker-compose.yml` file. - ``` + ```bash + docker-compose -f generated-docker-compose.yaml pull # Get the latest Docker images docker-compose -f generated-docker-compose.yml up -d ``` You can check whether the TiKV cluster has been successfully deployed using the following command: -``` +```bash curl localhost:2379/pd/api/v1/stores ```