In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to use Cassandra, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
First, let's introduce the installation and startup of Cassandra:
There are 3 installation options for Cassandra:
1. Community Edition:
Address: http://planetcassandra.org/Download/DataStaxCommunityEdition
Description: free of charge for development and production environment
two。 Enterprise edition
Address: http://www.datastax.com/download
Description: the development environment is free and the production environment requires license
3. Open source version
Address: http://www.datastax.com/download
Github address: https://github.com/apache/cassandra
Installation method, Cassandra has yum,tarball installation mode, we choose tarball installation:
According to the download address above, we download and extract the * .tar.gz file
As you can see, bin,conf, tools and other directories are included after decompression.
Run Cassandra directly under the bin directory
Start Cassandra:
Bin/cassandra
Cassandra will produce diary files in the log directory. Check "statejump to normal" to indicate that the startup is successful.
INFO 15:09:21 Node localhost/127.0.0.1 state jump to normal
II. CQL Foundation
It mainly includes the following knowledge points:
What is CQL?
What is Keyspaces?
What is Tables?
Basic datatypes
What is CQL?
The full name of CQL: Cassandra Query Language, which is Cassandra query syntax, similar to SQL.
SELECT * FROM users
What is Keyspaces?
Keyspaces is the outermost / top-level container of data in Cassandra, similar to the concept of schema for relational databases. There is an attribute Replication that defines the global behavior across the entire Keyspaces scope.
CREATE KEYSPACE killrvideoWITH REPLICATION = {'class':' SimpleStrategy', 'replication_factor': 1}
Toggle Keyspaces method: use USE
USE killrvideo
What is Tables?
Keyspaces contains tables,tables contains data, similar to a table container in a relational database.
Basic data types:
Type description
Text
UTF-8 coding
Varchar is the same as text
Int
Symbolic type
32 bit
Timestamp
64-bit integer
The number of seconds stored from 00:00:00 on 1970-01-01
UUID and TIMEUUID types
Used to replace integer id (because Cassandra is a distributed database)
Full name of UUID: Universally Unique Identifier
For example: 52b11d6d-16e2-4ee2-b2a9-5ef1e9589328
Generated by uuid ()
TIMEUUID: embed timestamp in UUID values
For example: 1be43390-9fe4-11e3-8d05-425861b86ab6
Sortable, generated by now ()
INSERT syntax:
Similar to relational grammar
INSERT INTO users (user_id, first_name, last_name) VALUES (uuid (), 'Joseph',' Chu')
SELECT syntax:
Similar to relational grammar
SELECT * FROM users;SELECT first_name, last_name FROM users;SELECT * FROM users WHERE user_id = 4b516be3-ddf0-4c43murbab6murbabb91d674b64a5; above is all the content of this article "how to use Cassandra". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.