Skip to content

Commit

Permalink
docs:update the compile guides stoneatom#1562
Browse files Browse the repository at this point in the history
  • Loading branch information
augety committed Apr 14, 2023
1 parent 45e75ee commit a84a827
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Ensure that the tools and third-party libraries used in your environment meet th
* Boost 1.77

## Procedure

:::info
When executing following commands, you may run into peimission issues, so using 'sudo' is a good idea.
:::
### Step 1. Install the dependencies

```bash
Expand Down Expand Up @@ -72,11 +74,9 @@ sudo aptitude install libssl-dev
:::

### Step 2. Install third-party dependencies

If your ubuntu version >= 20.04, skip to install marisa.
1.If cmake version < 3.72, install CMake
Check your CMake version first.

StoneDB is dependent on marisa, RocksDB, and Boost. You are advised to specify paths for saving these libraries when you install them, instead of using the default paths.
#### 1. Install cmake
Check your CMake version first. If your cmake version < 3.72, install cmake
```bash
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
tar -zxvf cmake-3.7.2.tar.gz
Expand All @@ -98,8 +98,8 @@ If your gcc version too high, it may cause the compilation to fail. You can add
```
:::

2.If make version < 3.82, install Make
Check your make version first.
#### 2. Install make
If your make version < 3.82, install make

```bash
wget http://mirrors.ustc.edu.cn/gnu/make/make-3.82.tar.gz
Expand All @@ -112,7 +112,7 @@ ln -s /usr/local/make/bin/make /usr/local/bin/make
make --version
```

3.Install marisa
#### 3. Install marisa

```bash
git clone https://github.com/s-yata/marisa-trie.git
Expand All @@ -135,7 +135,7 @@ lrwxrwxrwx 1 root root 18 Mar 20 16:25 libmarisa.so.0 -> libmarisa.so.0.0.0
drwxrwxr-x 2 root root 4096 Mar 20 16:25 pkgconfig
```

4.Install RocksDB
#### 4. Install RocksDB

```bash
wget https://github.com/facebook/rocksdb/archive/refs/tags/v6.12.6.tar.gz
Expand Down Expand Up @@ -188,7 +188,7 @@ lrwxrwxrwx 1 root root 20 Mar 20 17:12 librocksdb.so.6 -> librocksdb.so.6.
-rw-r--r-- 1 root root 9490272 Mar 20 17:12 librocksdb.so.6.12.6
```

5.Install Boost
#### 5. Install Boost

```bash
wget https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.gz
Expand Down Expand Up @@ -246,7 +246,7 @@ lrwxrwxrwx 1 root root 25 Mar 20 18:56 libboost_locale.so -> libboost_loca
-rwxrwxr-x 1 root root 1177200 Mar 20 18:56 libboost_locale.so.1.77.0
```

6.Install Gtest
#### 6.Install Gtest

```bash
sudo git clone https://github.com/google/googletest.git -b release-1.12.0
Expand Down Expand Up @@ -278,10 +278,9 @@ git clone https://github.com/stoneatom/stonedb.git
```

Before compilation, modify the compilation script as follows:

Change the installation directory of StoneDB based on your actual conditions. In the example, `/stonedb/`is used.
Change the installation directories of marisa, RocksDB, and Boost based on your actual conditions.

:::info
You cna change the installation directory of StoneDB based on your actual conditions. In this example, `/stonedb/`is used. Remember to change the installation directories of marisa, RocksDB, and Boost based on your actual conditions.
:::
```bash
cd stonedb
git checkout -b 8.0 origin/stonedb-8.0-dev
Expand Down Expand Up @@ -310,33 +309,11 @@ You need to manually create directories, and then initialize and start StoneDB.
```bash
cd ../install8
### Create directories.
mkdir -p /stonedb/build/install8/data
mkdir -p /stonedb/build/install8/binlog
mkdir -p /stonedb/build/install8/log
mkdir -p /stonedb/build/install8/tmp
mkdir -p /stonedb/build/install8/redolog
mkdir -p /stonedb/build/install8/undolog
sudo mkdir data binlog log tmp redolog undolog

### Configure parameters in my.cnf.
mv my.cnf my.cnf.bak
vim /stonedb/install8/my.cnf
[client]
port = 3306
socket = /stonedb/build/install8/tmp/mysql.sock

[mysqld]
port = 3306
basedir = /stonedb/build/install8/
character-sets-dir = /stonedb/build/install8/share/charsets/
lc-messages-dir = /stonedb/build/install8/share/
plugin_dir = /stonedb/build/install8/lib/plugin/
tmpdir = /stonedb/build/install8/tmp/
socket = /stonedb/build/install8/tmp/mysql.sock
datadir = /stonedb/build/install8/data/
pid-file = /stonedb/build/install8/data/mysqld.pid
log-error = /stonedb/build/install8/log/mysqld.log
lc-messages-dir = /stonedb/build/install8/share/english/
local-infile
sudo cp ../../scripts/my.cnf.sample my.cnf
sudo sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf

### Initialize StoneDB.
sudo ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
Expand All @@ -349,8 +326,9 @@ sudo ./bin/mysqld --user=root &

```bash
./bin/mysql -uroot
use mysql;
### user='root' password='stonedb123'
alter user 'root'@'localhost' identified by 'stonedb123';
update user set host='%' where user='root';
### set the password of user root to stonedb123
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
Query OK, 0 rows affected
### allow remote access
mysql> update user set host='%' where user='root';
```
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ sidebar_position: 5.151
* RocksDB 6.12.6
* Boost 1.77

### 第一步:安装依赖包
:::info
以下命令的执行可能会遇到权限问题,建议在管理员权限下运行,或者使用 sudo
:::

## 第一步:安装依赖包

```bash
sudo apt install -y gcc
sudo apt install -y gcc
sudo apt install -y g++
sudo apt install -y make
sudo apt install -y cmake
Expand Down Expand Up @@ -68,12 +72,10 @@ sudo aptitude install libssl-dev
```
:::

### 第二步:安装第三方库

如果你的 ubuntu 版本 >= 20.04, 你可以直接跳至安装marisa.
1.如果你的cmake 版本 < 3.72, 安装 CMake, 否则跳过
注意先检查你的CMake版本.

## 第二步:安装第三方库
StoneDB 依赖 marisa、rocksdb、boost,在编译 marisa、rocksdb、boost 时,建议指定安装路径。示例中我们指定了 marisa、rocksdb、boost 的安装路径,你可以根据自己的需求更改安装路径。
### 1. 安装 cmake
注意检查你的 cmake 版本,如果你的cmake 版本 < 3.72, 安装 cmake
```bash
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
tar -zxvf cmake-3.7.2.tar.gz
Expand All @@ -94,9 +96,8 @@ cmake --version
```
:::

2.如果你的make版本 < 3.82, 安装Make
注意先检查你的Make版本.

### 2. 安装 make
注意检查你的Make版本,如果你的make版本 < 3.82, 安装 make
```bash
wget http://mirrors.ustc.edu.cn/gnu/make/make-3.82.tar.gz
tar -zxvf make-3.82.tar.gz
Expand All @@ -108,8 +109,7 @@ ln -s /usr/local/make/bin/make /usr/local/bin/make
make --version
```

3.安装marisa

### 3. 安装marisa
```bash
git clone https://github.com/s-yata/marisa-trie.git
cd marisa-trie
Expand All @@ -131,7 +131,7 @@ lrwxrwxrwx 1 root root 18 Mar 20 16:25 libmarisa.so.0 -> libmarisa.so.0.0.0
drwxrwxr-x 2 root root 4096 Mar 20 16:25 pkgconfig
```

4.安装RocksDB
### 4. 安装RocksDB

```bash
wget https://github.com/facebook/rocksdb/archive/refs/tags/v6.12.6.tar.gz
Expand Down Expand Up @@ -184,7 +184,7 @@ lrwxrwxrwx 1 root root 20 Mar 20 17:12 librocksdb.so.6 -> librocksdb.so.6.
-rw-r--r-- 1 root root 9490272 Mar 20 17:12 librocksdb.so.6.12.6
```

5.安装Boost
### 5. 安装Boost

```bash
wget https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.gz
Expand Down Expand Up @@ -242,7 +242,7 @@ lrwxrwxrwx 1 root root 25 Mar 20 18:56 libboost_locale.so -> libboost_loca
-rwxrwxr-x 1 root root 1177200 Mar 20 18:56 libboost_locale.so.1.77.0
```

6.安装Gtest
### 6. 安装Gtest

```bash
sudo git clone https://github.com/google/googletest.git -b release-1.12.0
Expand All @@ -264,7 +264,7 @@ ls /usr/local/lib64/ # 64-bit os
...... cmake libgtest.a libgtest_main.a
```

### 第三步:编译StoneDB
## 第三步:编译StoneDB

现在StoneDB有三个分支: StoneDB-5.6 (for MySQL 5.6)、 StoneDB-5.7 (for MySQL 5.7) and StoneDB-8.0 (for MySQL 8.0). 本文安装的是StoneDB-8.0. 在本例中源代码保存在/目录中.

Expand All @@ -274,9 +274,9 @@ git clone https://github.com/stoneatom/stonedb.git
```

在编译前, 像下文一样更改编译脚本:

将安装目录改为你的实际安装目录. 本例中用的是`/stonedb/`.
将marisa, RocksDB, and Boost的路径改为你的这三个库的实际安装路径.
:::info
你可以根据自己的需求将安装目录更改为你的实际安装目录, 本例中用的是`/stonedb/`,记得将marisa, RocksDB, 和 Boost的路径改为你的这三个库的实际安装路径.
:::

```bash
cd stonedb
Expand All @@ -299,54 +299,32 @@ make -j`nproc`
make install -j`nproc`
```

### 第四步:启动StoneDB
## 第四步:启动StoneDB

你需要手动创建几个目录, 然后初始化并启动StoneDB. 你还需要填写你的配置文件my.cnf, 包括安装目录和端口.

```bash
cd ../install8
### Create directories.
mkdir -p /stonedb/build/install8/data
mkdir -p /stonedb/build/install8/binlog
mkdir -p /stonedb/build/install8/log
mkdir -p /stonedb/build/install8/tmp
mkdir -p /stonedb/build/install8/redolog
mkdir -p /stonedb/build/install8/undolog

### Configure parameters in my.cnf.
mv my.cnf my.cnf.bak
vim /stonedb/install8/my.cnf
[client]
port = 3306
socket = /stonedb/build/install8/tmp/mysql.sock

[mysqld]
port = 3306
basedir = /stonedb/build/install8/
character-sets-dir = /stonedb/build/install8/share/charsets/
lc-messages-dir = /stonedb/build/install8/share/
plugin_dir = /stonedb/build/install8/lib/plugin/
tmpdir = /stonedb/build/install8/tmp/
socket = /stonedb/build/install8/tmp/mysql.sock
datadir = /stonedb/build/install8/data/
pid-file = /stonedb/build/install8/data/mysqld.pid
log-error = /stonedb/build/install8/log/mysqld.log
lc-messages-dir = /stonedb/build/install8/share/english/
local-infile

### Initialize StoneDB.
### 新建目录
sudo mkdir data binlog log tmp redolog undolog

### 配置my.cnf
sudo cp ../../scripts/my.cnf.sample my.cnf
sudo sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf

### 初始化StoneDB
sudo ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure

### Start StoneDB.
### 启动StoneDB
sudo ./bin/mysqld --user=root &
```

### 登录 StoneDB

## 第五步:登录 StoneDB
```bash
./bin/mysql -uroot
use mysql;
### user='root' password='stonedb123'
alter user 'root'@'localhost' identified by 'stonedb123';
update user set host='%' where user='root';
### 设置用户 root 的密码为 'stonedb123'
mysql> alter user 'root'@'localhost' identified by 'stonedb123';
Query OK, 0 rows affected
### 允许远程访问
mysql> update user set host='%' where user='root';
```

0 comments on commit a84a827

Please sign in to comment.