需求
服务器网段调整,将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_allnodesNode | 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 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:78:f3:cb brd ff:ff:ff:ff:ff:ffinet 192.168.40.200/24 brd 192.168.40.255 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe78:f3cb/64 scope linkvalid_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.200controlAddress: 192.168.40.200controlBroadcast: 192.168.40.255The 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_allnodesNode | 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)