Skip to content

Commit

Permalink
docs(user-guide): add android running doc (GreptimeTeam#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
v0y4g3r authored Oct 12, 2023
1 parent 87a2749 commit 9859e8b
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/en/v0.4/summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- configuration
- kubernetes
- gtctl
- run-on-android
# TODO
# - monitor-&-alert
# - import-data
Expand Down
105 changes: 105 additions & 0 deletions docs/en/v0.4/user-guide/operations/run-on-android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Run on Android Platforms

Since v0.4.0, GreptimeDB supports running on Android platforms with ARM64 CPU and Android API level >= 23.

## Install terminal emulator on Android

You can install [Termux](https://termux.dev/) from [Google Play store](https://play.google.com/store/apps/details?id=com.termux).


## Download GreptimeDB Android binary.

```bash
curl -sOL https://github.com/GreptimeTeam/greptimedb/releases/download/v0.4.0/greptime-android-arm64-v0.4.0.tar.gz
tar zxvf ./greptime-android-arm64-v0.4.0.tar.gz
./greptime -V
```

If binary's downloaded correctly, the command is expected to print:

```
greptimedb
branch: HEAD
commit: c9c2b3c91f273ff605782dbb8a4873e511dfea10
dirty: false
version: 0.4.0
```

## Create GreptimeDB configuration file

You can create a minimal configuration file that allows access from local network.

```bash
DATA_DIR="$(pwd)/greptimedb-data"
mkdir -p ${DATA_DIR}

cat <<EOF > ./config.toml
[http]
addr = "0.0.0.0:4000"
[grpc]
addr = "0.0.0.0:4001"
[mysql]
addr = "0.0.0.0:4002"
[storage]
data_home = "${DATA_DIR}"
type = "File"
EOF
```

## Start GreptimeDB from command line

```bash
./greptime --log-dir=$(pwd)/logs standalone start -c ./config.toml
```

## Connect to GreptimeDB running on Android
> You can find the IP address of your Android device from system settings or `ifconfig`.
You can now connect to the GreptimeDB instance running on Android from another device with MySQL client installed.

```bash
mysql -h <ANDROID_DEVICE_IP_ADDR> -P 4002
```

And play like on any other platforms!
```
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.10-alpha-msql-proxy Greptime
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE TABLE monitor (env STRING, host STRING, ts TIMESTAMP, cpu DOUBLE DEFAULT 0, memory DOUBLE, TIME INDEX (ts), PRIMARY KEY(env,host));
Query OK, 0 rows affected (0.14 sec)
mysql> INSERT INTO monitor(ts, env, host, cpu, memory) VALUES
-> (1655276557000,'prod', 'host1', 66.6, 1024),
-> (1655276557000,'prod', 'host2', 66.6, 1024),
-> (1655276557000,'prod', 'host3', 66.6, 1024),
-> (1655276558000,'prod', 'host1', 77.7, 2048),
-> (1655276558000,'prod', 'host2', 77.7, 2048),
-> (1655276558000,'test', 'host3', 77.7, 2048),
-> (1655276559000,'test', 'host1', 88.8, 4096),
-> (1655276559000,'test', 'host2', 88.8, 4096),
-> (1655276559000,'test', 'host3', 88.8, 4096);
Query OK, 9 rows affected (0.14 sec)
mysql>
mysql> select * from monitor where env='test' and host='host3';
+------+-------+---------------------+------+--------+
| env | host | ts | cpu | memory |
+------+-------+---------------------+------+--------+
| test | host3 | 2022-06-15 15:02:38 | 77.7 | 2048 |
| test | host3 | 2022-06-15 15:02:39 | 88.8 | 4096 |
+------+-------+---------------------+------+--------+
2 rows in set (0.20 sec)
```
109 changes: 109 additions & 0 deletions docs/zh/v0.4/user-guide/operations/run-on-android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# 在安卓平台运行

从 v0.4.0 开始,GreptimeDB 支持在采用了 ARM64 CPU 和 Android API 23 版本以上的安卓平台运行。

## 安装终端模拟器

您可以从 [Google Play 商店安装](https://play.google.com/store/apps/details?id=com.termux)终端模拟器,如 [Termux](https://termux.dev/),来运行 GreptimeDB.



## 下载 GreptimeDB 的二进制

请执行以下命令来下载安卓平台的 GreptimeDB 二进制:
```bash
curl -sOL https://github.com/GreptimeTeam/greptimedb/releases/download/v0.4.0/greptime-android-arm64-v0.4.0.tar.gz
tar zxvf ./greptime-android-arm64-v0.4.0.tar.gz
./greptime -V
```

如果下载成功,以上命令将输出:

```
greptimedb
branch: HEAD
commit: c9c2b3c91f273ff605782dbb8a4873e511dfea10
dirty: false
version: 0.4.0
```

## 创建 GreptimeDB 的配置文件

您可以通过以下命令来创建一个最小化的配置文件以允许从局域网访问 GreptimeDB:

```bash
DATA_DIR="$(pwd)/greptimedb-data"
mkdir -p ${DATA_DIR}

cat <<EOF > ./config.toml
[http]
addr = "0.0.0.0:4000"
[grpc]
addr = "0.0.0.0:4001"
[mysql]
addr = "0.0.0.0:4002"
[storage]
data_home = "${DATA_DIR}"
type = "File"
EOF
```

## 从命令行启动 GreptimeDB

```bash
./greptime --log-dir=$(pwd)/logs standalone start -c ./config.toml
```

## 从局域网连接运行在安卓设备上的 GreptimeDB

> 您可以通过`ifconfig`来获取您所使用的的安卓设备的网络地址。
在启动 GreptimeDB 后,您可以从局域网内安装了 MySQL 客户端的设备上通过 MySQL 协议访问 GreptimeDB。

```bash
mysql -h <ANDROID_DEVICE_IP_ADDR> -P 4002
```

连接成功后,您可以像在任何其他平台一样使用运行在安卓设备上的 GreptimeDB!

```
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.10-alpha-msql-proxy Greptime
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE TABLE monitor (env STRING, host STRING, ts TIMESTAMP, cpu DOUBLE DEFAULT 0, memory DOUBLE, TIME INDEX (ts), PRIMARY KEY(env,host));
Query OK, 0 rows affected (0.14 sec)
mysql> INSERT INTO monitor(ts, env, host, cpu, memory) VALUES
-> (1655276557000,'prod', 'host1', 66.6, 1024),
-> (1655276557000,'prod', 'host2', 66.6, 1024),
-> (1655276557000,'prod', 'host3', 66.6, 1024),
-> (1655276558000,'prod', 'host1', 77.7, 2048),
-> (1655276558000,'prod', 'host2', 77.7, 2048),
-> (1655276558000,'test', 'host3', 77.7, 2048),
-> (1655276559000,'test', 'host1', 88.8, 4096),
-> (1655276559000,'test', 'host2', 88.8, 4096),
-> (1655276559000,'test', 'host3', 88.8, 4096);
Query OK, 9 rows affected (0.14 sec)
mysql>
mysql> select * from monitor where env='test' and host='host3';
+------+-------+---------------------+------+--------+
| env | host | ts | cpu | memory |
+------+-------+---------------------+------+--------+
| test | host3 | 2022-06-15 15:02:38 | 77.7 | 2048 |
| test | host3 | 2022-06-15 15:02:39 | 88.8 | 4096 |
+------+-------+---------------------+------+--------+
2 rows in set (0.20 sec)
```

0 comments on commit 9859e8b

Please sign in to comment.