Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
FenjuFu committed Nov 24, 2024
1 parent 9aac816 commit 914cc8d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 9 deletions.
Binary file added content/chinese/news/images/news-post-24-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 80 additions & 9 deletions content/chinese/news/news-post-24.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Running: datanode master dn002

集群信息如下:

<img src=../images/news-post-24-2.png class="img-fluid" /><br/>

三、添加DN节点
--------------
Expand All @@ -47,48 +48,118 @@ Running: datanode master dn002

* 在新的 DN 节点上,创建必要的目录结构并设置权限:

# 创建数据目录mkdir -p /data/opentenbase/data/dn003 mkdir -p /data/opentenbase/installchown -R opentenbase:opentenbase /data/opentenbase # 创建 opentenbase 用户useradd -d /data/opentenbase -s /bin/bash -m opentenbase # 设置密码passwd opentenbase
```
# 创建数据目录
mkdir -p /data/opentenbase/data/dn003
mkdir -p /data/opentenbase/install
chown -R opentenbase:opentenbase/data/opentenbase
# 创建 opentenbase 用户
useradd -d /data/opentenbase -s /bin/bash -m opentenbase
# 设置密码
passwd opentenbase
```

### 3.2. 配置opentenbase环境变量

[opentenbase]$ vim ~/.bashrcexport OPENTENBASE_HOME=/data/opentenbase/install/opentenbase_bin_v2.6export PATH=$OPENTENBASE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$OPENTENBASE_HOME/lib:${LD_LIBRARY_PATH}export LC_ALL=C
```
[opentenbase]
$ vim ~/.bashrc
export OPENTENBASE_HOME=/data/opentenbase/install/opentenbase_bin_v2.6
export PATH=$OPENTENBASE_HOME/bin:OPENTENBASEHOME/bin:$PATH
export LD_LIBRARY_PATH=$OPENTENBASE_HOME/lib:OPENTENBASEHOME/lib:${LD_LIBRARY_PATH}
export LC_ALL=C
```

### 3.3. 分发二进制文件

将 OpenTenBase 的二进制文件分发到新的 DN 节点。

* 管控节点192.168.2.136分发软件包

[opentenbase]pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf deploy 192.168.2.138
```
[opentenbase]
pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf
deploy 192.168.2.138
```

### 3.4. 配置 SSH 互信

确保现有的集群节点可以无密码访问新的 DN 节点:

# 生成 SSH 密钥对(如果还没有)ssh-keygen -t rsa # 将公钥复制到新的 DN 节点ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
```
# 生成 SSH 密钥对(如果还没有)
ssh-keygen -t rsa
# 将公钥复制到新的 DN 节点
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
```

### 3.5 添加dn003节点

pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf PGXCadd datanode master dn003 192.168.2.138 40004 20012 /data/opentenbase/data/dn003 none none none none
```
pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf
PGXC
add datanode master dn003 192.168.2.138 40004 20012 /data/opentenbase/data/dn003 none none none none
```

### 3.6 节点操作补充(不用执行)

1)初始化新的 DN 节点

[opentenbase]pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf PGXCinit datanode dn003
```
[opentenbase]
pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf
PGXC
init datanode dn003
```

2)启动新的 DN 节点

使用 pgxc_ctl 工具启动新的 DN 节点:

[opentenbase]pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf PGXCstart datanode dn003
```
[opentenbase]
pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf
PGXC
start datanode dn003
```

3)移除DN节点

使用 pgxc_ctl 工具移除新的 DN 节点:

[opentenbase]pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf PGXCremove datanode master dn003 clean
```
[opentenbase]
pgxc_ctl -c /data/opentenbase/pgxc_ctl/pgxc_ctl.conf
PGXC
remove datanode master dn003 clean
```

四. 验证
--------

新增的 DN 节点连接到任意一个协调节点(CN),验证新的 DN 节点是否已经成功加入集群:

[opentenbase@db1 ~]$ psql -h 192.168.2.136 -p 30004 -d postgres -U opentenbasepsql (PostgreSQL 10.0 OpenTenBase V2)Type "help" for help.postgres=# select * from pgxc_node; node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id | node_cluster_name -----------+-----------+-----------+---------------+----------------+------------------+-------------+--------------------- gtm | G | 50001 | 192.168.2.136 | t | f | 428125959 | opentenbase_cluster cn001 | C | 30004 | 192.168.2.136 | f | f | -264077367 | opentenbase_cluster cn002 | C | 30004 | 192.168.2.137 | f | f | -674870440 | opentenbase_cluster dn001 | D | 40004 | 192.168.2.136 | t | t | 2142761564 | opentenbase_cluster dn002 | D | 40004 | 192.168.2.137 | f | f | -17499968 | opentenbase_cluster dn003 | D | 40004 | 192.168.2.138 | f | f | -1956435056 | opentenbase_cluster(6 rows)
```
[opentenbase@db1 ~]$ psql -h 192.168.2.136 -p 30004 -d postgres -U opentenbase
psql (PostgreSQL 10.0 OpenTenBase V2)
Type "help" for help.
postgres=# select * from pgxc_node;
node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id | node_cluster_name
-----------+-----------+-----------+---------------+----------------+------------------+-------------+---------------------
gtm | G | 50001 | 192.168.2.136 | t | f | 428125959 | opentenbase_cluster
cn001 | C | 30004 | 192.168.2.136 | f | f | -264077367 | opentenbase_cluster
cn002 | C | 30004 | 192.168.2.137 | f | f | -674870440 | opentenbase_cluster
dn001 | D | 40004 | 192.168.2.136 | t | t | 2142761564 | opentenbase_cluster
dn002 | D | 40004 | 192.168.2.137 | f | f | -17499968 | opentenbase_cluster
dn003 | D | 40004 | 192.168.2.138 | f | f | -1956435056 | opentenbase_cluster
(6 rows)
```


五、总结
--------

Expand Down

0 comments on commit 914cc8d

Please sign in to comment.