# 命令行部署
如果您希望使用命令行的方式单独部署 OushuDB ,请按照本章节步骤部署。
OushuDB 5.0 的运行需要依赖分布式存储 Magma ,在部署 OushuDB 前,请确保 Magma 已经部署并初始化。Magma 安装部署请参考:[Magma 安装](../magma/magma-install-cli.md)。
## 前提
登陆到 oushu1 节点:
```bash
ssh root@oushu1
```
创建 `oushuhosts` 文件,包含 OushuDB 集群中所有机器:
```bash
touch ~/oushuhosts
```
编写 `oushuhosts` 文件内容如下:
```
oushu1
oushu2
oushu3
```
配置yum源,安装lava命令行管理工具
```sh
# 从yum源所在机器(假设为192.168.1.10)获取repo文件
scp root@192.168.1.10:/etc/yum.repos.d/oushu.repo /etc/yum.repos.d/oushu.repo
# 追加yum源所在机器信息到/etc/hosts文件
yum clean all
yum makecache
yum install -y lava
```
在 oushu1 上和集群内其他节点交换公钥,以便ssh免密码登陆和分发配置文件,以密码代替*号:
```bash
lava ssh-exkeys -f ~/oushuhosts -p ********
```
将repo文件分发给集群内其他机器:
```bash
lava scp -f ~/oushuhosts /etc/yum.repos.d/oushu.repo =:/etc/yum.repos.d
lava ssh -f ~/oushuhosts -e "yum clean all"
lava ssh -f ~/oushuhosts -e "yum makecache"
```
在 oushu1 节点的系统配置文件 /etc/sysctl.conf 中追加如下内容:
```bash
kernel.shmmax = 3000000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 250 512000 100 2048
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_syncookies = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 200000
net.ipv4.conf.all.arp_filter = 1
net.ipv4.ip_local_port_range = 10000 65535
net.core.netdev_max_backlog = 200000
net.netfilter.nf_conntrack_max = 524288
fs.nr_open = 3000000
kernel.threads-max = 798720
kernel.pid_max = 798720
net.core.rmem_max=2097152
net.core.wmem_max=2097152
net.core.somaxconn=4096
kernel.core_pattern=/data1/oushudb/cores/core-%e-%s-%u-%g-%p-%t
```
如果集群计划部署在麒麟操作系统上,需要额外追加网络配置参数:
```bash
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ipfrag_high_thresh = 41943040
net.ipv4.ipfrag_low_thresh = 40894464
net.ipv4.udp_mem = 9242685 12323580 18485370
net.ipv4.tcp_mem = 9240912 12321218 18481824
```
为了方便软件调试分析,我们建议允许 OushuDB 生成 core dump 文件。
创建文件 ` /etc/security/limits.d/oushu.conf`
```bash
touch /etc/security/limits.d/oushu.conf
```
并向其写入内容:
```bash
* soft nofile 1048576
* hard nofile 1048576
* soft nproc 131072
* hard nproc 131072
oushu soft core unlimited
oushu hard core unlimited
```
同步上述操作系统参数修改到所有节点:
```bash
lava scp -r -f ~/oushuhosts /etc/sysctl.conf =:/etc/
lava scp -r -f ~/oushuhosts /etc/security/limits.d/oushu.conf =:/etc/security/limits.d/
lava ssh -f ~/oushuhosts -e "sysctl -p"
```
配置 Magma 集群节点IP到集群节点的`/etc/hosts'中:
```bash
lava ssh -f ~/oushuhosts -e "echo '192.168.1.21 magma1' >>/etc/hosts"
lava ssh -f ~/oushuhosts -e "echo '192.168.1.22 magma2' >>/etc/hosts"
lava ssh -f ~/oushuhosts -e "echo '192.168.1.23 magma3' >>/etc/hosts"
```
如果配置 HDFS 作为存储引擎,则需要将 HDFS 集群节点 IP 添加到集群的`/etc/hosts`中:
```bash
lava ssh -f ~/oushuhosts -e "echo '192.168.1.21 hdfs1' >>/etc/hosts"
lava ssh -f ~/oushuhosts -e "echo '192.168.1.22 hdfs2' >>/etc/hosts"
```
如果 HDFS 存储引擎配置了 Kerberos, 则需要将对应的 KDC 节点的 IP 添加到集群的 `/etc/hosts`中,并安装kerberos client:
```bash
lava ssh -f ~/oushuhosts -e "echo '192.168.1.31 kdcserver' >>/etc/hosts"
lava ssh -f ~/oushuhosts "yum install -y krb5-libs krb5-workstation"
```
## 安装
使用 yum install 的安装方式:
```bash
lava ssh -f ~/oushuhosts -e "yum install -y jdk oushudb"
```
## 配置
为了方便管理,为 oushu 用户创建 oushuhostfile, mhostfile 与 shostfile 以分别管理集群所有节点、 集群 main 节点和集群 segment 节点。
在 oushu1 上 `/home/oushu` 目录下,
创建 `oushuhostfile` 文件,包含集群所有节点:
```
touch /home/oushu/oushuhostfile
```
编辑`oushuhostfile` 文件如下:
```
oushu1
oushu2
oushu3
```
创建 `mhostfile` 文件,包含集群所有 main 节点:
```
touch /home/oushu/mhostfile
```
编辑`mhostfile` 文件如下:
```
oushu1
oushu2
```
创建 `shostfile` 文件,包含集群所有 segment节点:
```
touch /home/oushu/shostfile
```
编辑`shostfile` 文件如下:
```
oushu1
oushu2
oushu3
```
同步hostfile文件到所有节点:
```
lava scp -r -f ~/oushuhosts /home/oushu/* =:/home/oushu
lava ssh -f ~/oushuhosts -e "chown -R oushu:oushu /home/oushu"
```
修改集群内 oushu 用户环境变量:
```bash
lava ssh -f ~/oushuhosts -e "touch /home/oushu/.bashrc"
lava ssh -f ~/oushuhosts -e "echo 'source /usr/local/oushu/oushudb/oushudb_path.sh' >> /home/oushu/.bashrc"
```
### 准备数据目录
**在主节点上创建本地文件目录**
在所有主节点上创建本地元数据目录(masterdd)与临时文件目录(tmp):
```bash
lava ssh -f /home/oushu/mhostfile -e "mkdir -p /data1/oushudb/masterdd"
lava ssh -f /home/oushu/mhostfile -e "mkdir -p /data1/oushudb/tmp"
```
可以在多个盘下创建临时文件目录提升磁盘利用率,例如:
```bash
lava ssh -f /home/oushu/mhostfile -e "mkdir -p /data1/oushudb/tmp"
lava ssh -f /home/oushu/mhostfile -e "mkdir -p /data2/oushudb/tmp"
lava ssh -f /home/oushu/mhostfile -e "mkdir -p /data3/oushudb/tmp"
```
修改对应文件的权限信息:
```bash
lava ssh -f /home/oushu/mhostfile -e "chown -R oushu:oushu /data1/oushudb"
```
**在所有计算节点创建本地文件目录**
在所有计算节点中创建本地元数据目录(segmentdd) 与临时文件目录(tmp):
``` bash
lava ssh -f /home/oushu/shostfile -e "mkdir -p /data1/oushudb/segmentdd"
lava ssh -f /home/oushu/shostfile -e "mkdir -p /data1/oushudb/tmp"
```
修改对应文件夹的权限信息:
```bash
lava ssh -f /home/oushu/shostfile -e "chown -R oushu:oushu /data1/oushudb"
```
**在所有节点上创建core dump文件路径**
按照 `kernel.core_pattern` 的配置值进行创建 :
```bash
lava ssh -f /home/oushu/oushuhostfile -e "mkdir -p /data1/oushudb/cores"
lava ssh -f /home/oushu/oushuhostfile -e "chmod 777 /data1/oushudb/cores"
```
### 修改配置文件
修改配置文件过程需使用 oushu 用户,在配置前 oushu 用户需要与集群中其他节点交换key,
使用 lava 工具修改集群节点上 oushu 用户密码,密码代替 * 号:
```bash
lava ssh -f ~/oushuhosts -e "echo '******' | passwd --stdin oushu"
```
在 oushu1 节点上, 切换 oushu 用户并与集群节点交换 key,按照提示输入相应节点的 oushu 用户密码:
```bash
su - oushu
oushudb ssh-exkeys -f ~/oushuhostfile
```
OushuDB 的配置文件存放于`/usr/local/oushu/conf/oushudb`,配置文件模板存放于`/usr/local/oushu/oushudb/conf.empty`。
进入`/usr/local/oushu/conf/oushudb`
```bash
cd /usr/local/oushu/conf/oushudb
```
**1.配置`oushudb-topology.yaml`**
`oushudb-topology.yaml` 描述了 OushuDB 集群的拓扑信息,其中包含**所有**节点信息、集群的逻辑结构、节点角色的分配情况以及虚拟集群的参数配置。
`oushudb-topology.yaml` 由两部分组成:描述节点信息的 nodes 段以及描述集群配置信息的 vc 段。
修改`oushudb-topology.yaml` 内容如下:
```yaml
nodes:
- id: m[001]
addr: 192.168.1.11
label: { region: "regionA", zone: "zoneA"}
- id: m[002]
addr: 192.168.1.12
label: { region: "regionA", zone: "zoneA"}
- id: m[003]
addr: 192.168.1.13
label: { region: "regionA", zone: "zoneA"}
vc:
- name: mains
vci:
- nodes: m[001], m[002]
- name: vc_default
vci:
- name: vci1
nodes: m[001-002]
- name: vc1
vci:
- name: vci2
nodes: m[003]
```
参数项的含义如下:
| nodes 参数项 | 含义 |
| ------------ | ---------------------------- |
| id | 集群节点标识 |
| addr | 节点的ip地址或者hostname |
| label | 节点标签 |
| vc 参数项 | 含义 | 默认值 | 最小 | 最大 |
| --------- |----------------------------------------------| ------ | ------ | ------ |
| name | vc 的名称 | | | |
| vci | 一个虚拟集群实例,由 name 与 nodes 组成 | | | |
一个 vc 可以包含若干个 vci ,在配置时需要注意:
(1)同一个 vc 下的每一个vci包含的节点数必须相等。
(2)不同的 vc 和不同的 vci 中配置的 nodes 必须互斥, 名称为 mains 的 vc 不受此限制。
(3)一个vci中的所有节点必须在同一个zone中。
(4)集群内部必须要配置名称为 mains 的 vc ,表示集群内部所有的 main 节点。
(5)集群内部必须要配置名称为 vc_default 的 vc , vc_default 是 OushuDB 默认初始化的虚拟集群。
**配置`magma-client.xml`**
`magma-client.xml`需依次指定 nameservice, nameservice 下属节点,以及对应节点的访问方式。
如本例:
nameservice 名称为 oushu_magma, oushu_magma 下属 3 个节点: magma1, magma2, magma3
配置节点访问方式时,节点使用 nameservice 做前缀进行标识,例如节点 oushu_magma.magma1
其值可指定为 ip:port 或 hostname:port, hostname需提前加入本机。
```xml
nameservices
oushu_magma
oushu_magma
magma1,magma2,magma3
oushu_magma.magma1
magma1:6666
oushu_magma.magma2
magma2:6666
oushu_magma.magma3
magma3:6666
```
**2.配置 `hdfs-client.xml`(可选)**
如果您使用 HDFS 作为存储引擎,则需要配置 `hdfs-client.xml`,否则跳过本步骤。
去除 ``,修改该注释部分的参数,这部分可参照下面文件做修改。
修改 `dfs.client.read.shortcircuit`,如果是存算分离环境,设置为 false。
其余配置保持不变。
```xml
dfs.nameservices
oushu
dfs.ha.namenodes.oushu
nn2,nn1
dfs.namenode.rpc-address.oushu.nn1
hdfs1:9000
dfs.namenode.rpc-address.oushu.nn2
hdfs2:9000
dfs.namenode.http-address.oushu.nn1
hdfs1:50070
dfs.namenode.http-address.oushu.nn2
hdfs2:50070
rpc.client.timeout
3600000
timeout interval of a RPC invocation in millisecond. default is 3600000.
rpc.client.connect.tcpnodelay
true
whether set socket TCP_NODELAY to true when connect to RPC server. default is true.
rpc.client.max.idle
10000
the max idle time of a RPC connection in millisecond. default is 10000.
rpc.client.ping.interval
10000
the interval which the RPC client send a heart beat to server. 0 means disable, default is 10000.
rpc.client.connect.timeout
600000
the timeout interval in millisecond when the RPC client is trying to setup the connection. default is 600000.
rpc.client.connect.retry
10
the max retry times if the RPC client fail to setup the connection to server. default is 10.
rpc.client.read.timeout
3600000
the timeout interval in millisecond when the RPC client is trying to read from server. default is 3600000.
rpc.client.write.timeout
3600000
the timeout interval in millisecond when the RPC client is trying to write to server. default is 3600000.
rpc.client.socket.linger.timeout
-1
set value to socket SO_LINGER when connect to RPC server. -1 means default OS value. default is -1.
dfs.client.read.shortcircuit
true
whether reading block file bypass datanode if the block and the client are on the same node. default is true.
dfs.default.replica
3
the default number of replica. default is 3.
dfs.prefetchsize
10
the default number of blocks which information will be prefetched. default is 10.
dfs.client.failover.max.attempts
15
if multiply namenodes are configured, it is the max retry times when the dfs client try to issue a RPC call. default is 15.
dfs.default.blocksize
134217728
default block size. default is 134217728.
```
**3.配置 `oushudb-site.xml`**
如果计划使用 HDFS 作为存储引擎,需要在配置项 `hawq_dfs_url` 中配置使用的连接方式与默认文件路径。
`hawq_dfs_url` 由两部分组成:在 hdfs-client.xml 中配置的 `dfs.nameservices` 与 OushuDB 允许使用的文件路径`dfs_url`,两者以"/" 连接。
例如本例:oushu/oushudb/default_filespace.
配置`hawq_master_directory`、`hawq_segment_directory`、`hawq_master_temp_directory`、`hawq_segment_temp_directory`,其值为本节点用作 main 或 segment 数据目录与临时目录的路径值。
配置`hawq_rm_memory_limit_perseg`、`hawq_rm_nvcore_limit_perseg`, 其值将用作 ERM 分配资源所用, hawq_rm_memory_limit_perseg 应能被 hawq_rm_nvcore_limit_perseg 整除。
配置 `cache_read_protocols`,其值决定可使用缓存的存储协议,可选hdfs、magma、s3。
配置`default_storage`,其值决定默认使用的存储引擎,可选hdfs、magma、s3。
配置`catalog_url`, 其值依赖`magma-client.xml` 的`nameservices` 与 Magma 中配置的元数据存储集群:在本配置下为`oushu_magma/vsc_catalog`
配置`magma_dfs_url`,其值依赖`magma-client.xml` 的`nameservices` 与 Magma 中配置的数据虚拟存储集群:在本配置下为`oushu_magma/vsc_default`
其余配置保持不变。
```xml
hawq_master_address_port
5432
The port of hawq master.
hawq_segment_address_port
40000
The port of hawq segment.
hawq_dfs_url
oushu/oushudb/default_filespace
URL for accessing HDFS.
hawq_s3_url
none
URL for accessing S3.
cache_read_protocols
hdfs,magma
hawq_master_directory
/data1/oushudb/masterdd
The directory of hawq master.
hawq_segment_directory
/data1/oushudb/segmentdd
The directory of hawq segment.
hawq_master_temp_directory
/data1/oushudb/tmp
The temporary directory reserved for hawq master.
hawq_segment_temp_directory
/data1/oushudb/tmp
The temporary directory reserved for hawq segment.
hawq_global_rm_type
none
The resource manager type to start for allocating resource.
'none' means hawq resource manager exclusively uses whole
cluster; 'yarn' means hawq resource manager contacts YARN
resource manager to negotiate resource.
hawq_rm_memory_limit_perseg
64GB
The limit of memory usage in a hawq segment when
hawq_global_rm_type is set 'none'.
hawq_rm_nvcore_limit_perseg
16
The limit of virtual core usage in a hawq segment when
hawq_global_rm_type is set 'none'.
hawq_rm_yarn_address
localhost:8032
The address of YARN resource manager server.
hawq_rm_yarn_scheduler_address
localhost:8030
The address of YARN scheduler server.
hawq_rm_yarn_queue_name
default
The YARN queue name to register hawq resource manager.
hawq_rm_yarn_app_name
hawq
The application name to register hawq resource manager in YARN.
hawq_re_cpu_enable
false
The control to enable/disable CPU resource enforcement.
hawq_re_cgroup_mount_point
/sys/fs/cgroup
The mount point of CGroup file system for resource enforcement.
For example, /sys/fs/cgroup/cpu/hawq for CPU sub-system.
hawq_re_cgroup_hierarchy_name
hawq
The name of the hierarchy to accomodate CGroup directories/files for resource enforcement.
For example, /sys/fs/cgroup/cpu/hawq for CPU sub-system.
hawq_acl_type
standalone
HAWQ ACL mode.
'standalone' means HAWQ does native ACL check;
'ranger' means HAWQ does priviliges check through Ranger.
hawq_rps_address_port
8432
The port number of Ranger Plugin Serice. HAWQ RPS address is
http://$rps_host(hawq_master_address_host or hawq_standby_address_host):$hawq_rps_address_port/rps
For example, http://localhost:8432/rps
default_storage
hdfs
set default storage as hdfs, s3 or magma when creating table.
catalog_url
oushu_magma/vsc_catalog
urls for accessing magma.
magma_dfs_url
oushu_magma/vsc_default
```
**4.配置kerberos(可选)**
如果使用的 HDFS 存储引擎配置了 Kerberos,则需要为 OushuDB 配置 Kerberos,否则跳过本步骤。
登录 KDC server,将Kerberos配置文件/etc/krb5.conf分发至 oushu1 节点:
```
scp /etc/krb5.conf root@192.168.1.11:/etc/krb5.conf
```
为 oushu 用户创建 Kerberos principal 并生成一个keytab文件:
```bash
kadmin.local -q "addprinc -randkey oushu@REALM"
kadmin.local -q "addprinc -randkey oushu/oushu1@REALM"
kadmin.local -q "addprinc -randkey oushu/oushu2@REALM"
kadmin.local -q "addprinc -randkey oushu/oushu3@REALM"
kadmin.local -q "xst -k /etc/security/keytabs/oushu.keytab oushu/oushu1@REALM"
kadmin.local -q "xst -k /etc/security/keytabs/oushu.keytab oushu/oushu2@REALM"
kadmin.local -q "xst -k /etc/security/keytabs/oushu.keytab oushu/oushu3@REALM"
kadmin.local -q "ktadd -k /etc/security/keytabs/oushu.keytab oushu"
```
分发 `/etc/security/keytabs/oushu.keytab`至 oushu1 节点:
```
sudo scp /etc/security/keytabs/oushu.keytab oushu@192.168.1.11:/usr/local/oushu/conf/oushudb/
```
返回 oushu1 节点,切换 root 用户,分发 `/etc/krb5.conf`到所有 OushuDB 节点:
```
su - root
lava scp -f ~/oushuhosts /etc/krb5.conf =:/etc/
```
切换 oushu 用户,执行后续修改
```
su - oushu
```
**修改 `oushudb-site.xml` 配置**
修改 krb_server_list ,修改为 `hdfs-client.xml`中配置 的 nameservice,多个集群需以逗号分隔,不能有多余的空格:
```xml
krb_server_list
oushu
```
注意,这里的nameservice格式可以为HA也可以是host:port,无论是哪一种,在所有配置文件中都应该一致,即hawq_hdfs_url、pg_filesystem_entry或者hdfs-client.xml中该集群也必须以krb_server_list中的nameservice进行标识,否则会导致识别失败。
**修改 hdfs-client.xml**
OushuDB 通过如下配置项来进行 kerberos 认证。
1. dfs.encrypt.data.transfer
2. dfs.block.access.token.enable
3. hadoop.security.authentication
4. hadoop.rpc.protection
5. dfs.data.transfer.protection
6. hadoop.security.token.lifetime (KDC 认证有效时间,单位ms)
7. hadoop.security.ticket.lifetime (Namenode 认证有效时间,单位ms)
8. hadoop.security.keytab (keytab 路径,路径下的keytab文件分发到所有 main )
9. hadoop.security.principal (KDC 认证时使用的 principal)
新增一个 Kerberos 配置时,每项应该以HDFS 集群的 nameservice 为前缀,表示这是该 HDFS 集群的 kerberos 配置。
```xml
oushu.hadoop.security.authentication
kerberos
oushu.hadoop.rpc.protection
authentication
oushu.dfs.data.transfer.protection
authentication
oushu.dfs.encrypt.data.transfer
false
oushu.dfs.block.access.token.enable
true
oushu.hadoop.security.token.lifetime
4320000
oushu.hadoop.security.ticket.lifetime
4320000
oushu.hadoop.security.keytab
/usr/local/oushu/conf/oushudb/oushu.keytab
oushu.hadoop.security.principal
oushu
```
将oushu.keytab分发到所有 main 节点
```
oushudb scp -f ~/mhostfile /usr/local/oushu/conf/oushudb/oushu.keytab =:/usr/local/oushu/conf/oushudb/
```
**5.分发配置文件**
将修改后的OushuDB配置文件分发到所有节点
```bash
oushudb scp -f ~/oushuhostfile /usr/local/oushu/conf/oushudb/oushudb-topology.yaml =:/usr/local/oushu/conf/oushudb/
oushudb scp -f ~/oushuhostfile /usr/local/oushu/conf/oushudb/oushudb-site.xml =:/usr/local/oushu/conf/oushudb/
oushudb scp -f ~/oushuhostfile /usr/local/oushu/conf/oushudb/magma-client.xml =:/usr/local/oushu/conf/oushudb/
oushudb scp -f ~/oushuhostfile /usr/local/oushu/conf/oushudb/hdfs-client.xml =:/usr/local/oushu/conf/oushudb/
```
## 启动
### 初始化OushuDB
如果配置了HDFS 作为存储引擎,需要确保HDFS系统启动,并为 OushuDB 配置好路径与权限。
登录 hdfs1,切换为 hdfs 用户执行如下命令为 OushuDB 创建可用目录:
```
sudo -u hdfs hdfs dfs -mkdir -p /oushudb/default_filespace
```
上文命令中 `/oushudb/default_filespace`路径来源于 `oushudb-site.xml`中`hawq_dfs_url` 配置项的`dfs_url`。
修改为 OushuDB 创建的文件路径的归属用户,如果启用了 Kerberos,则需修改为 principal 指定的用户:
```
sudo -u hdfs hdfs dfs -chown -R oushu:oushu /oushudb/default_filespace
```
OushuDB 依赖 Magma 分布式表存储,需要确保 Magma 已经初始化并启动。Magma 安装部署请参考:[Magma 安装](../magma/magma-install-cli.md)。
在 oushu1 使用 oushu 用户执行如下命令以初始化集群:
```bash
oushudb init cluster -a
```
执行 `oushudb init --help` 可获得更为详细的命令描述。
### 安装后测试
连接数据库:
```bash
psql -d postgres
```
执行如下SQL以验证:
```sql
CREATE TABLE rank1 (id int);
insert into rank1 select generate_series(1, 1000000, 1);
select count(*) from rank1;
```
## 常用命令
```bash
# 启动停止运行的 OushuDB 集群
oushudb start cluster
# 停止正在运行的 OushuDB 集群
oushudb stop cluster
# 停止当前 main 节点
oushudb stop main
# 停止当前 segment 节点
oushudb stop segment
# 停止所有 main 节点
oushudb stop allmains
# 停止所有 segment 节点
oushudb stop allsegments
# 初始化本地 main 节点
oushudb init main
# 初始化所有 main 节点
oushudb init allmains
# 初始化本地 segment 节点
oushudb init segment
# 初始化所有 segment 节点
oushudb init allsegments
```
## 注册到skylab(可选)
注册工作需要将 OushuDB 所有节点添加到Skylab,如果您尚未添加,请参考[注册机器](../start/install-lava.md)。
在 oushu1 上(所有master节点)使用 oushu 用户,修改配置文件 `/data1/oushudb/masterdd/pg_hba.conf`
在 oushu1 上(所有master节点)使用 oushu 用户,修改配置文件 `/data1/oushudb/masterdd/pg_hba.conf`
在 oushu1 上(所有master节点)使用 oushu 用户,修改配置文件 `/data1/oushudb/masterdd/pg_hba.conf`
一定要修改pg_hba.conf之后再注册。
修改 oushu 用户之外的认证方式为 (IP需要被替换为Skylab 服务器IP):
```bash
host all all 0.0.0.0/0 cloud cloudserver=http://IP:1612
```
同步配置到所有 main 节点,并reload:
```bash
oushudb scp -f /home/oushu/mhostfile /data1/oushudb/masterdd/pg_hba.conf =:/data1/oushudb/masterdd/
oushudb reload main -a
```
注册现有数据库 (IP需要被替换为Skylab 服务器IP)
```
curl -l -k -H "Content-type:application/json" -X POST -d '{"login_type":1, "name": "oushu", "password": "Oushu6@China", "tenant_code": "根租户"}' http://IP:1612/user/login -c /tmp/.lavacookie > /tmp/.userinfo
curl -l -k -H "Content-type:application/json" -X POST -d '{"ip": "192.168.1.11", "port": "5432", "cluster_group_name": "oushudb"}' http://IP:1652/admin/OushuDB/register -b /tmp/.lavacookie
```
访问Skylab服务以确认注册完成,例如Skylab 部署在192.168.1.10:
```
http://192.168.1.10:3000/main/Deploy/oushudb
```
从页面登录后,在自动部署模块对应服务中可以查看到新添加的集群,同时列表中会实时监控 OushuDB 进程在机器上的状态。
