简体   繁体   English

在窗口中使用 docker 将数据导入 Cassandra

[英]Import data into Cassandra using docker in window

Hi i am trying to load into cassandra in docker.嗨,我正在尝试加载到 docker 中的 cassandra。 Unfortunately, i can't make it.不幸的是,我做不到。 I pretty sure the path is correct, as i directly copy and paste from the properties section.我很确定路径是正确的,因为我直接从属性部分复制和粘贴。 May i know is there any alternative to solve it?我可以知道有没有其他方法可以解决它?

ps i am using windows 11, latest cassandra 4.1 ps我正在使用Windows 11,最新的cassandra 4.1

cqlsh:cds502_project> COPY data (id)
                  ... FROM 'D:\USM\Data Science\CDS 502 Big data storage and management\Assignment\Project\forest area by state.csv' 
                  ... WITH HEADER = TRUE; 
Using 7 child processes

Starting copy of cds502_project.data with columns [id].
Failed to import 0 rows: OSError - Can't open 'D:\\USM\\Data Science\\CDS 502 Big data storage and management\\Assignment\\Project\\forest area by state.csv' for reading: no matching file found,  given up after 1 attempts
Processed: 0 rows; Rate:       0 rows/s; Avg. rate:       0 rows/s
0 rows imported from 0 files in 0.246 seconds (0 skipped).

above is my code and the result.以上是我的代码和结果。 I have tried https://www.geeksforgeeks.org/export-and-import-data-in-cassandra/ exactly and it works when i create the data inside the docker, export and reimport it, but not working when i use external data.我已经尝试过https://www.geeksforgeeks.org/export-and-import-data-in-cassandra/并且当我在 docker 中创建数据时它有效,导出并重新导入它,但当我使用外部时不起作用数据。

I also notice the csv file i exported using cassandra in docker is missing in my laptop but can be access by docker.我还注意到我在 docker 中使用 cassandra 导出的 csv 文件在我的笔记本电脑中丢失,但可以通过 docker 访问。

Behaviour you are observing is what is expected from docker.您正在观察的行为是 docker 所期望的。 What I know there are cp commands in Kubernetes which copy the data from outside to inside container and vice-versa.据我所知,Kubernetes 中有 cp 命令可以将数据从容器外部复制到内部容器,反之亦然。 Either you can check those commands to take the data from inside or outside the docker or other way is you can push your csv into docker using a Docker Image.您可以检查这些命令以从 docker 内部或外部获取数据,或者您可以使用 Docker Image 将 csv 推送到 docker 中。

you need to leverage Docker bind mounting a volume in order to access local files within your container.您需要利用 Docker 绑定挂载卷才能访问容器中的本地文件。 docker run -it -v <path>...

See references below:请参阅以下参考资料:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM