1.脚本如下
snc-sdyd-oceanbase02:~/lhh # cat orac host="172.16.100.136" password=ShSnc123!@# if [ "$1" = "version" ]; then mysql -h"$host" -P2881 -uroot@sys -p${password} -c -Doceanbase -e" select version(); " fi if [ "$1" = "status" ]; then echo "######################################集群状态信息#############################################################" mysql -h"$host" -P2881 -uroot@sys -p${password} -c -Doceanbase -e" select svr_ip,with_rootserver rs,zone, ORA_DECODE(start_service_time, 0, NULL, CAST(usec_to_time(start_service_time) AS DATETIME)) start_service_time, ORA_DECODE(stop_time, 0, NULL, CAST(usec_to_time(stop_time) AS DATETIME)) stop_time, ORA_DECODE(last_offline_time, 0, NULL, CAST(usec_to_time(last_offline_time) AS DATETIME)) last_offline_time,status, SUBSTR(build_version, 1, INSTR(build_version, '-') - 1) build_version FROM __all_server; " fi
2.命令执行
snc-sdyd-oceanbase02:~/lhh # orac version +---------------------------+ | version() | +---------------------------+ | 5.7.25-OceanBase-v3.2.3.2 | +---------------------------+ snc-sdyd-oceanbase02:~/lhh # snc-sdyd-oceanbase02:~/lhh # orac status ######################################集群状态信息############################################################# +----------------+----+-------+---------------------+-----------+-------------------+--------+----------------------------+ | svr_ip | rs | zone | start_service_time | stop_time | last_offline_time | status | build_version | +----------------+----+-------+---------------------+-----------+-------------------+--------+----------------------------+ | 172.16.100.136 | 1 | zone1 | 2023-01-17 17:20:06 | NULL | NULL | active | 3.2.3.2_105020012022101916 | | 172.16.100.137 | 0 | zone2 | 2023-01-17 17:20:06 | NULL | NULL | active | 3.2.3.2_105020012022101916 | | 172.16.100.138 | 0 | zone3 | 2023-01-17 17:20:06 | NULL | NULL | active | 3.2.3.2_105020012022101916 | +----------------+----+-------+---------------------+-----------+-------------------+--------+----------------------------+
标签:status,17,oceanbase,数据库,version,3.2,time,NULL,ora From: https://www.cnblogs.com/hanglinux/p/17158117.html