问题现象
OAT 初始化服务器失败
config os admin failed,日志报错groupadd: command not found。create admin user 2 14:22:00 114:07:47 else touch /home/"$admin_user"/$name fi chown "$admin user:$admin user"/hom /home/"$admin_user"/$name fi done [2024-11-12T14:22:00.540+0800] ERROR - bash: line 8: groupadd: command not found [2024-11-12T14:22:00.540+0800] INFO - create group ocean with gid 500 error! [2024-11-12T14:22:00.541+0800] ERROR - Task failed with exception Traceback (most recent call 1 1 last): File "/usr/local/lib/python3.9/site-packages/airflow/decoratorators/base :py", line 217, in execute return_value = super().execute(context) File "/usr/local/lib/pythons.9/site-packages/airflou/operators/python.py", line 175, in execute return_value = self.execute_callable() File "/usr/local/lib/pythons.9/site-packages/airflou/operators/python.py", line 192,in execute_callable return self.python_callable(*self.op_args,**self.op_kwargs) File "/oat/task_engine/dags/init_server_with_tag.py",line 51,in create_admin_user common.config os admin(ctx,logger) File"/oat/task engine/plugins/common-py", line 1813, in config_os_admin raise RuntimeError('config os admin failed') RuntimeError:config os admin failed [2024-11-12T14:22:00.548+0800] INFO - Marking task as FAILED. dag_id=init_server_with_tag, task_id=create_admin_user......... execution_date=2024112T060744,start_date=20241112T062200, end_date=20241112T062200 [2024-11-12T14:22:00.568+0800] ERROR - Failed to execute job 93 for task create admin user (config os admin failed....... [2024-11-12T14:22:00.596+0800] INFO - Task exited with return code 1 [2024-11-12T14:22:00.622+0800] INFO - 0 downstream tasks scheduled fr from follow-on schedule check命令行测试 groupadd 却可以成功。
[root@localhost install]# groupadd -g 500 ocean [root@localhost install]# cat /etc/group root:x:0: .....
问题原因
由于 PATH 环境变量配置的问题,在 OAT 内通过代码远程连接到对应服务器执行 groupadd 命令是找不到 groupadd 这个命令。
问题的风险及影响
OAT 初始化服务器失败。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
适用版本
OAT V3.x、V4.x 版本。
解决方法
需要 ssh obadmin@ip
能执行。 这里只要把 groupadd 的路径加入到 bashrc 里面的 PATH 即可。在打开的文件中找到 PATH 变量的定义行,通常类似于 /etc/bashrc 加一行 export PATH=$PATH:/usr/sbin。 # /etc/bashrc # system wide functions and aliases # environment stuff ff goes in /etc/profile # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. # Prevent doublesourcing export PATH=$PATH://usr/sbin -- 此处为 /etc/bashrc 中添加的一行:export PATH=$PATH:/usr/sbin if [ -z $NASHRCSOURCED"]; then BASHRCSOURCED="Y" # are we an interactive shell? if [ $PS1 ]; then if[-z "$PROMPT_COMMAND" ]; then case $TERM in xterm*|vte*) if [ -e /etc/sysconfig/bash-prompt-xterm]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm elif ["${VTE_VERSION:-0}" -ge 3405 ]; then PROMPT_COMMAND="_vte_prompt_command" else PROMPT_COMMAND="printf "\033]0;%s@%s:%s\097" "${USER}" "${HOSTNAME%%.*} " "${PW....... fi ;; screen*) if [ -e /etc/sysconfig/bash-prompt-screen ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen else PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "$USERj" "$HOSTNAME%%.*}" "${pw....... fi ;; *)在当前 SHELL 终端中执行
source /etc/bashrc命令,可以立即生效修改的内容。重试 OAT 上的失败任务。