重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1402|回复: 0
打印 上一主题 下一主题

[基础命令] tar压缩报错:Exiting with failure status due to previous errors的处理

[复制链接]
跳转到指定楼层
楼主
发表于 2022-4-21 09:47:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
系统:CentOS 7.6
备份ORACLE_HOME时报以下异常:
[oracle@dbserver ~]$ tar -cvfp product.tar.gz /u01/app/oracle/
/u01/app/oracle/oradata/orcl/temp01.dbf
/u01/app/oracle/archive/
tar: Exiting with failure status due to previous errors

经查询资料,确认此异常最有可能是tar命令压缩的某个文件过程中,
该用户并不具备读权限,因此切换root用户进行压缩,如下:
[root@dbserver ~]# tar -cvfp product.tar.gz /u01/app/oracle/
tar: Exiting with failure status due to previous errors

结果依然报出此异常

问题:
1、如何确定错误根源?
2、tar命令打印出"previous errors"到底是什么错误?

要找到这些信息,可以把tar命令的标准输出(stdout)进行过滤,如下:
[oracle@dbserver ~]$ tar zcvf product.tar.gz /u01/app/oracle/ >/dev/null
tar: Removing leading `/' from member names
tar: /u01/app/oracle/product/11.2.0/db_1/bin/nmb: Cannot open: Permission denied
tar: /u01/app/oracle/product/11.2.0/db_1/bin/nmhs: Cannot open: Permission denied
tar: /u01/app/oracle/product/11.2.0/db_1/bin/nmo: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors

由此可见,造成此异常原因如下:
1、无权限 —— 切换root解决
2、去除文件名中前导的根目录“/”  

说明:对于异常原因2,tar命令在压缩文件时,默认使用相对路径,如果使用绝对路径,便会报该错误.
此时可以加参数P,不要去掉文件名开头的'/',即使用绝对路径进行压缩,如下成功压缩:

[root@dbserver ~]# tar -zcvPf product.tar.gz /u01/app/oracle >/dev/null
[root@dbserver ~]# ll                    
total 2617380
-rw-r--r--. 1 root root  233770311 Mar  2 14:04 alert_jbzyydb2.log20220302
-rw-------. 1 root root       2307 Nov 25 21:05 anaconda-ks.cfg
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Desktop
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Documents
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Downloads
-rw-r--r--. 1 root root       2400 Nov 25 21:11 initial-setup-ks.cfg
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Music
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Pictures
-rw-r--r--  1 root root 2446414252 Apr 19 23:43 product.tar.gz
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Public
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Templates
drwxr-xr-x. 2 root root          6 Nov 25 21:27 Videos

注意:-zcvPf不能写出-zcvfP,P不能放到最后,因为f必须紧跟要创建的文件名称.

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-6-17 16:19 , Processed in 0.090761 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表