1, first download the cassandra tgz package , I installed the 3.9 version of cassandra, download address http://
2. Unzip after downloading
Tar zxvf apache-cassandra-3.9-bin.tar.gz
3, configuration
Go to the unzipped cassandra directory and set the datafile, commitlog, and saved_caches directories in conf/cassandra.yaml. The default values ​​are: $CASSANDRA_HOME/data/data, $CASSANDRA_HOME/data/commitlog, $CASSANDRA_HOME/data/saved_caches, Set according to your own requirements
I set /var/lib/cassandra/data, /var/lib/cassandra/commitlog, /var/lib/cassandra/saved_caches.
Create these three directories and change their owners to regular users.
Sudo mkdir /var/lib/cassandra/data
Sudo mkdir /var/lib/cassandra/commitlog
Sudo mkdir /var/lib/cassandra/saved_caches
Sudo chown -R ly:ly /var/lib/cassandra/data
Sudo chown -R ly:ly /var/lib/cassandra/commitlog
Sudo chown -R ly:ly /var/lib/cassandra/saved_caches
After that, if you need to configure cassandra memory, in the cassandra-env.sh file under conf, MAX_HEAP_SIZE indicates the maximum application memory size, HEAP_NEW_SIZE indicates the initial application memory size, the two can not be set separately, otherwise cassandra error
4, running
After all is completed, you can start cassandra and run it in the cassandra directory.
Bin/cassandra
Wait, enter the command
Ps -aux | grep cassandra
View the process, when the 5012 similar process appears in the figure below, then cassandra is started.
Figure 999
5, start cql
Bin/cqlsh
Start cassandra cql editor, you can use cql statement to operate the database (enable cql condition is that the system installed 2.7 version and above python, if not, can not be opened)
6, close cassandra, use the simple and rude kill command
Kill 5012
7, test
Use java to write a simple program to insert the database, see http://ju.outofmemory.cn/entry/210437 (jdbc connection method), http://blog.csdn.net/maosijunzi/arTIcle/details/42268061 (Cassandra.Client the way)
An error may occur at runtime:
java.lang.ClassNotFoundExcepTIon:com.google.common.uTIl.concurrent.AsyncFuncTIon
Probably because of the lack of dependencies, the following jar packages are guaranteed:
Cassandra-driver-core-*.jar
Guaua-*.jar
Metrics-core-*.jar
Netty-all-*.Final.jar
Slf4j-api-*.jar
Cassandra database migration (introduction of two methods)The first way: copy command
How to use: Applicable when the amount of data is small.
How to use: copy mykeyspace.mytable to '/home/db.csv'
This successfully exports the table mytable to the db.csv file in csv format.
Then in another cluster, build an identical table and use
Copy app12345.mytable from '/home/db.csv'
Just import the data into the new library.
However, the above method is limited to a small amount of data. When the amount of data is large, the process will last for a long time, and the file will be large.
The second way: the sstableloader tool.
A sstableloader tool is provided in the bin directory of cassandra. This tool is specifically used to import a table's sstable file into a new cluster.
Suppose your table is mykeyspace.mytable. Your data is stored in a cluster of 10 nodes. The data for each point is stored in the /disk/data1 and /disk/data2 directories.
Assuming that one of your new cluster's access addresses is IP, first create a keyspace and table structure of the same name in the new cluster.
Next you just execute the following command on each node of the old cluster:
Bin/sstableloader -d IP -u cassandra -pw cassandra -t 100 /disk/data1/mykeyspace/mytable
Bin/sstableloader -d IP -u cassandra -pw cassandra -t 100 /disk/data2/mykeyspace/mytable
Where -u is the username -pw is the password -t is the limit traffic 100M/bps
After all the nodes have been executed, your table data will be successfully imported into the new cluster. Of course, as long as your machine io and network conditions allow, you can execute multiple nodes concurrently.
Euroblock, short for "European-style terminal block"; is a combination of a low-voltage disconnect (or pluggable) connector and terminal block commonly used for microphones and line-level audio signals , and for control signals such as RS-232 or RS-485. It is also known as the Phoenix connector and comes from a German Phoenix Electric Company, which was established in 1981 in Harrisburg, Pennsylvania, USA. Also known as "Plug-in Terminal Blocks" or "Two-Piece Terminal Blocks".
Eurostyle Terminal Blocks,Eurostyle Terminal Blocks High Temperature,Eurostyle Terminal Blocks Kit,Eurostyle Terminal Blocks Heat Resistant
Sichuan Xinlian electronic science and technology Company , https://www.sztmlchs.com