mongo db 上的自动化脚本给出二进制错误
automation script on mongo db giving binary error
正在尝试 运行 mongo db 上的脚本来检查 utlization 出现错误:无法执行二进制文件,任何建议。
[bp09@zlv172 ~]$ sh disk.sh
./kubectl config use-context agef
./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
尝试时:
./kubectl exec -it mongoagef-2 -c mongo bash -- file /usr/bin/df
bash:文件:没有这样的文件或目录命令以退出代码 127 终止
./kubectl config use-context agef
./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
[bp09@zlv172 ~]$ ./kubectl config use-context agef
Switched to context "agef".
[bp09@zlv172 ~]$ ./kubectl get pods
NAME READY STATUS RESTARTS AGE
mongoagef-0 2/2 Running 0 20d
mongoagef-1 2/2 Running 0 24d
mongoagef-2 2/2 Running 0 20d
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash
bash-4.2$ df -h /data/db
Filesystem Size Used Avail Use% Mounted on
/de/map/data_vg-shared_vol2 3.5T 1.8T 501G 75% /data/db
但是当 运行 时:-
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- file /usr/bin/df -h
bash: file: No such file or directory
command terminated with exit code 127
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- file /bin/df -h
bash: file: No such file or directory
command terminated with exit code 127
当使用以下 locate df 命令检查时,输出是:-
[bp09@zlv172 ~]$ 定位 df
/bin/df
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash
bash-4.2$ cd /usr/bin
bash-4.2$ ls -lrth|grep -i df
-rwxr-xr-x 1 root root 99K Oct 30 2018 df
k exec -it mongo -c mongo -- /bin/sh -c df 这个工作正常。
正如您提到的那样,当您登录到容器和 运行 命令时,df
命令有效,但在 运行 使用 exec
时无效。或者你调用 shell 然后调用你需要的命令。例如:
kubectl exec -it mongo -c mongo -- /bin/sh -c df
-c If the -c option is present, then commands are read from the first non-option argument command_string. If there are
arguments after the com‐
mand_string, the first argument is assigned to [=13=] and any remaining arguments are assigned to the positional parameters.
The assignment to [=13=]
sets the name of the shell, which is used in warning and error messages.
正在尝试 运行 mongo db 上的脚本来检查 utlization 出现错误:无法执行二进制文件,任何建议。
[bp09@zlv172 ~]$ sh disk.sh
./kubectl config use-context agef
./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
尝试时:
./kubectl exec -it mongoagef-2 -c mongo bash -- file /usr/bin/df
bash:文件:没有这样的文件或目录命令以退出代码 127 终止
./kubectl config use-context agef
./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
[bp09@zlv172 ~]$ ./kubectl config use-context agef
Switched to context "agef".
[bp09@zlv172 ~]$ ./kubectl get pods
NAME READY STATUS RESTARTS AGE
mongoagef-0 2/2 Running 0 20d
mongoagef-1 2/2 Running 0 24d
mongoagef-2 2/2 Running 0 20d
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash
bash-4.2$ df -h /data/db
Filesystem Size Used Avail Use% Mounted on
/de/map/data_vg-shared_vol2 3.5T 1.8T 501G 75% /data/db
但是当 运行 时:-
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- df -h
/usr/bin/df: /usr/bin/df: cannot execute binary file
command terminated with exit code 126
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- file /usr/bin/df -h
bash: file: No such file or directory
command terminated with exit code 127
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash -- file /bin/df -h
bash: file: No such file or directory
command terminated with exit code 127
当使用以下 locate df 命令检查时,输出是:- [bp09@zlv172 ~]$ 定位 df
/bin/df
[bp09@zlv172 ~]$ ./kubectl exec -it mongoagef-2 -c mongo bash
bash-4.2$ cd /usr/bin bash-4.2$ ls -lrth|grep -i df
-rwxr-xr-x 1 root root 99K Oct 30 2018 df
k exec -it mongo -c mongo -- /bin/sh -c df 这个工作正常。
正如您提到的那样,当您登录到容器和 运行 命令时,df
命令有效,但在 运行 使用 exec
时无效。或者你调用 shell 然后调用你需要的命令。例如:
kubectl exec -it mongo -c mongo -- /bin/sh -c df
-c If the -c option is present, then commands are read from the first non-option argument command_string. If there are arguments after the com‐ mand_string, the first argument is assigned to [=13=] and any remaining arguments are assigned to the positional parameters. The assignment to [=13=] sets the name of the shell, which is used in warning and error messages.