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)
相关推荐
Antonio91520 分钟前
【Linux】Linux多路复用-poll
linux·服务器
bcxwz6691 小时前
软死锁的检测--看门狗
运维·服务器·网络
wei_work@3 小时前
【linux】简单的shell脚本练习
linux·运维·服务器
XiaoCCCcCCccCcccC4 小时前
传输层协议 TCP 介绍 -- TCP协议格式,确认应答机制,超时重传机制,连接管理机制,滑动窗口,流量控制,拥塞控制,延迟应答,捎带应答
网络·网络协议·tcp/ip
conkl5 小时前
Apache网页优化实战指南 - 让网站加载速度提升
linux·运维·服务器·开发语言·阿里云·apache
天空之城夢主5 小时前
PostgreSQL 初体验
数据库·postgresql
huangyuchi.5 小时前
【Linux】初见,进程概念
linux·服务器·操作系统·进程·进程管理·pcb·fork
搬码临时工6 小时前
域名访问内网网站知多少?通过自定义域名访问本地Web 服务
服务器·网络·tcp/ip
五阿哥爱跳舞6 小时前
【环境配置】解决linux每次打开终端都需要source .bashrc文件的问题
linux·运维·服务器
网易独家音乐人Mike Zhou7 小时前
【Linux应用】Linux系统日志上报服务,以及thttpd的配置、发送函数
linux·运维·服务器·mcu·物联网·嵌入式·iot