Skip to content

Commit

Permalink
doc(develop-guide): modify method for complie stonedb using docker
Browse files Browse the repository at this point in the history
1. change the version of the stonedb from 5.6 to 5.7 in docs.
2. list both manual install and automatic install in docs.
3. update the reference in zh-doc to a valid one:
可以参考:[StoneDB快速部署手册](https://stonedb.io/zh/docs/getting-started/quick-deployment)
可以参考:[StoneDB快速部署手册](https://stonedb.io/zh/docs/quick-deployment)
  • Loading branch information
Dysprosium0626 authored and mergify[bot] committed May 12, 2023
1 parent c3931fe commit 65585be
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 99 deletions.
134 changes: 71 additions & 63 deletions Docs/04-developer-guide/00-compiling-methods/compile-using-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,72 +159,80 @@ After the `make` commands are successful, you can choose either to compress the
### Compress compilation files to a TAR file
```bash
# Compress the 'home' folder to a TAR file and mount the TAR file to a directory outside the container.
[root@06f1f385d3b3 build]# tar -zcPvf /home/stonedb56.tar.gz /stonedb56/
[root@06f1f385d3b3 build]# tar -zcPvf /home/stonedb57.tar.gz /stonedb57/
```
### Directly use StoneDB in the container
You can refer to [Quick Deployment](.../../../../02-getting-started/quick-deployment/quick-deployment-56.md) or the following code to deploy and use StoneDB in the container.
```bash
[root@06f1f385d3b3 build]# cd /stonedb56/install/

[root@06f1f385d3b3 install]# groupadd mysql

[root@06f1f385d3b3 install]# useradd -g mysql mysql

[root@06f1f385d3b3 install]# ll
total 180
-rw-r--r--. 1 root root 17987 Jun 8 03:41 COPYING
-rw-r--r--. 1 root root 102986 Jun 8 03:41 INSTALL-BINARY
-rw-r--r--. 1 root root 2615 Jun 8 03:41 README
drwxr-xr-x. 2 root root 4096 Jun 8 06:16 bin
drwxr-xr-x. 3 root root 18 Jun 8 06:16 data
drwxr-xr-x. 2 root root 55 Jun 8 06:16 docs
drwxr-xr-x. 3 root root 4096 Jun 8 06:16 include
-rwxr-xr-x. 1 root root 267 Jun 8 03:41 install.sh
drwxr-xr-x. 3 root root 272 Jun 8 06:16 lib
drwxr-xr-x. 4 root root 30 Jun 8 06:16 man
drwxr-xr-x. 10 root root 4096 Jun 8 06:16 mysql-test
-rwxr-xr-x. 1 root root 12516 Jun 8 03:41 mysql_server
-rwxr-xr-x. 1 root root 764 Jun 8 03:41 reinstall.sh
drwxr-xr-x. 2 root root 57 Jun 8 06:16 scripts
drwxr-xr-x. 28 root root 4096 Jun 8 06:16 share
drwxr-xr-x. 4 root root 4096 Jun 8 06:16 sql-bench
-rw-r--r--. 1 root root 5526 Jun 8 03:41 stonedb.cnf
drwxr-xr-x. 2 root root 136 Jun 8 06:16 support-files
[root@06f1f385d3b3 install]# ./reinstall.sh

...

# If the following information is returned, StoneDB is started.
+ log_success_msg
+ /etc/redhat-lsb/lsb_log_message success
/etc/redhat-lsb/lsb_log_message: line 3: /etc/init.d/functions: No such file or directory
/etc/redhat-lsb/lsb_log_message: line 11: success: command not found

+ return 0
+ return_value=0
+ test -w /var/lock/subsys
+ touch /var/lock/subsys/mysql
+ exit 0


# Reset the password of local user 'root'.
[root@06f1f385d3b3 install]# /stonedb56/install/bin/mysqladmin flush-privileges -u root password "*******"
Warning: Using a password on the command line interface can be insecure.
# Create a username and password for remote connection.
[root@06f1f385d3b3 install]# /stonedb56/install/bin/mysql -uroot -p*******
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.24-StoneDB-log build-
You can refer to [Quick Deployment](.../../../../02-getting-started/quick-deployment/quick-deployment-57.md) or the following code to deploy and use StoneDB in the container.
### 1. Create an account
```shell
groupadd mysql
useradd -g mysql mysql

# Here are the optional execution statements
passwd mysql
```
### 2. Manually install StoneDB
You need to manually create directories, configure the parameter file, and then initialize and start StoneDB.
```shell
### Create directories.
mkdir -p /stonedb57/install/data
mkdir -p /stonedb57/install/binlog
mkdir -p /stonedb57/install/log
mkdir -p /stonedb57/install/tmp
mkdir -p /stonedb57/install/redolog
mkdir -p /stonedb57/install/undolog
chown -R mysql:mysql /stonedb57

### Configure my.cnf.
mv my.cnf my.cnf.bak
vim /stonedb57/install/my.cnf
[mysqld]
port = 3306
socket = /stonedb57/install/tmp/mysql.sock
basedir = /stonedb57/install
datadir = /stonedb57/install/data
pid_file = /stonedb57/install/data/mysqld.pid
log_error = /stonedb57/install/log/mysqld.log
innodb_log_group_home_dir = /stonedb57/install/redolog/
innodb_undo_directory = /stonedb57/install/undolog/

chown -R mysql:mysql /stonedb57/install/my.cnf

### Initialize StoneDB.
/stonedb57/install/bin/mysqld --defaults-file=/stonedb57/install/my.cnf --initialize --user=mysql

### Start StoneDB.
/stonedb57/install/bin/mysqld_safe --defaults-file=/stonedb57/install/my.cnf --user=mysql &
```
### 3. Automatically install StoneDB
The process of executing the **reinstall.sh** script is to initialize and start the StoneDB.
```shell
cd /stonedb57/install
./reinstall.sh
```
:::info
Differences between **reinstall.sh** and **install.sh**:
Copyright (c) 2000, 2022 StoneAtom Group Holding Limited
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- **reinstall.sh** is the script for automatic installation. When the script is being executed, directories are created, and StoneDB is initialized and started. Therefore, do not execute the script unless for the initial startup of StoneDB. Otherwise, all directories will be deleted and StoneDB will be initialized again.
- **install.sh** is the script for manual installation. You can specify the installation directories based on your needs and then execute the script. Same as reinstall.sh, when the script is being executed, directories are created, and StoneDB is initialized and started. Therefore, do not execute the script unless for the initial startup. Otherwise, all directories will be deleted and StoneDB will be initialized again.
:::
mysql> grant all ON *.* to root@'%' identified by '********';
Query OK, 0 rows affected (0.00 sec)
### 4. Log in to StoneDB
```shell
cat /stonedb57/install/log/mysqld.log |grep password
[Note] A temporary password is generated for root@localhost: ceMuEuj6l4+!

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
/stonedb57/install/bin/mysql -uroot -p -S /stonedb57/install/tmp/mysql.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36-StoneDB-debug-log build-

```
After you start StoneDB in the container, you can log in to and use StoneDB or run the `docker run -p <port mapping>` command to connect to StoneDB.
Copyright (c) 2021, 2022 StoneAtom Group Holding Limited
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified by 'stonedb123';
# Allow root user to log in remotely
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'stonedb123' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
```
Original file line number Diff line number Diff line change
Expand Up @@ -114,44 +114,56 @@ CONTAINER ID IMAGE COMMAND CREATED
[root@06f1f385d3b3 build]# tar -zcPvf /home/stonedb57.tar.gz /stonedb57/
```
### 2、容器中直接部署试用StoneDB
可以参考:[StoneDB快速部署手册](https://stonedb.io/zh/docs/getting-started/quick-deployment)
可以参考:[StoneDB快速部署手册](https://stonedb.io/zh/docs/quick-deployment)
或者在容器中参考以下方法快速部署进行试用。
```bash
#进入编译安装的StoneDB install目录,以stonedb57为例
[root@06f1f385d3b3 build]# cd /stonedb57/install/

[root@06f1f385d3b3 install]# groupadd mysql

[root@06f1f385d3b3 install]# useradd -g mysql mysql

[root@06f1f385d3b3 install]# ll
total 180
-rw-r--r--. 1 root root 17987 Jun 8 03:41 COPYING
-rw-r--r--. 1 root root 102986 Jun 8 03:41 INSTALL-BINARY
-rw-r--r--. 1 root root 2615 Jun 8 03:41 README
drwxr-xr-x. 2 root root 4096 Jun 8 06:16 bin
drwxr-xr-x. 3 root root 18 Jun 8 06:16 data
drwxr-xr-x. 2 root root 55 Jun 8 06:16 docs
drwxr-xr-x. 3 root root 4096 Jun 8 06:16 include
-rwxr-xr-x. 1 root root 267 Jun 8 03:41 install.sh
drwxr-xr-x. 3 root root 272 Jun 8 06:16 lib
drwxr-xr-x. 4 root root 30 Jun 8 06:16 man
drwxr-xr-x. 10 root root 4096 Jun 8 06:16 mysql-test
-rwxr-xr-x. 1 root root 12516 Jun 8 03:41 mysql_server
-rwxr-xr-x. 1 root root 764 Jun 8 03:41 reinstall.sh
drwxr-xr-x. 2 root root 57 Jun 8 06:16 scripts
drwxr-xr-x. 28 root root 4096 Jun 8 06:16 share
drwxr-xr-x. 4 root root 4096 Jun 8 06:16 sql-bench
-rw-r--r--. 1 root root 5526 Jun 8 03:41 stonedb.cnf
drwxr-xr-x. 2 root root 136 Jun 8 06:16 support-files

[root@06f1f385d3b3 install]# ll {data,binlog,log,tmp,redolog,undolog}
[root@06f1f385d3b3 install]# mkdir -p ./{data/innodb,binlog,log,tmp,redolog,undolog}

[root@06f1f385d3b3 install]# chown -R mysql:mysql *
#### 2.1. 创建用户
```shell
groupadd mysql
useradd -g mysql mysql
passwd mysql
```
#### 2.2. 手动安装
手动创建目录、初始化和启动实例,还需要配置 my.cnf 文件,如安装目录,端口等参数。
```shell
###创建目录
mkdir -p /stonedb57/install/data
mkdir -p /stonedb57/install/binlog
mkdir -p /stonedb57/install/log
mkdir -p /stonedb57/install/tmp
mkdir -p /stonedb57/install/redolog
mkdir -p /stonedb57/install/undolog
chown -R mysql:mysql /stonedb57

###配置my.cnf
mv my.cnf my.cnf.bak
vim /stonedb57/install/my.cnf
[mysqld]
port = 3306
socket = /stonedb57/install/tmp/mysql.sock
basedir = /stonedb57/install
datadir = /stonedb57/install/data
pid_file = /stonedb57/install/data/mysqld.pid
log_error = /stonedb57/install/log/mysqld.log
innodb_log_group_home_dir = /stonedb57/install/redolog/
innodb_undo_directory = /stonedb57/install/undolog/

chown -R mysql:mysql /stonedb57/install/my.cnf

###初始化实例
/stonedb57/install/bin/mysqld --defaults-file=/stonedb57/install/my.cnf --initialize --user=mysql

###启动实例
/stonedb57/install/bin/mysqld_safe --defaults-file=/stonedb57/install/my.cnf --user=mysql &
```
#### 2.3. 自动安装
编译完成后,在安装目录下会自动生成 reinstall.sh、install.sh 和 my.cnf 文件,执行 reinstall.sh 就是创建目录、初始化实例和启动实例的过程。
```shell
cd /stonedb57/install
./reinstall.sh
```
#### 2.4 执行登录
StoneDB56 和StoneDB57安装部署的区别在于初始化数据和重置密码上,在初始化过程中如果遇到问题建议先自行排查log/mysqld.log ,是否有报错信息,如无法自行解决,请提供StoneDB版本信息,Docker image 版本和报错日志,StoneDB版本信息到我们社区或者github 提交issues。
### StoneDB56参考
##### StoneDB56参考
```bash
[root@06f1f385d3b3 install]# ./scripts/mysql_install_db --defaults-file=./my.cnf --user=mysql --basedir=/stonedb56/install --datadir=/stonedb56/install/data
To do so, start the server, then issue the following commands:
Expand Down Expand Up @@ -196,7 +208,7 @@ Query OK, 0 rows affected (0.00 sec)


```
### StoneDB57参考
##### StoneDB57参考
```bash

[root@06f1f385d3b3 install]# ./bin/mysqld --defaults-file=./my.cnf --initialize --user=mysql
Expand Down

0 comments on commit 65585be

Please sign in to comment.