openGauss单独安装卸载CM代码解读

2023年 8月 26日 114.3k 0

单独安装

前置检查

判断CM是否安装

source /home/omm/.bashrc; gs_om -t status --detail | grep 'CMServer State' > /dev/null

term

新安装集群,需要做两次切换,切换到其他节点,再切回原主。

开始安装

创建目录

# create path: cmdir、cmdir/cm_server、cmdir/cm_agent
mkdir -p /app/ogdata/data/cm/cm_server /app/ogdata/data/cm/cm_agent # 所有节点均需要创建 来源single.xml

解压包

# Decompressing CM pacakage
tar -zxf /app/scripts/01_og_intall/package/tar/openGauss-3.0.5-openEuler-64bit-cm.tar.gz -C /app/opengauss/app/2.0.1
# 检查cm、gaussdb版本
source /home/omm/.bashrc; cm_ctl -V
#cmVersionList = re.findall(r'.*CM (\d.*\d) build', output)
source /home/omm/.bashrc; gaussdb -V
# 复制到其他节点
scp /app/scripts/01_og_intall/package/tar/openGauss-3.0.5-openEuler-64bit-cm.tar.gz pghost2:/app/opengauss/tool
/app/opengauss/tool/openGauss-3.0.5-openEuler-64bit-cm.tar.gz
tar -zxf /app/opengauss/tool/openGauss-3.0.5-openEuler-64bit-cm.tar.gz -C /app/opengauss/app/2.0.1

创建cluster_manual_start文件

Creating cluster_manual_start file

if [ ! -f /app/opengauss/app/2.0.1/bin/cluster_manual_start ]; then
touch /app/opengauss/app/2.0.1/bin/cluster_manual_start
fi # 所有节点均需要创建

初始化CMServer-initCMServer

# 所有节点均需要执行 /app/ogdata/data/cm
cp /app/opengauss/app/2.0.1/share/config/cm_server.conf.sample /app/ogdata/data/cm/cm_server/cm_server.conf
sed 's#log_dir = .*#log_dir = /app/opengauss/gaussdb_log/omm/cm/cm_server#' /app/ogdata/data/cm/cm_server/cm_server.conf -i

初始化CMAgent-initCMAgent

# 所有节点均需要执行
cp /app/opengauss/app/2.0.1/share/config/cm_agent.conf.sample /app/ogdata/data/cm/cm_agent/cm_agent.conf
sed 's#log_dir = .*#log_dir = /app/opengauss/gaussdb_log/omm/cm/cm_agent#' /app/ogdata/data/cm/cm_agent/cm_agent.conf -i sed 's#unix_socket_directory = .*#unix_socket_directory = /app/opengauss/app/2.0.1#' app/ogdata/data/cm/cm_agent/cm_agent.conf -i

createCMCA

Creating CM ca files

/app/opengauss/app/2.0.1/share/sslcert/cm
rm /app/opengauss/app/2.0.1/share/sslcert/cm -rf; mkdir /app/opengauss/app/2.0.1/share/sslcert/cm
# OPENSSL: Create config file.
'[ v3_ca ]\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid:always,issuer:always\nbasicConstraints = CA:true\nkeyUsage = keyCertSign,cRLSign'
/app/opengauss/app/2.0.1/share/sslcert/cm/openssl.cnf写入上述内容:
v3CaL = [
"[ v3_ca ]",
"subjectKeyIdentifier=hash",
"authorityKeyIdentifier=keyid:always,issuer:always",
"basicConstraints = CA:true",
"keyUsage = keyCertSign,cRLSign",
]
source /home/omm/.bashrc; echo "oracle_4U" | sh /app/opengauss/app/2.0.1_5564ce8e/tool/cm_tool/CreateCMCACert.sh

# 删除无用文件
/app/opengauss/app/2.0.1/share/sslcert/cm
删除不是 ["cacert.pem", "server.crt", "server.key", "client.crt", "client.key", "server.key.cipher", "server.key.rand", "client.key.cipher", "client.key.rand"] 的文件

# Distributing CM ca files to other hosts. 在其他节点上执行
rm /app/opengauss/app/2.0.1/share/sslcert/cm -rf; mkdir /app/opengauss/app/2.0.1/share/sslcert/cm; chmod 700 /app/opengauss/app/2.0.1/share/sslcert/cm

scp /app/opengauss/app/2.0.1/share/sslcert/cm/* pghost2:/app/opengauss/app/2.0.1/share/sslcert/cm

刷新静态配置文件

'\n source /home/omm/.bashrc;\n gs_om -t generateconf -X /home/omm/single.xml --distribute\n '

配置OM定时任务

# setMonitorCrontab
## 备份原来的定时任务
crontab -l > /app/opengauss/tmp/cronContentTmpFile_145125
## 删除已经存在的om定时任务
sed '/.*om_monitor.*/d' /app/opengauss/tmp/cronContentTmpFile_145125 -i

source /etc/profile;(if [ -f ~/.profile ];then source ~/.profile;fi);source ~/.bashrc;source /home/omm/.bashrc; nohup om_monitor -L /app/opengauss/gaussdb_log/omm/cm/om_monitor >>/dev/null 2>&1 &
## 写入定时任务 ## 所有节点都需要配置。
*/1 * * * * source /etc/profile;(if [ -f ~/.profile ];then source ~/.profile;fi);source ~/.bashrc;source /home/omm/.bashrc; nohup om_monitor -L /app/opengauss/gaussdb_log/omm/cm/om_monitor >>/dev/null 2>&1 &\n
# kill residual om_monitor, otherwise cm_agent won't be started if there are residual om_monitor process.
pkill om_monitor -u omm;

启动集群

source /home/omm/.bashrc; cm_ctl start
# 刷新动态配置文件
# 查看集群状态

单独卸载

前置检查

检查操作用户

检查传入的参数

检查single.xml中cm信息:(不能有cm的信息)

grep -E 'cmDir|cmsNum|cmServerPortBase|cmServerPortStandby|cmServerlevel|cmServerListenIp1|cmServerRelation' /home/omm/single.xml

获取节点主机名信息

检查互信配置:

ssh -o ConnectTimeout=3 -o ConnectionAttempts=5 -o PasswordAuthentication=no -o StrictHostKeyChecking=no pghost1 'pwd > /dev/null'

开始卸载

获取CMDataPaths

# Get cmDataPaths of all nodes from static file.
source /home/omm/.bashrc; cm_ctl view | grep -E 'cmDataPath'

清理om定时任务

# 所有节点均执行
crontab -l > /tmp/cronContentTmpFile_171575
sed '/.*om_monitor.*/d' /tmp/cronContentTmpFile_171575 -i
crontab /tmp/cronContentTmpFile_171575
rm -f /tmp/cronContentTmpFile_171575

停止stopCMProcess

ps -xo pid,command | grep -E 'om_monitor|cm_agent|cm_server|fenced UDF' | grep -v grep

刷新动态和静态配置文件

gs_om -t generateconf ....
source /home/omm/.bashrc; rm -f $GAUSSHOME/bin/cluster_dynamic_config
source /home/omm/.bashrc; ls $GAUSSHOME/bin/cluster_manual_start
gs_om -t refreshconf

删除二进制文件

# delete CM binaries, include om_monitor, cm_agent, cm_server, cm_ctl
source /home/omm/.bashrc; cd $GAUSSHOME/bin; rm -f om_monitor* cm_agent* cm_server* cm_ctl* cm_persist* *manual*start* promote_mode_cms; cd -

删除CMData

# remove cmdatapath
source /home/omm/.bashrc; rm -rf /app/ogdata/data/cm $GAUSSLOG/cm $GAUSSHOME/share/sslcert/cm

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论