Skip to content

Commit

Permalink
docs:add docker compile guide of stonedb8.0.(#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
augety authored and mergify[bot] committed May 17, 2023
1 parent 65585be commit 20abfc7
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 5.16,
"label": "Compile StoneDB in Docker",
"collapsible": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
id: compile-using-docker
sidebar_position: 5.16
id: compile-using-docker-for-56-57
sidebar_position: 5.161
---

# Compile StoneDB in a Docker Container
# Compile StoneDB 5.7 in a Docker Container
## Introduction
Compiling StoneDB on a physical server requires installation of third-party repositories, which is complicated. In addition, if the OS in your environment is Fedora or Ubuntu, you also need to install many dependencies. We recommend that you compile StoneDB in a Docker container. After StoneDB is compiled, you can directly run StoneDB in the container or copy the compilation files to your environment.
## Prerequisites
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: compile-using-docker-for-80
sidebar_position: 5.162
---

# Compile StoneDB 8.0 in a Docker Container
## Introduction
Compiling StoneDB on a physical server requires installation of third-party repositories, which is complicated. In addition, if the OS in your environment is Fedora or Ubuntu, you also need to install many dependencies. We recommend that you compile StoneDB in a Docker container. After StoneDB is compiled, you can directly run StoneDB in the container or copy the compilation files to your environment.

## Prerequisites
Docker has been installed. For information about how to install Docker, visit [https://docs.docker.com/engine/install/ubuntu/](https://docs.docker.com/engine/install/ubuntu/).

## Procedure
The url of our image:[stoneatom/stonedb80_buildenv](https://hub.docker.com/r/stoneatom/stonedb80_buildenv)

### Pull image from dockerhub
```bash
$ docker pull stoneatom/stonedb80_buildenv
# show all images
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
stoneatom/stonedb80_buildenv latest cc644347ffed 7 months ago 771MB
```

### Launch a container & Get into it
```bash
# docker run parameter description
# -v Directory mounting. Specify the directory on the host first and then the directory in the container.
# -p Port mapping. Specify the port on the host first and then the port in the container.It can allow connection
# from outside the container.
$ docker run -v /home/src/:/home/ -p 23306:3306 -it stoneatom/stonedb80_buildenv /bin/bash
```

### Download source code & Compile and Install
```bash
root@71a1384e5ee3:/home# git clone -b stonedb-8.0-dev https://github.com/stoneatom/stonedb.git

root@fb0bf0c54de0:/home# cd stonedb
root@fb0bf0c54de0:/home/stonedb# mkdir build
root@fb0bf0c54de0:/home/stonedb# cd build
# The intall directory here is /stonedb8/install,you can change it by yourself
root@fb0bf0c54de0:/home/stonedb/build# cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/stonedb8/install \
-DMYSQL_DATADIR=/stonedb8/install/data \
-DSYSCONFDIR=/stonedb8/install \
-DMYSQL_UNIX_ADDR=/stonedb8/install/tmp/mysql.sock \
-DWITH_BOOST=/usr/local/stonedb-boost \
-DWITH_MARISA=/usr/local/stonedb-marisa \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb

root@fb0bf0c54de0:/home/stonedb/build# make -j `nproc` && make install -j`nproc`
```

### Initialize & Start StoneDB
```bash
root@fb0bf0c54de0:/home/stonedb/build# cd /stonedb8/install
# Create directories
root@fb0bf0c54de0:/stonedb8/install# mkdir data binlog log tmp redolog undolog
# Configure parameters in my.cnf
root@fb0bf0c54de0:/stonedb8/install# cp /home/stonedb/scripts/my.cnf.sample my.cnf
root@fb0bf0c54de0:/stonedb8/install# sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf
# Initialize StoneDB.
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
# Start StoneDB
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --user=root &
```

### Login StoneDB
```bash
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysql -uroot
# Set the password of user root to stonedb123
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
# Allow remote access
mysql> use mysql;
mysql> update user set host='%' where user='root';
```
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,6 @@ sudo ./bin/mysqld --user=root &
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
Query OK, 0 rows affected
### allow remote access
mysql> use mysql;
mysql> update user set host='%' where user='root';
```
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
id: compile-using-docker
sidebar_position: 5.16
id: compile-using-docker-for-56-57
sidebar_position: 5.161
---

# Docker 下编译使用 StoneDB
# Docker 下编译使用 StoneDB 5.7
## 环境简介
由于编译环境搭建第三方库较为繁琐,且Fedora,Ubuntu等环境编译存在大量依赖缺失,需要补充安装依赖,搭建麻烦,所以搭建一个Docker Centos 编译环境容器,可以通过Docker 容器快速编译StoneDB,解决编译环境搭建繁琐问题,也可以通过Docker 容器编译后直接启动StoneDB进行调试使用。

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
id: compile-using-docker-for-80
sidebar_position: 5.162
---

# Docker 下编译使用 StoneDB 8.0
## 环境简介
由于编译环境搭建第三方库较为繁琐,且Fedora,Ubuntu等环境编译存在大量依赖缺失,需要补充安装依赖,搭建麻烦,所以搭建一个Docker Centos 编译环境容器,可以通过Docker 容器快速编译StoneDB,解决编译环境搭建繁琐问题,也可以通过Docker 容器编译后直接启动StoneDB进行调试使用。

## Docker 编译环境搭建使用步骤
本搭建文档需要提前安装好Docker,Docker 安装请参考Docker官方文档[https://docs.docker.com/engine/install/ubuntu/](https://docs.docker.com/engine/install/ubuntu/)

### 获取镜像
Docker hub镜像地址:[stoneatom/stonedb80_buildenv](https://hub.docker.com/r/stoneatom/stonedb80_buildenv)
```bash
# 从 dockerhub 获取镜像
$ docker pull stoneatom/stonedb80_buildenv
# 查看docker 镜像
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
stoneatom/stonedb80_buildenv latest cc644347ffed 7 months ago 771MB
```

### 启动一个容器并进入
```bash
# docker run 参数说明
# -v 目录挂载,前面是宿主机目录,后面是容器内目录,宿主机目录为stonedb源码父目录路径,本文档以/home/src路径为示例
# -p 端口映射,前面是宿主机端口,后面是容器端口,设置端口映射使得可以在容器外连接容器内的数据库服务端
$ docker run -v /home/src/:/home/ -p 23306:3306 -it stoneatom/stonedb80_buildenv /bin/bash
```

### 获取 StoneDB 8.0 源码,编译安装
```bash
root@71a1384e5ee3:/home# git clone -b stonedb-8.0-dev https://github.com/stoneatom/stonedb.git

root@fb0bf0c54de0:/home# cd stonedb
root@fb0bf0c54de0:/home/stonedb# mkdir build
root@fb0bf0c54de0:/home/stonedb# cd build
# 本文档安装路径以/stonedb8/install为例,你可以另外指定安装路径
root@fb0bf0c54de0:/home/stonedb/build# cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/stonedb8/install \
-DMYSQL_DATADIR=/stonedb8/install/data \
-DSYSCONFDIR=/stonedb8/install \
-DMYSQL_UNIX_ADDR=/stonedb8/install/tmp/mysql.sock \
-DWITH_BOOST=/usr/local/stonedb-boost \
-DWITH_MARISA=/usr/local/stonedb-marisa \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb

root@fb0bf0c54de0:/home/stonedb/build# make -j `nproc` && make install -j`nproc`
```

### 初始化并启动StoneDB
```bash
root@fb0bf0c54de0:/home/stonedb/build# cd /stonedb8/install
# 新建目录
root@fb0bf0c54de0:/stonedb8/install# mkdir data binlog log tmp redolog undolog
# 配置 my.cnf
root@fb0bf0c54de0:/stonedb8/install# cp /home/stonedb/scripts/my.cnf.sample my.cnf
root@fb0bf0c54de0:/stonedb8/install# sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf
# 初始化
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
# 启动
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --user=root &
```

### 登录 StoneDB
```bash
root@fb0bf0c54de0:/stonedb8/install# ./bin/mysql -uroot
# 设置用户 root 的密码为 'stonedb123'
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
# 允许远程访问
mysql> use mysql;
mysql> update user set host='%' where user='root';
```
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,6 @@ sudo ./bin/mysqld --user=root &
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
Query OK, 0 rows affected
### 允许远程访问
mysql> use mysql;
mysql> update user set host='%' where user='root';
```

0 comments on commit 20abfc7

Please sign in to comment.