暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Vertica数据库的免密配置及免密使用场景

原创 simonchiang 2024-08-29
203

1. 免密配置方法

管理帐户必须能够使用安全 Shell (SSH) 登录 (ssh) 所有主机而无需指定密码。shell 脚本 install_vertica 会自动执行此操作。本节介绍如何在必要时手动执行此操作。

1、如果您尚未在所有主机上安装 SSH,请以 root 身份登录每台主机并立即安装。您可以从 OpenSSH 下载免费版 SSH 连接工具。
2、登录 Vertica 管理员帐户(本例中为 dbadmin,root用户配置方法相同)。
3、使您的主目录 (~) 仅可由您自己写入。选择以下之一:

$ chmod 700 ~

or

$ chmod 755 ~

各权限代码含义:

700 includes 755 includes
400 read by owner
200 write by owner
100 execute by owner
400 read by owner
200 write by owner
100 execute by owner
040 read by group
010 execute by group
004 read by anybody (other)
001 execute by anybody

4、进入home目录

$ cd ~

5、生成私钥/公钥对:

$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/dbadmin/.ssh/id_rsa): Created directory '/home/dbadmin/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/dbadmin/.ssh/id_rsa. Your public key has been saved in /home/dbadmin/.ssh/id_rsa.pub.

6、使您的 .ssh 目录仅您自己可读可写:

$ chmod 700 ~/.ssh

7、进入.ssh目录:

$ cd ~/.ssh

8、将id_rsa.pub文件内容添加到authorized_keys2

$ cp id_rsa.pub authorized_keys2

9、使 .ssh 目录中的文件仅您自己可读写:

$ chmod 600 ~/.ssh/*

10、对于每个集群主机:

$ scp -r ~/.ssh <host>:.

11、连接到每个集群主机。第一次通过 ssh 连接到新的远程计算机时,您可能会收到类似以下内容的消息:

$ ssh dev0 Warning: Permanently added 'dev0,192.168.1.92' (RSA) to the list of known hosts.

此消息仅在您第一次 ssh 连接到特定远程主机时出现。

2. root用户免密使用场景

2.1 数据库安装、升级

2.1.1 提高效率、安全性

安装数据库前,需要检查集群每个节点的硬件配置、硬件性能、系统参数配置等等操作,如果没有免密登陆,每次登陆都需要输入密码。
当集群数量大时,免密登陆将大大提升效率。且免密登陆可避重复输入密码,降低密码泄露风险。

2.1.2 场景1:安装数据库集群时需要免密登陆

[root@v001 ~]# /opt/vertica/sbin/install_vertica --license /tmp/license.txt --accept-eula --dba-user-password password --hosts host_list --rpm package_name

在一个节点上执行install_vertica命令时,如下步骤会使用免密登陆:
1、通过root用户的免密将rpm包传输到集群所有节点;
2、通过免密发送安装rpm包命令到所有节点进行rpm包安装;
3、安装完成后还需要通过免密检查rpm包是否安装成功并返回检查结果进行校验;

2.1.3 场景2:升级数据库集群时需要免密登陆

[root@v001 ~]# /opt/vertica/sbin/update_vertica --hosts host_list --rpm package_name

在一个节点上执行update_vertica命令时,如下步骤会使用免密登陆:
1、通过root用户的免密将rpm包传输到集群所有节点;
2、通过免密发送更新rpm包命令到所有节点进行rpm包更新;
3、rpm包更新完成后还需要通过免密检查rpm包是否更新成功并返回检查结果进行校验;

2.2 root用户免密是否可回收

root的免密仅在安装、升级数据库时使用,日常运维并不需要,数据库安装、升级操作完成后即可回收。

3. dbadmin用户免密使用场景

3.1 admintools管理工具

admintools管理工具是数据库日常运维管理工具,该工具可以创建、删除数据库,启停数据库集群,启停数据库节点,监控数据库状态等40余项功能。
admintools管理工具的各项功能都会用到dbadmin用户的免密,故dbadmin用户必须持有免密。

3.1.1 创建、删除数据库

通过dbadmin用户使用admintools创建删除数据库时,需要通过免密登陆到所有节点创建相应的文件目录。
1、创建数据库

[dbadmin@v001 ~]$ admintools -t create_db -d vmart -sv001 -pvertica

2、删除数据库

[dbadmin@v001 ~]$ admintools -t drop_db -d vmart

3.1.2 启动、停止数据库集群

通过dbadmin用户使用admintools启动、停止数据库时,需要通过免密登陆到所有节点拉起Vertica进程、关闭Vertica进程并返回执行结果。
1、启动数据库

[dbadmin@v001 ~]$ admintools -t start_db -d vmart -pvertica -F

2、关闭数据库

[dbadmin@v001 ~]$ admintools -t stop_db -d vmart -pvertica -F

3.1.3 启动、停止数据库节点

通过dbadmin用户使用admintools启动、关闭数据库节点时,需要通过免密登陆到对应节点拉起Vertica进程、关闭Vertica进程并返回执行结果。
1、启动数据库节点

[dbadmin@v001 ~]$ admintools -t restart_node -s v001 -d vmart -pvertica

2、关闭数据库节点

[dbadmin@v001 ~]$ admintools -t stop_node -s v001 -d vmart -pvertica

3.1.4 监控数据库状态

通过dbadmin用户使用admintools工具检查数据库状态时,需要通过免密登陆到所有节点获取每个节点的Vertica进程状态。
1、检查集群状态

[dbadmin@v001 ~]$ admintools -t view_cluster DB | Host | State -------+------+------- vmart | ALL | UP

2、检查节点状态

[dbadmin@v001 ~]$ admintools -t list_allnodes Node | Host | State | Version | DB ------------------+-------------+-------+-------------------+------- v_vmart_node0001 | 10.211.55.6 | UP | vertica-12.0.4.25 | vmart

3.2 vbr备份

vbr备份是数据库自带的数据库备份工具,在dbadmin用户使用该工具进行备份时亦需要通过用户的免密到所有节点执行相关命令。

[dbadmin@v001 ~]$ /opt/vertica/bin/vbr No valid options found vertica backup and restore script help -h --help print help message -t --task { backup | restore | copycluster | replicate | listbackup | init | quick-check | full-check | quick-repair | collect-garbage | remove } specify task -c --config-file mybackup.conf specify config file --debug { 0 | 1 | 2 | 3 } change output message level --nodes v_mydb_node0001[,...] only operate on nodes inside the comma separated list --showconfig displays parameters in the config file --archive < yymmdd_hhmmss > only valid with --task restore, specify which archive to restore from, and --task remove, specify which archive(s) to remove --dry-run only valid with --task backup/restore/copycluster/replicate, check what the vbr task is going to do, before actually doing --json only valid with --task listbackup, output json format on screen --list-all only valid with --task listbackup, let listbackup list all snapshots on backup hosts --list-output-file only valid with --task listbackup, specify the file to output --report-file only valid with --task full-check, specify the file to output, output content is lists of files --restore-objects obj[,...] only valid with --task restore, specify which objects to restore --include-objects pattern[,...] only valid with --task restore, specify object wildcards to include objects for restore --exclude-objects pattern[,...] only valid with --task restore, specify object wildcards to exclude objects from restore --[s3-force-init | cloud-force-init] only valid with --task init, force to reinitialize S3/GS backup locations

3.3 dbadmin用户免密是否可回收

因dbadmin用户为Vertica数据库日常运维用户,故该用户的免密不可回收。

二维码.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论