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)
相关推荐
hrrrrb18 分钟前
【TCP/IP】5. IP 协议
网络协议·tcp/ip·php
工藤新一¹32 分钟前
Linux 开发工具
linux·运维·服务器
W111115_40 分钟前
网络综合实验
linux·运维·服务器·网络
cui_win41 分钟前
【网络】Linux 内核优化实战 - net.ipv4.tcp_sack
linux·网络·tcp/ip
山川绿水1 小时前
Ubuntu22.04更新Openssh至9.9p2无法正常连接,报错解决
服务器·web安全·网络安全
古希腊数通小白(ip在学)1 小时前
HCIA实现不同vlan间的通信
linux·服务器·网络
老六ip加速器1 小时前
ip地址可以精确到什么级别?如何获取/更改ip地址
网络·网络协议·tcp/ip
星辰离彬1 小时前
Java 与 MySQL 性能优化:MySQL连接池参数优化与性能提升
java·服务器·数据库·后端·mysql·性能优化
hrrrrb1 小时前
【TCP/IP】10. 引导协议与动态主机配置协议
网络·网络协议·tcp/ip