首页 > 应用开发 > IT综合 > cassandra backup
Cassandra can snapshot data while online using nodetool snapshot. You can then back up those snapshots using any desired system, although leaving them where they are is probably the option that makes the most sense on large clusters. nodetool snapshot triggers a node-wide flush, so all data written before the execution of the snapshot command is contained within the snapshot.
With some combinations of operating system/jvm you may receive an error related to the inability to create a process during the snapshotting, such as this on Linux
Exception in thread "main" java.io.IOException: Cannot run program "ln": java.io.IOException: error=12, Cannot allocate memory
This is caused by the operating system trying to allocate the child "ln" process a memory space as large as the parent process (the cassandra server), even though it's not going to use it. So if you have a machine with 8GB of RAM and no swap, and you gave 6GB to the cassandra server, it will fail during this because the operating system wants 12 GB of virtual memory before allowing you to create the process.
This error can be worked around by either :
OR
OR
To restore a snapshot:
You can get an eventually consistent backup by snapshotting all node; no individual node's backup is guaranteed to be consistent but if you restore from that snapshot then clients will get eventually consistent behavior as usual.
There is no such thing as a consistent view of the data in the strict sense, except in the trivial case of writes with consistency level = ALL.
-------------------------------test---------------------------------
restore:
1.stop node
pgep -u `whoami` -f cassandra |xargs kill -9
2.clean commitlog and sstable
rm -f /var/lib/cassandra/commitlog/*
rm -f /dir/*
3.
cp /var/lib/cassandra/data/demo/snapshots/oxoxooxx/* /var/lib/cassandra/data/demo/
cp /var/lib/cassandra/data/demo/backups/* /var/lib/cassandra/data/demo/
4.
./cassandra
./cassandra-cli -h 192.168.100.110 -p 9160
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23937368/viewspace-1051061/ ,如需转载,请注明出处,否则将追究法律责任。