簡介
市中網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),市中網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為市中上1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的市中做網(wǎng)站的公司定做!Cassandra是一套開源分布式NoSQL數(shù)據(jù)庫系統(tǒng),Cassandra的主要特點是無中心的設(shè)計,其分布式集群由一堆數(shù)據(jù)庫節(jié)點共同構(gòu)成一個分布式網(wǎng)絡(luò)服務(wù),對Cassandra 的一個寫操作,會被復(fù)制到其他節(jié)點上去,對Cassandra的讀操作,也會被路由到某個節(jié)點上面去讀取。對于一個Cassandra群集來說,擴展性能是比較簡單的事情,只管在群集里面添加節(jié)點就可以了。
隨著Nosql的火熱,Hbase、Mongodb已然成了NoSQL數(shù)據(jù)庫的代表,而Cassandra在國內(nèi)的使用卻不多(據(jù)說360公司在大規(guī)模使用),根據(jù)百度指數(shù)的顯示cassandra的火熱度遠遠低于mongodb和Hbase。
而在國外,根據(jù)數(shù)據(jù)庫評分網(wǎng)站DB-Engines的16.10的最新數(shù)據(jù),cassandra排名上升到了第7,排名遠遠高于Hbase。
優(yōu)點:
1、模式靈活
使用Cassandra,像文檔存儲,你不必提前解決記錄中的字段。你可以在系統(tǒng)運行時隨意的添加或移除字段。這是一個驚人的效率提升,特別是在大型部署上。
2、真正的可擴展性
Cassandra是純粹意義上的水平擴展。為給集群添加更多容量,可以指向另一臺電腦。你不必重啟任何進程,改變應(yīng)用查詢,或手動遷移任何數(shù)據(jù)。
3、多數(shù)據(jù)中心識別
你可以調(diào)整你的節(jié)點布局來避免某一個數(shù)據(jù)中心起火,一個備用的數(shù)據(jù)中心將至少有每條記錄的完全復(fù)制。
4、范圍查詢
如果你不喜歡全部的鍵值查詢,則可以設(shè)置鍵的范圍來查詢。
5、列表數(shù)據(jù)結(jié)構(gòu)
在混合模式可以將超級列添加到5維。對于每個用戶的索引,這是非常方便的。
6、分布式寫操作
有可以在任何地方任何時間集中讀或?qū)懭魏螖?shù)據(jù)。并且不會有任何單點失敗
缺點
1. 讀的性能太慢
無中心的設(shè)計,造成讀數(shù)據(jù)時通過逆熵做計算,性能損耗很大,甚至?xí)?yán)重影響服務(wù)器運作。
2. 數(shù)據(jù)同步太慢(最終一致性延遲可能非常大)
由于無中心設(shè)計,要靠各節(jié)點傳遞信息。相互發(fā)通知告知狀態(tài),如果副本集有多份,其中又出現(xiàn)節(jié)點有宕機的情況,那么做到數(shù)據(jù)的一致性,延遲可能非常大,效率也很低的。
3. 用插入和更新代替查詢,缺乏靈活性,所有查詢都要求提前定義好。
與大多數(shù)數(shù)據(jù)庫為讀優(yōu)化不同,Cassandra的寫性能理論上是高于讀性能的,因此非常適合流式的數(shù)據(jù)存儲,尤其是寫負載高于讀負載的。與HBase比起來,它的隨機訪問性能要高很多,但不是很擅長區(qū)間掃描,因此可以作為HBase的即時查詢緩存,由HBase進行批量的大數(shù)據(jù)處理,由Cassandra提供隨機查詢的接口
4. 不支持直接接入hadoop,不能實現(xiàn)MapReduce。
現(xiàn)在大數(shù)據(jù)的代名詞就是hadoop,做為海量數(shù)據(jù)的框架不支持hadoop及MapReduce,就將被取代。除非Cassandra能夠給出其他的定位,或者海量數(shù)據(jù)解決方案。DataStax公司,正在用Cassandra重構(gòu)HDFS的文件系統(tǒng),不知道是否可以成功。
一:部署cassandra
規(guī)劃:
集群節(jié)點:3
10.10.8.3
10.10.8.4
10.10.8.5
(1)配置jdk
10.10.8.3、10.10.8.4、10.10.8.5
(2)安裝Cassandra
10.10.8.3、10.10.8.4、10.10.8.5
(3)配置
10.10.8.3、10.10.8.4、10.10.8.5
如果使用cassandra的默認配置,只需要修改如下行即可,其他性能參數(shù)請參照官方文檔。
10 cluster_name: 'My Cluster' 71 hints_directory: /data/cassandra/hints 169 data_file_directories:170 - /data/cassandra/dbdata 175 commitlog_directory: /data/cassandra/commitlog 287 saved_caches_directory: /data/cassandra/caches 343 - seeds: "10.10.8.3,10.10.8.4,10.10.8.5" 473 listen_address: localhost(4)創(chuàng)建對應(yīng)的目錄
10.10.8.3、10.10.8.4、10.10.8.5
(5)啟動進程
10.10.8.3、10.10.8.4、10.10.8.5
二:插件工具使用
(1)nodetool工具
nodetool是cassandra的集群和節(jié)點的管理和信息查看工具。
$ /opt/cassandra/bin/nodetool usage: nodetool [(-u <username> | --username <username>)] [(-pw <password> | --password <password>)] [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)] [(-h <host> | --host <host>)] [(-p <port> | --port <port>)] <command> [<args>]1:查看集群狀態(tài)
$/opt/cassandra/bin/nodetool status Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 10.10.8.3 304.71 KB 256 68.0% 64b6a935-caa6-4ed5-857b-70963e74a81d rack1 UN 10.10.8.4 173.84 KB 256 65.3% db77bd8a-2655-41c6-b13e-584cf44b8162 rack1 UN 10.10.8.5 297.2 KB 256 66.7% 8fac64f8-1ed9-4ca3-af70-dee9ebcf77c2 rack12:當(dāng)前節(jié)點狀態(tài)
$/opt/cassandra/bin/nodetool info ID : db77bd8a-2655-41c6-b13e-584cf44b8162 Gossip active : true Thrift active : true Native Transport active: true Load : 173.84 KB Generation No : 1478159246 Uptime (seconds) : 4554 Heap Memory (MB) : 297.65 / 7987.25 Off Heap Memory (MB) : 0.00 Data Center : datacenter1 Rack : rack1 Exceptions : 0 Key Cache : entries 14, size 1.08 KB, capacity 100 MB, 110 hits, 127 requests, 0.866 recent hit rate, 14400 save period in seconds Row Cache : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds Counter Cache : entries 0, size 0 bytes, capacity 50 MB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds Token : (invoke with -T/--tokens to see all 256 tokens)3:關(guān)閉cassandra的進程
$ /opt/cassandra/bin/nodetool stopdaemon Cassandra has shutdown. error: Connection refused -- StackTrace -- java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)4:查看各個列的數(shù)據(jù)詳細信息、讀寫次數(shù),響應(yīng)時間等
$ /opt/cassandra/bin/nodetool cfstats Keyspace: system_traces Read Count: 0 Read Latency: NaN ms. Write Count: 0 Write Latency: NaN ms. Pending Flushes: 0 Table: events SSTable count: 0 Space used (live): 0 Space used (total): 0 Space used by snapshots (total): 0 Off heap memory used (total): 0 SSTable Compression Ratio: 0.0 Number of keys (estimate): 0 Memtable cell count: 0 Memtable data size: 0 Memtable off heap memory used: 0 Memtable switch count: 0(2)cqlsh 命令行工具
cqlsh是cassandra的客戶端命令行工具,替代了之前版本中的cassandra-cli,能實現(xiàn)對數(shù)據(jù)的增刪改查等一些列的操作。
$ /opt/cassandra/bin/cqlsh Usage: cqlsh [options] [host [port]] CQL Shell for Apache Cassandra1:安裝python2.7(依賴python)
$ yum install openssl-devel #防止python編譯后沒有ssl模塊,導(dǎo)致cqlsh不可用 $ wget https://www.python.org/ftp/python/2.7/Python-2.7.tgz $ tar xf Python-2.7.tgz $ cd Python-2.7 $ mkdir /usr/local/python27 $ ./configure --prefix=/usr/local/python27 $ make&&make install $ ln -s /usr/local/python27/bin/python2.7 /usr/bin/python2.7如果遇到 ImportError: No module named _ssl ,就安裝openssl-devel,然后再編譯安裝python
2:連接host
$ /opt/cassandra/bin/cqlsh 10.10.8.3 9042 Connected to My Cluster at 10.10.8.3:9042. [cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4] Use HELP for help. cqlsh> show version [cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4] cqlsh> show host Connected to My Cluster at 10.10.8.3:9042.3:help命令可以看到 CQL數(shù)據(jù)操作語言的相關(guān)命令
cqlsh> help Documented shell commands: =========================== CAPTURE CLS COPY DESCRIBE EXPAND LOGIN SERIAL SOURCE UNICODE CLEAR CONSISTENCY DESC EXIT HELP PAGING SHOW TRACING CQL help topics: ================ AGGREGATES CREATE_KEYSPACE DROP_TRIGGER TEXT ALTER_KEYSPACE CREATE_MATERIALIZED_VIEW DROP_TYPE TIME ALTER_MATERIALIZED_VIEW CREATE_ROLE DROP_USER TIMESTAMP ALTER_TABLE CREATE_TABLE FUNCTIONS TRUNCATE ALTER_TYPE CREATE_TRIGGER GRANT TYPES ALTER_USER CREATE_TYPE INSERT UPDATE APPLY CREATE_USER INSERT_JSON USE ASCII DATE INT UUID BATCH DELETE JSON BEGIN DROP_AGGREGATE KEYWORDS BLOB DROP_COLUMNFAMILY LIST_PERMISSIONS BOOLEAN DROP_FUNCTION LIST_ROLES COUNTER DROP_INDEX LIST_USERS CREATE_AGGREGATE DROP_KEYSPACE PERMISSIONS CREATE_COLUMNFAMILY DROP_MATERIALIZED_VIEW REVOKE CREATE_FUNCTION DROP_ROLE SELECT CREATE_INDEX DROP_TABLE SELECT_JSON cqlsh>參考資料
連接:http://cassandra.apache.org/doc/latest/ ---官方文檔
鏈接:http://jingyan.baidu.com/article/7e440953ec8a7e2fc0e2ef9b.html ---優(yōu)點
鏈接:https://www.zhihu.com/question/19592244/answer/21430967 ---缺點
連接:http://yikebocai.com/2014/06/cassandra-principle/ ---原理
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享題目:開源Nosql數(shù)據(jù)庫Cassandra3.0實戰(zhàn)-集群部署與插件使用-創(chuàng)新互聯(lián)
本文鏈接:http://bm7419.com/article42/dssdec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、網(wǎng)站設(shè)計、動態(tài)網(wǎng)站、ChatGPT、App設(shè)計、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容