Skip to content

添加单机环境部署文档 #39

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# OpenTenBase 单机开发环境配置
`
本文档为开发入门指南,以便初学者快速搭建 OpenTenBase 的开发环境。
`

## 环境准备

- 虚拟机: VirtualBox 7.0
- 分配内存: 最少 4 G
- 分配磁盘: 最少 50 G
- 操作系统: CentOS-7-x86_64
- 开发工具: Eclipse IDE for C/C++ Developers 2023-12
- 终端工具: MobaXterm v23.2

## 安装软件包
``` bash
[root@localhost ~]# yum groupinstall "X Window System"
[root@localhost ~]# yum -y install gcc make readline-devel zlib-devel openssl-devel uuid-devel bison flex
[root@localhost ~]# yum -y install gdb git java-1.8.0-openjdk.x86_64 xclock
```


## 新建开发账号

``` bash
#开发账号
[root@localhost ~]# useradd opentenbase

#开发目录
[root@localhost ~]# mkdir -p /data/opentenbase

[root@localhost ~]# chown -R opentenbase.opentenbase /data/opentenbase

```

测试 X11 环境是否可用,使用 opentenbase 账号登录终端 (不是用 root 用户通过 su 命令切换),执行 xclock 确认弹出小闹钟。
![](assets/snap_xclock.png)


## 下载源码

建议把官方代码 fork 到自己的账号,然后 clone 自己仓库的代码,这样以后修改了可以直接向自己的库里提交。

``` bash
[opentenbase@localhost ~]$ cd /data/opentenbase
[opentenbase@localhost opentenbase]$ git clone https://github.com/yousoa/OpenTenBase.git --depth 0
```

## 部署 OpenTenBase 集群环境
参考 [单机部署文档:stand-alone-deployment.md](../stand-alone-deployment/stand-alone-deployment.md)

> 注: configure 命令需要加入 --enable-debug 编译后的程序支持调试。

``` bash
# configure 命令参数可以用如下形式

./configure --prefix=${INSTALL_PATH}/opentenbase_bin_v2.0 --enable-user-switch --with-openssl --with-ossp-uuid CFLAGS=-g --enable-depend --enable-cassert --enable-debug
```

## 下载Eclipse

```bash
[opentenbase@localhost opentenbase]$ curl -O https://mirrors.nju.edu.cn/eclipse//technology/epp/downloads/release/2023-12/R/eclipse-cpp-2023-12-R-linux-gtk-x86_64.tar.gz

[opentenbase@localhost opentenbase]$ tar xzvf eclipse-cpp-2023-12-R-linux-gtk-x86_64.tar.gz
```

## 运行 Eclipse , 导入工程

运行eclipse

```bash
[opentenbase@localhost eclipse]$ cd /data/opentenbase/eclipse
[opentenbase@localhost eclipse]$ ./eclipse
```

导入工程
![](assets/snap_ide1.png)
![](assets/snap_ide2.png)
![](assets/snap_ide3.png)

## 调试

### 查询进程 PID
登录数据库通过 pg_stat_activity 表查 pid,或通过 select pg_backend_pid(); 查询。
![](assets/snap_debug1.png)
![](assets/snap_debug2.png)

### 绑定调试进程
![](assets/snap_debug3.png)
![](assets/snap_debug4.png)
![](assets/snap_debug5.png)

### 设置断点
![](assets/snap_debug6.png)

### 执行查询命令,然后查看断点
![](assets/snap_debug7.png)
![](assets/snap_debug8.png)

## 开始 OpenTenBase 开发之旅吧。
79 changes: 79 additions & 0 deletions docs/contribution/stand-alone-deployment/assets/pgxc_ctl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

pgxcInstallDir=${PG_HOME}
pgxlDATA=/data/opentenbase/pgxc

pgxcOwner=$USER
pgxcUser=$USER
tmpDir=/tmp
localTmpDir=$tmpDir


# ---- GTM Master ---------------
gtmName=gtm
gtmMasterServer=127.0.0.1
gtmMasterPort=50001
gtmMasterDir=$pgxlDATA/gtm


# ---- Configuration
gtmExtraConfig=none
gtmMasterSpecificExtraConfig=none

# ---- GTM Slave
gtmSlave=y # Specify y if you configure GTM Slave. Otherwise, GTM slave will not be configured and
# all the following variables will be reset.
gtmSlaveName=gtmSlave
gtmSlaveServer=127.0.0.1 # value none means GTM slave is not available. Give none if you don't configure GTM Slave.
gtmSlavePort=50002 # Not used if you don't configure GTM slave.
gtmSlaveDir=$pgxlDATA/gtmSlave # Not used if you don't configure GTM slave.

#---- Configuration
gtmSlaveSpecificExtraConfig=none



#---- GTM Proxy
#---- GTM-Proxy Master -------
gtmProxyDir=$pgxlDATA/gtm_proxy
gtmProxy=y
gtmProxyNames=(gtm_pxy1 gtm_pxy2)
gtmProxyServers=(127.0.0.1 127.0.0.1)
gtmProxyPorts=(50011 50012)
gtmProxyDirs=($gtmProxyDir/gtm_pxy1 $gtmProxyDir/gtm_pxy2)

#---- Configuration
gtmPxyExtraConfig=none
gtmPxySpecificExtraConfig=(none none)


#---- Coordinators ---------
coordMasterDir=$pgxlDATA/coord
coordNames=(cn001)
coordPorts=(30004)
poolerPorts=(30011)
coordPgHbaEntries=(0.0.0.0/0)

coordMasterServers=(127.0.0.1)
coordMasterDirs=($coordMasterDir/cn001)
coordMaxWALsernder=0
coordMaxWALSenders=($coordMaxWALsernder)

coordSlave=n


#---- Datanodes ----------
datanodeMasterDir=$pgxlDATA/dn_master
primaryDatanode=127.0.0.1
datanodeNames=(dn001 dn002)
datanodePorts=(20008 20009)
datanodePoolerPorts=(20011 20012)
datanodePgHbaEntries=(0.0.0.0/0)

datanodeMasterServers=(127.0.0.1 127.0.0.1)
datanodeMasterDirs=($datanodeMasterDir/dn001 $datanodeMasterDir/dn002)
datanodeMaxWalSender=0
datanodeMaxWALSenders=($datanodeMaxWalSender $datanodeMaxWalSender)

datanodeSlave=n

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading