file decompression error during kafka installation with chef - ruby

I'm trying to install kafka using the supermarket recipe as my starting point. But when I run kitchen converge it gives me the following error. It should be something inherent in the archive. What do you think?platform kitchen ubuntu 14.04 tar version 1.27.1
execute 'kafka-install' do
cwd node['kafka']['install_dir']
command <<-EOH
wget http://www-us.apache.org/dist/kafka/2.5.0/kafka_2.12-2.5.0.tgz && \
tar -zxf kafka_2.12-2.5.0.tgz && \
useradd -M #{node['kafka']['user']} && \
chown #{node['kafka']['user']}:#{node['kafka']['group']} -R #{node['kafka']['install_dir']} && \
chown +x /kafka/bin/*.sh
EOH
end
I get the following error
Error executing action `run` on resource 'execute[kafka-install]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
---- Begin output of wget http://www-us.apache.org/dist/kafka/2.5.0/kafka_2.12-2.5.0.tgz && tar -zxf kafka_2.12-2.5.0.tgz && useradd -M kafka && chown kafka:kafka -R /kafka && chown +x /kafka/bin/*.sh
----
STDOUT:
STDERR: --2020-06-09 18:21:40-- http://www-us.apache.org/dist/kafka/2.5.0/kafka_2.12-2.5.0.tgz
tar: Skipping to next header
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Substituting `.' for empty member name
tar: .: Unknown file type ' ', extracted as normal file
tar: .: Cannot open: Is a directory
tar: Skipping to next header
gzip: stdin: invalid compressed data--format violated
tar: Child returned status 1
tar: Error is not recoverable: exiting now
---- End output of wget http://www-us.apache.org/dist/kafka/2.5.0/kafka_2.12-2.5.0.tgz && tar -zxf kafka_2.12-2.5.0.tgz && useradd -M kafka && chown kafka:kafka -R /kafka && chown +x /kafka/bin/*.sh
----
Ran wget http://www-us.apache.org/dist/kafka/2.5.0/kafka_2.12-2.5.0.tgz && tar -zxf kafka_2.12-2.5.0.tgz && useradd -M kafka && chown kafka:kafka -R /kafka && chown +x /kafka/bin/*.sh
returned 2
I tried the tar command in ubuntu 18.04 and it works, tar version 1.29

Related

Issues with tar command

I'm trying to figure out why is the following tar command not working -
I've tried the following 2 versions & both don't work -
Version 1
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar -C '/home/jhonst/data_lake/1m/*.UX.csv'
The error I see is
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.
Version 2
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar -C '/home/jhonst/data_lake/1m/*.UX.csv' .
The error I see is
tar:
/home/jhonst/data_lake/1m/*.UX.csv: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Please could someone guide me on what I am doing wrong
When you do:
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar /home/jhonst/data_lake/1m/*.UX.csv
You'll get:
tar -t -f /home/jhonst/data_lake/1m/UX.tar
home/jhonst/data_lake/1m/file1.UX.csv
home/jhonst/data_lake/1m/file2.UX.csv
...
Which is not the best. There are two possibilities for getting rid of the "path" inside the tar archive:
Go inside the directory with cd (in a subshell or with pushd/popd if you want to return to the original directory after the tar command):
cd /home/jhonst/data_lake/1m && tar -c --use-compress-program=pigz -f UX.tar *.csv
# returning to the same place after the tar:
(cd /home/jhonst/data_lake/1m && tar -c --use-compress-program=pigz -f UX.tar *.csv)
# or:
pushd /home/jhonst/data_lake/1m && {
tar -c --use-compress-program=pigz -f UX.tar *.csv
popd
}
Use the -C option of GNU tar, which is not that easy to handle:
dirpath=/home/jhonst/data_lake/1m
files=("$dirpath"/*.csv)
tar -c --use-compress-program=pigz -f "$dirpath"/UX.tar -C "$dirpath" "${files[#]#$dirpath/}"

How to tar files based on the file name?

There are some files in /var/log as below:
cron
cron-20200322
maillog-20200329
tallylog
bootscan.log
bootscan.log-20200115.gz
bootscan.log-20200116.gz
I want to backup files:cron;cron-20200322;bootscan.log;bootscan.log-20200115.gz;bootscan.log-20200116.gz to a single file /mnt/log_backup.tar
Then,I witer bash shell script as below:
#!/bin/bash
backup_dir='/mnt'
tar -cpf $backup_dir/log_backup.tar -C /var/log cron*
tar -cpfr $backup_dir/log_backup.tar -C /var/log boot*
Sadly, I got error as below:
tar: cron*: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar: Removing leading `/' from member names
tar: boot*: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
What's the problem in my shell script?
The globbing of * is evaluated before changing the folder to /var/log.
Check How to make tar globbing work with the 'change directory' option
find . /var/log -maxdepth 1 -type f -name "boot*" -print0 | tar -cpf $backup_dir/log_backup.tar --null -T -
find . /var/log -maxdepth 1 -type f -name "cron*" -print0 | tar -rpf $backup_dir/log_backup.tar --null -T -
I think it's the correct answer,maybe not the best one.
Pls contribute you 2 cents if any better solution,thks!

How to unzip a dump file created by Rethinkdb

In a Linux directory ~/Documents/Scratch, I've created the following tar file using the rethinkdb dump command:
kurt#kurt-ThinkPad:~/Documents/Scratch$ ls -tr | tail -n1
rethinkdb_dump_2016-10-10T16:58:32.tar.gz
However, if I try to untar this file, I get an "unexpected end of file" error:
kurt#kurt-ThinkPad:~/Documents/Scratch$ tar -zxvf rethinkdb_dump_2016-10-10T16:58:32.tar.gz
tar (child): Cannot connect to rethinkdb_dump_2016-10-10T16: resolve failed
gzip: stdin: unexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now
Do I perhaps have to rename the file before unzipping it?
Yes you can rename it.
mv rethinkdb_dump_2016-10-10T16\:58\:32.tar.gz rethinkdb.tgz
tar zxvf rethinkdb.tgz
Or you can force it to look localy using --force-local:
tar -zxvf rethinkdb_dump_2016-10-10T16\:58\:32.tar.gz --force-local

Tar: Cannot stat: No such file or directory even though directory exists

I've created a temporary directory in a Makefile:
export TMP := $(shell mktemp -d -t), do a bunch of work there. Then I want to create a tarball.
tar czf ../packages/$(PACKAGE).lin.tar.gz -C $(TMP) $(PACKAGE).lin
The issue is that this command always gives
Tar: Cannot stat: No such file or directory
I've added a test to see if the directory exists using this right before the tar:
if [ -d $(TMP)/$(PACKAGE).lin ]; then echo "Dir exists"; fi
I see the echo, the directory does exist. I also cannot cd into that directory!?
Also, it seems to be dropping the latter part of the directory name...it will say cannot stat'$(PACKAGE)' instead of '$(PACKAGE).lin'.
If I do this:
cd $(TMP)
tar czf ../packages/$(PACKAGE).lin.tar.gz $(PACKAGE).lin
Then it will say cannot stat $(PACKAGE).lin.

tar: Unexpected EOF in archive

I am trying extract .tar.gz file it but with no luck
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
the file tar.gz include another file.tar only which is has the issue
when i trying to extract .tar file i got
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
i tried –ignore-zeros –ignore-failed-read with no luck
how could i extract this file even if it corrupted ?
You tar file is truncated. tar extracts everything present in the archive but cannot invent the missing part.

Resources