4

Cassandra newbie here. I have just set up a proof of concept single node machine on Red Hat Linux. I finally got all of the permissions correct and started up the machine. I then created a keyspace called harvard, issues the use command to switch into harvard, and then created a table called hmxpc.

I then wanted to import a .csv file. I placed the .csv file in the cassandra folder just for simplicity, chmod 755 the file, and issued the following:

copy hmxpc (course_id, userid_di, certified, explored, final_cc_cname_di, gender, grade, incomplete_flag, last_event_di, loe_di, nchapters, ndays_act, nevents, nforum_posts, nplay_video, registered, roles, start_time_di, viewed, yob) from 'cassandra/HMXPC.csv' with header=true;

When I run it, I get the following error:

[Errno 13] Permission denied: 'import_harvard_hmxpc.err'

What am I doing wrong?

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
user2297683
  • 406
  • 1
  • 5
  • 15

7 Answers7

4

I just had the same issue. I figured it out by using the --debug flag. My floats had ',' instead of '.' so my csv couldn't be parsed. CQLSH tried to write an err file describing the issue, but I was in /root, which cassandra can't write to. So I cd'ed to /tmp and did the same, this time getting I got errors showing that my floats couldn't be parsed

sirolf2009
  • 819
  • 8
  • 15
0

The problem ended up being a Red Hat permissions issue and had nothing to do with Cassandra. Thanks for looking.

user2297683
  • 406
  • 1
  • 5
  • 15
0

I was getting the same error as show in screenshot_Errored. Moved the .csv file to .cassandra directory and was able to execute the same csql command as shown in screenshot_worked Errored Worked

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
0

Beyond the other cases that are described in other responses, the error may appear, as described below if an incorrect ordering or number of columns appears in the COPY command.

i.e consider having a CSV file with the following header line:

actor, added date, video id, character name, description, encoding, tags, title, user id 

If I use the following COPY command:

cqlsh:killrvideo> COPY videos_by_actor(actor, added_date, character_name, description, encoding, tags, title, user_id, video_id) FROM 'videos_by_actor.csv' WITH HEADER = true;

I will get the Error 13:

Using 7 child processes
Starting copy of killrvideo.videos_by_actor with columns [actor, added_date, character_name, description, encoding, tags, title, user_id, video_id].
[Errno 13] Permission denied: 'import_killrvideo_videos_by_actor.err'

If I set the names of the columns correctly in the COPY commands as follows

cqlsh:killrvideo>COPY videos_by_actor(actor, added_date, video_id, character_name, description, encoding, tags, title, user_id ) FROM 'videos_by_actor.csv' WITH HEADER = true

then command completes successfully.

Using 7 child processes

Starting copy of killrvideo.videos_by_actor with columns [actor, added_date, video_id, character_name, description, encoding, tags, title, user_id].
Processed: 81659 rows; Rate:    5149 rows/s; Avg. rate:    2520 rows/s
81659 rows imported from 1 files in 32.399 seconds (0 skipped). 
garfield
  • 571
  • 9
  • 21
0

Here's my checklist for this rather non-specific (catch-all) cqlsh error "[Errno 13] Permission denied" for the containerized use cases (e.g. when using bitnami/cassandra:latest):

  1. Make sure the path you are supplying to the COPY command is the internal (container) path, not an external one (host, PVC etc).

  2. Make sure the CSV file has correct read permissions for the internal container user ID, not the external one (host, PVC etc), especially if the CSV was created in another containerized app (e.g. Jupyter Notebook).

  3. If the file contains a header, our COPY command ends in WITH HEADER = true; (yes, omitting it also raises permission denied error...)

For example, assuming you have run your Cassandra container like this:

$ docker run -d --rm --name cassandra -v /tmp:/bitnami -u 1001 bitnami/cassandra:4.0

Then the COPY command issued in cqlsh to import a /tmp/random_data1.csv from the host should be:

> COPY dicts.dict1 (key, value) FROM '/bitnami/random_data1.csv' WITH HEADER = true;

and the /tmp/random_data1.csv file should be owned by user 1001 or accessible for reading for all users.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
0

The most bizarre reason for this error is lack of write access... to the errors file (the path to which is left empty in the default config file). This is particularly likely if running Cassandra (container) as a non-root user.

To solve it, one needs to pass a custom config file (e.g. /bitnami/cqlshrc) when executing the client:

$ cqlsh -u <user> -p <pass> --cqlshrc=/bitnami/cqlshrc

There should be a sample config cqlshrc.sample shipped with your installation (use cd / && find | grep cqlshrc to find it).

Changes to be made in your custom config file:

# uncomment this section:
; [copy-from] -> [copy-from]

# uncomment and specify custom error file 
; errfile = -> errfile = /bitnami/cassandra-errfile.txt

More info on the setting in question: errfile.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
0

I used to work on ubuntu .I faced this error by using the copy command in cassandra "copy iwm_data from '/home/manikanta/wholeCassandra_spaces.csv' with delimiter ='|';"
Using 11 child processes
[Errno 13] Permission denied
Answer
I installed Cassandra by following the link "https://archive.apache.org/dist/cassandra/3.11.11/" after installation I run the command "cqlsh" but it shows that cqlsh command not found later I run the "sudo snap install cqlsh" then the CQLSH run successfully
But the mistake is here ,now my system has two Cassandra source due to snap and due to package installation by link
so we found it by searching Cassandra in system root termainal. we found out that Cassandra placed in different directories. we remove the "cassandra from terminal"

to remove that I follwed this commands dpkg --list dpkg --list | grep cqlsh dpkg --list | grep cassandra dpkg --list | grep cass apt list --installed | grep cqlsh apt list --installed | grep cassandra snap list sudo snap remove cqlsh snap list