Vertica单点更改服务器ip

需求

服务器网段调整,将ip:192.168.40.190收回,使用ip:192.168.40.200

默认情况下,节点 IP 地址和导出 IP 地址配置相同的 IP 地址。导出地址是网络上有权访问其他 DBMS 系统的节点的 IP 地址。使用导出地址从 DBMS 系统导入和导出数据。您可以按照此处的说明手动更改导出地址。

在下面的示例中,export_address是默认值。在这种情况下,当您运行 re-ip 命令时,export_address将更改为新的node_address。

查看数据库信息

复制代码
--查看现有ip
root@ubuntu:~# su - dbadmin
dbadmin@ubuntu:~$ vsql -Udbadmin -W dhh
dhh=> SELECT node_name, node_address, export_address FROM nodes;
   node_name    |  node_address  | export_address
----------------+----------------+----------------
 v_dhh_node0001 | 192.168.40.190 | 192.168.40.190
(1 row)

--查看admintools.conf
主机和节点的 IP 地址存储在 opt/vertica/config/admintools.conf
dbadmin@ubuntu:~$ cat /opt/vertica/config/admintools.conf
[Configuration]
format = 3
install_opts = --failure-threshold NONE --host '192.168.40.190' -u dbadmin -l /home/dbadmin -d /home/dbadmin
....
[Cluster]
hosts = 192.168.40.190

[Nodes]
node0001 = 192.168.40.190,/home/dbadmin,/home/dbadmin
v_dhh_node0001 = 192.168.40.190,/home/dbadmin,/home/dbadmin
....

--IP 地址列表
dbadmin@ubuntu:~$ admintools -t list_allnodes
 Node           | Host           | State | Version          | DB
----------------+----------------+-------+------------------+-----
 v_dhh_node0001 | 192.168.40.190 | UP    | vertica-10.0.0.0 | dhh

 --显示节点信息
 dhh=> SELECT * from vs_nodes order by name;
        oid        | tag |      name      | schema |    address     | addressfamily | ei_address |                   catalogpath                    | hascatalog | siteuniqueid| nodetype | isephemeral | isrecoveryclerk | parentfaultgroupid | clientport | controladdress | controladdressfamily | controlbroadcast | controlport |    controlnode    | replacednode | nodeparammap | isprimary
-------------------+-----+----------------+--------+----------------+---------------+------------+--------------------------------------------------+------------+--------------+----------+-------------+-----------------+--------------------+------------+----------------+----------------------+------------------+-------------+-------------------+--------------+--------------+-----------
 45035996273704978 |   0 | v_dhh_node0001 |      0 | 192.168.40.190 | ipv4          |          0 | /home/dbadmin/dhh/v_dhh_node0001_catalog/Catalog | f          |           10|        0 | f           | f               |  45035996273704976 |       5433 | 192.168.40.190 | ipv4                 | 192.168.40.255   |        4803 | 45035996273704978 |       0 |            0 | t
(1 row)

停止数据库

安全关闭数据库。

复制代码
dbadmin@ubuntu:~$ admintools

更改网卡信息

更改所有节点上的 IP 地址和与网络相关的配置,例如防火墙、硬件负载平衡器等。然后,使用 ping 命令和 ssh 登录检查节点之间的网络连接。

复制代码
--更改网卡信息
root@ubuntu:~# vi /etc/netplan/01-netcfg.yaml
192.168.40.190更改为192.168.40.200保存

--重启网卡
root@ubuntu:~# netplan apply

--查看ip地址
root@ubuntu:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:78:f3:cb brd ff:ff:ff:ff:ff:ff
    inet 192.168.40.200/24 brd 192.168.40.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe78:f3cb/64 scope link
       valid_lft forever preferred_lft forever

--查看/etc/hosts
root@ubuntu:~# cat /etc/hosts
127.0.0.1	localhost
127.0.1.1	ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.40.200 ubuntu

创建映射文件

确保 oldIPaddress 和 newIPaddress 之间没有"逗号",按以下格式为节点地址创建映射文件:

复制代码
--语法
oldIPaddress newIPaddress, controlAddress (optional), controlBroadcast (optional)

--示例
su - dbadmin
cd /home/dbadmin
cat > mapfile  << "EOF"
192.168.40.190 192.168.40.200
EOF

执行 Re-IP 工具

复制代码
su - dbadmin
cd /home/dbadmin
admintools -t re_ip -f mapfile

详细过程如下:

复制代码
dbadmin@ubuntu:~$ admintools -t re_ip -f mapfile
Parsing mapfile ...
New settings for Host 192.168.40.190 are:
  address: 192.168.40.200
  controlAddress: 192.168.40.200
  controlBroadcast: 192.168.40.255

The following databases would be affected by this tool: dhh
Checking DB status ...

Please check your new settings carefully, incorrect settings may cause database damage!
Enter "yes" to write new settings or "no" to exit > yes
Backing up local admintools.conf ...
Writing new settings to local admintools.conf ...

Writing new settings to the catalogs of database dhh ...
The change was applied to all nodes.
Success. Change committed on a quorum of nodes.
You can start database dhh again.

Initiating admintools.conf distribution ...
Success. Local admintools.conf sent to all hosts in the cluster.
>>> Write new settings successfully.

启动数据库

查看更改后的数据库信息

复制代码
--查看现有ip
root@ubuntu:~# su - dbadmin
dbadmin@ubuntu:~$ vsql -Udbadmin -W dhh
dhh=> SELECT node_name, node_address, export_address FROM nodes;
   node_name    |  node_address  | export_address
----------------+----------------+----------------
 v_dhh_node0001 | 192.168.40.200 | 192.168.40.200
(1 row)

--查看admintools.conf
主机和节点的 IP 地址存储在 opt/vertica/config/admintools.conf
dbadmin@ubuntu:~$ cat /opt/vertica/config/admintools.conf
[Configuration]
format = 3
install_opts = --failure-threshold NONE --host '192.168.40.190' -u dbadmin -l /home/dbadmin -d /home/dbadmin
....
[Cluster]
hosts = 192.168.40.200

[Nodes]
node0001 = 192.168.40.200,/home/dbadmin,/home/dbadmin
v_dhh_node0001 = 192.168.40.200,/home/dbadmin,/home/dbadmin
....

--IP 地址列表
dbadmin@ubuntu:~$ admintools -t list_allnodes
 Node           | Host           | State | Version          | DB
----------------+----------------+-------+------------------+-----
 v_dhh_node0001 | 192.168.40.200 | UP    | vertica-10.0.0.0 | dhh

 --显示节点信息
 dhh=> SELECT * from vs_nodes order by name;
        oid        | tag |      name      | schema |    address     | addressfamily | ei_address |                   catalogpath                    | hascatalog | siteuniqueid| nodetype | isephemeral | isrecoveryclerk | parentfaultgroupid | clientport | controladdress | controladdressfamily | controlbroadcast | controlport |    controlnode    | replacednode | nodeparammap | isprimary
-------------------+-----+----------------+--------+----------------+---------------+------------+--------------------------------------------------+------------+--------------+----------+-------------+-----------------+--------------------+------------+----------------+----------------------+------------------+-------------+-------------------+--------------+--------------+-----------
 45035996273704978 |   0 | v_dhh_node0001 |      0 | 192.168.40.200 | ipv4          |          0 | /home/dbadmin/dhh/v_dhh_node0001_catalog/Catalog | f          |           10|        0 | f           | f               |  45035996273704976 |       5433 | 192.168.40.200 | ipv4                 | 192.168.40.255   |        4803 | 45035996273704978 |       0 |            0 | t
(1 row)
相关推荐
何中应2 小时前
vmware的linux虚拟机如何设置以命令行方式启动
linux·运维·服务器
野犬寒鸦2 小时前
从零起步学习并发编程 || 第一章:初步认识进程与线程
java·服务器·后端·学习
百炼成神 LV@菜哥3 小时前
Kylin Linux V10 aarch64 安装启动 TigerVNC-Server
linux·服务器·kylin
m0_737302583 小时前
百度智能云边缘云服务器,端云协同赋能全域智能场景
服务器
Anastasiozzzz3 小时前
LeetCode Hot100 295. 数据流的中位数 MedianFinder
java·服务器·前端
ipooipoo11884 小时前
动态住宅IP的定义、核心优势与技术场景应用
网络·网络协议·tcp/ip
Exquisite.4 小时前
Nginx
服务器·前端·nginx
j_xxx404_4 小时前
Linux:进程程序替换
linux·运维·服务器
祁鱼鱼鱼鱼鱼4 小时前
Keepalived实验环境设定
linux·服务器·网络
Genie cloud4 小时前
VPS 网络连接故障诊断与排查实用指南
linux·服务器·ssh