Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create MyTopling 编译文档.md #4

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions BUILD-mytopling-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
在编译 MyTopling 之前,我们首先需要安装一些依赖,并编译 ToplingDB。

## 1. 环境配置

**本文所使用的机器为阿里云的 ECS,系统为 Alibaba Cloud Linux 3.2104 LTS 64位。**
\-
安装 `liburing-devel`

安装下列包:

```shell
yum -y install liburing-devel \
openssl-devel \
ncurses-devel \
libtirpc-devel \
rpcgen \
bison \
libudev-devel \
git \
gcc-c++ \
gflags-devel \
libaio-devel \
cmake
```

> 如果提示找不到 `liburing-devel` 包,尝试下面命令后再次安装:
>
> `yum config-manager --set-enabled powertool`

## 2. 编译 ToplingDB

```shell
git clone --depth=1 https://github.com/topling/toplingdb.git
cd toplingdb
git submodule update --init --recursive
make -j`nproc` DEBUG_LEVEL=0 shared_lib
make install-shared
```

上面 `make install-shared` 有可选变量 `PREFIX` 和 `LIBDIR`项:

- `PREFIX`:默认为 `/usr/local`,为 ToplingDB 的安装位置。

- `LIBDIR`:默认为 `${PREFIX}/lib`,即 `/usr/local/lib`。

## 3. 编译 MyTopling

我们需要保证,clone 下来的 MyTopling 目录,与刚刚 clone 的 ToplingDB 目录同级。

```shell
git clone --depth=1 https://github.com/topling/mytopling.git
cd mytopling
git submodule update --init --recursive
export CXX_HOME=/usr
bash build.sh -DTOPLING_LIB_DIR=/path/to/LIBDIR \
-DCMAKE_INSTALL_PREFIX=/path/to/mytopling/install/dir
```

`DTOPLING_LIB_DIR` 和 `DCMAKE_INSTALL_PREFIX` 是必选项:

- `DTOPLING_LIB_DIR`:即为上面 ToplingDB 编译时的 `LIBDIR`。

- `DCMAKE_INSTALL_PREFIX`:指定 MyToplingDB 的安装位置。

如果编译 ToplingDB 的时候没有指定 `PREFIX` 和 `LIBDIR`,那么这里 `DTOPLING_LIB_DIR` 应当为 `/usr/local`。`DCMAKE_INSTALL_PREFIX` 可以和 ToplingDB 一起放在 `/usr/local` 目录下,即这里最后一个语句可以为:

```shell
bash build.sh -DTOPLING_LIB_DIR=/usr/local/lib \
-DCMAKE_INSTALL_PREFIX=/usr/local
```

上面的过程会在当前目录生成一个 `build-rls` 目录,我们执行下面的内容:

```shell
cd build-rls
export LD_LIBRARY_PATH=`pwd`/lib:`pwd`/lib/plugin:plugin_output_directory
make -j`nproc`
make install
```

到此,编译完成。



## 4. 运行 MyTopling



### 4.1. 下载脚本与配置文件



下载链接:https://github.com/topling/mytopling/conf

```
conf_mysqld.sh
init_mysqld.sh
start_mysqld.sh
mytopling.json
```

建议将这四个文件放在同一目录下(不然需要自行修改路径相关的配置),后面逐个说明需要编辑修改的内容。

我这里在 `/root/topling` 下。



### 4.2. 初始化



首先确定一个启动 MyTopling 的位置,我这里是 `/root/topling`:

```
cd /root/topling
```

然后确定一个数据存放位置,我这里是 `/root/mytopling/data`:

创建数据目录:

```shell
mkdir -p /root/mytopling/data
```

执行初始化脚本:

```shell
bash init_mysqld.sh
```



### 4.3. 配置并运行



将 `mytopling.json` 中的 `http`-> `document_root` 字段修改为上面的数据目录字段。为了安全起见,可以为 log (mysql log, toplingdb log) 设置单独的目录,然后将 document_root 设置到 log 目录,如果不想通过 web 访问 log 文件,就不要设置 document_root。

然后执行启动脚本:

```shell
bash start_mysqld.sh
```



最后输出如下表示成功:

```
2022-11-04T10:37:59.557896Z 0 [System] [MY-010931] [Server] /home/terark/topling/mytopling-install/bin/mysqld: ready for connections. Version: '8.0.28' socket: '/tmp/mysql.sock' port: 3306 MyTopling Enterprise.
```













92 changes: 92 additions & 0 deletions mytopling-conf/conf_mysqld.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash:

# type is env var
if [ -z "${type}" ]; then
type=rls
fi
mydir=`dirname $0`
mydir=`cd $mydir; pwd`

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64/
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64/
export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/10/:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib/mysqlrouter:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib/plugin:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib/private:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
#export LD_LIBRARY_PATH=/node-shared/opt/lib:${LD_LIBRARY_PATH}
export PATH=/usr/local/bin:${PATH}
export ROCKSDB_KICK_OUT_OPTIONS_FILE=1
export TOPLING_SIDEPLUGIN_CONF=${mydir}/mytopling.json
export JsonOptionsRepo_DebugLevel=2
export csppDebugLevel=0
export TOPLINGDB_CACHE_SST_FILE_ITER=1
#export TOPLINGDB_WARMUP_PROVIDER=mlock
#export MULTI_PROCESS=1
#export ZipServer_nltBuildThreads=5
#export ZIP_SERVER_OPTIONS=listening_ports=8090:num_threads=32
export BULK_LOAD_DEL_TMP=0

datadir=/root/mytopling/data
#datadir=/nvme-shared/mytopling/lifuzhou-data/test_data
rm -rf ${datadir}/.rocksdb/job-*
ulimit -n 100000

common_args=(
--gdb
#--skip-stack-trace
--datadir=${datadir}
--bind-address=0.0.0.0
--disabled_storage_engines=myisam
#--have_openssl=DISABLED
#--have_ssl=DISABLED
--host_cache_size=644
--internal_tmp_mem_storage_engine=MEMORY
--join_buffer_size=1048576
--key_buffer_size=16777216
--max_binlog_size=524288000
--max_connections=8000
--max_heap_table_size=67108864
--read_buffer_size=1048576
--skip_name_resolve=ON
--table_open_cache=8192
--thread_cache_size=200
#--thread_handling=pool-of-threads
--enable_optimizer_cputime_with_wallclock=on
--optimizer_switch=mrr=on,mrr_cost_based=off
--performance_schema=off
#--default_authentication_plugin=mysql_native_password
--secure_file_priv=''
)
dram=`awk '$1 == "MemTotal:"{print $2*1024}' /proc/meminfo`
part=`nproc`
part=$((part<64?part:64)) # innodb_buffer_pool_instances max is 64
innodb_args1=(
#--innodb_dedicated_server
--innodb_flush_log_at_trx_commit=0
--innodb_buffer_pool_chunk_size=$((dram/2/part))
--innodb_buffer_pool_instances=${part}
--innodb_buffer_pool_size=$((dram/2))
--innodb_adaptive_hash_index=OFF
--innodb_disable_sort_file_cache=ON
--innodb_doublewrite_pages=64
--innodb_purge_threads=1
--innodb_io_capacity=1000000
--innodb_io_capacity_max=1000000
--innodb_log_buffer_size=8388608
--innodb_log_compressed_pages=OFF
--innodb_flush_method=O_DIRECT
--innodb_log_file_size=1572864000
--innodb_page_cleaners=8
--innodb_strict_mode=OFF
)

if [ $type = dbg ]; then
dbg="gdb --args"
fi
#dbg="gdb --args"
binlog_args=(
--disable-log-bin --gtid_mode=OFF --enforce_gtid_consistency=OFF
#--sync_binlog=0 --binlog-order-commits=OFF
)
#dbg='numactl -N 0 --preferred 0'
5 changes: 5 additions & 0 deletions mytopling-conf/init_mysqld.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash:

source ./conf_mysqld.sh

${dbg} mysqld ${common_args[@]} ${binlog_args[@]} ${innodb_args[@]} ${rocksdb_args[@]} $@ --initialize-insecure
Loading