日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

NOSQL 之 cassadra 安装与集群配置

發布時間:2024/4/15 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NOSQL 之 cassadra 安装与集群配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

cassadra 安裝


1.下載:

apache-cassandra-2.0.6-bin.tar.gz

jdk-8-linux-x64.rpm


2.先更新jdk

?? ?rpm -ivh jdk-8-linux-x64.rpm

?? ?修改java ,指定到最新版本


?? ?rm /usr/bin/java? java.bak
?? ?ln -s /usr/java/jdk1.8.0/bin/java java

?? ?[root@localhost bin]# java -version
?? ?java version "1.8.0"
?? ?Java(TM) SE Runtime Environment (build 1.8.0-b132)
?? ?Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)



3.安裝cassandra



[root@localhost backup]# tar zxvf? apache-cassandra-2.0.6-bin.tar.gz

[root@localhost backup]# cd apache-cassandra-2.0.6/bin

root@localhost bin]# ll cassandra
-rwxr-xr-x 1 mongo mongo 7108 3月?? 7 20:34 cassandra
[root@localhost bin]# ./cassndra
-bash: ./cassndra: 沒有那個文件或目錄
[root@localhost bin]# ./cassandra
[root@localhost bin]#? INFO 17:59:33,186 Logging initialized
?INFO 17:59:33,369 Loading settings from file:/opt/backup/apache-cassandra-2.0.6/conf/cassandra.yaml
ps INFO 17:59:34,440 Data files directories: [/var/lib/cassandra/data]
?INFO 17:59:34,443 Commit log directory: /var/lib/cassandra/commitlog
?INFO 17:59:34,444 DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap






Cassandra集群 實施方案:


兩個節點:192.168.10.104
?? ?? 192.168.10.206


相關的JAVA,cassandra 安裝不再累述。兩節點的配置安裝和上面的是一樣的。
下面來做相關配置文件的修改:



節點1:
?? ? ?
?? ?192.168.10.104


?? ?vi /opt/apache-cassandra-2.0.6/conf/cassandra.yaml

?? ?修改內容如下:

?? ?cluster_name: 'Cluster1'

?? ? - seeds: "192.168.10.104"

?? ?listen_address: 192.168.10.104




節點2:
?? ? ?
?? ?192.168.10.206


?? ?vi /opt/apache-cassandra-2.0.6/conf/cassandra.yaml

?? ?修改內容如下:

?? ?cluster_name: 'Cluster1'

?? ? - seeds: "192.168.10.104"

?? ?listen_address: 192.168.10.206



啟動


節點1:

[root@localhost bin]# ./cassandra -f
?INFO 21:30:13,864 Logging initialized
?INFO 21:30:13,907 Loading settings from file:/opt/backup/apache-cassandra-2.0.6/conf/cassandra.yaml
?INFO 21:30:14,202 Data files directories: [/var/lib/cassandra/data]
?INFO 21:30:14,203 Commit log directory: /var/lib/cassandra/commitlog
?INFO 21:30:14,203 DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap
?INFO 21:30:14,203 disk_failure_policy is stop
?INFO 21:30:14,203 commit_failure_policy is stop
?INFO 21:30:14,207 Global memtable threshold is enabled at 1996MB
?INFO 21:30:14,282 Not using multi-threaded compaction
?INFO 21:30:14,420 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.8.0
?INFO 21:30:14,420 Heap size: 8375238656/8375238656

...................

INFO 22:14:41,166 Compacted 4 sstables to [/var/lib/cassandra/data/system/local/system-local-jb-25,].? 6,206 bytes to 5,671 (~91% of original) in 26ms = 0.208011MB/s.? 4 total partitions merged to 1.? Partition merge counts were {4:1, }
?INFO 22:14:41,197 Node /192.168.10.104 state jump to normal
?INFO 22:14:41,209 Waiting for gossip to settle before accepting client requests...
?INFO 22:14:49,210 No gossip backlog; proceeding
?INFO 22:14:49,351 Starting listening for CQL clients on /192.168.10.104:9042...
?INFO 22:14:49,406 Using TFramedTransport with a max frame size of 15728640 bytes.
?INFO 22:14:49,408 Binding thrift service to /192.168.10.104:9160
?INFO 22:14:49,418 Using synchronous/threadpool thrift server on 192.168.10.104 : 9160
?INFO 22:14:49,419 Listening for thrift clients...
?INFO 22:15:44,802 Handshaking version with /192.168.10.206
?INFO 22:15:45,914 Node /192.168.10.206 is now part of the cluster
?INFO 22:15:45,924 Handshaking version with /192.168.10.206
?INFO 22:15:45,930 InetAddress /192.168.10.206 is now UP

節點2:

[root@localhost bin]# ./cassandra -f
?INFO 22:18:50,672 Logging initialized
?INFO 22:18:50,742 Loading settings from file:/opt/backup/apache-cassandra-2.0.6/conf/cassandra.yaml
?INFO 22:18:51,194 Data files directories: [/var/lib/cassandra/data]
?INFO 22:18:51,196 Commit log directory: /var/lib/cassandra/commitlog
?INFO 22:18:51,196 DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap
?INFO 22:18:51,196 disk_failure_policy is stop
?INFO 22:18:51,197 commit_failure_policy is stop
?INFO 22:18:51,203 Global memtable threshold is enabled at 253MB
?INFO 22:18:51,339 Not using multi-threaded compaction
?INFO 22:18:51,651 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.8.0
?INFO 22:18:51,652 Heap size: 1063256064/1063256064
...................


INFO 22:19:05,145 Starting listening for CQL clients on /192.168.10.206:9042...
?INFO 22:19:05,267 Using TFramedTransport with a max frame size of 15728640 bytes.
?INFO 22:19:05,271 Binding thrift service to /192.168.10.206:9160
?INFO 22:19:05,320 Using synchronous/threadpool thrift server on 192.168.10.206 : 9160
?INFO 22:19:05,322 Listening for thrift clients...
?INFO 22:20:12,302 Handshaking version with /192.168.10.104
?INFO 22:20:12,345 Node /192.168.10.104 is now part of the cluster
?INFO 22:20:12,422 Handshaking version with /192.168.10.104
?INFO 22:20:12,436 InetAddress /192.168.10.104 is now UP


經檢查,發現防火墻開著,兩節點一直無法連接上。在修改防火墻后,終于成功解決問題。
查看集群狀態如下:

?[root@localhost bin]# ./nodetool -h 192.168.10.206 ring

Datacenter: datacenter1
==========
Address???????? Rack??????? Status State?? Load??????????? Owns??????????????? Token????????????????????????????????????? ?
?????????????????????????????????????????????????????????????????????????????? 9219864279989867836??????????????????????? ?
192.168.10.104? rack1?????? Up???? Normal? 61.04 KB??????? 100.00%???????????? -9209067550672142833?????????????????????? ?
.............................?????????????????? ?
192.168.10.104? rack1?????? Up???? Normal? 61.04 KB??????? 100.00%???????????? 9119365032104954381??????????????????????? ?
192.168.10.104? rack1?????? Up???? Normal? 61.04 KB??????? 100.00%???????????? 9144131727983125656??????????????????????? ?
192.168.10.104? rack1?????? Up???? Normal? 61.04 KB??????? 100.00%???????????? 9194205234863680199??????????????????????? ?
192.168.10.104? rack1?????? Up???? Normal? 61.04 KB??????? 100.00%???????????? 9205150584807094387??????????????????????? ?
192.168.10.206? rack1?????? Up???? Normal? 64.28 KB??????? 100.00%???????????? -9093153247508407374?????????????????????? ?
192.168.10.206? rack1?????? Up???? Normal? 64.28 KB??????? 100.00%???????????? -8959856259961417723?????????????????????? ?
192.168.10.206? rack1?????? Up???? Normal? 64.28 KB??????? 100.00%???????????? -8933270068536399704???????????????? ?
........................

? Warning: "nodetool ring" is used to output all the tokens of a node.
? To view status related info of a node use "nodetool status" instead.





測試:

1.在 206 節點創建 keyspace,并插入數據:


[root@localhost bin]# ./cassandra-cli -host 192.168.10.206
Connected to: "Cluster1" on 192.168.10.206/9160
Welcome to Cassandra CLI version 2.0.6

The CLI is deprecated and will be removed in Cassandra 3.0.? Consider migrating to cqlsh.
CQL is fully backwards compatible with Thrift data; see http://www.datastax.com/dev/blog/thrift-to-cql3

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.

[default@unknown] create keyspace testspace
...?? ?;
6ceaabf9-afde-3d03-ae18-21da5c18f58b

[default@unknown] use testspace;
Authenticated to keyspace: testspace


[default@testspace] create column family testcf
...?? ?? with column_type = 'Standard'
...?? ?? and comparator = 'UTF8Type'
...?? ?? and default_validation_class = 'UTF8Type'
...?? ?? and key_validation_class = 'UTF8Type'
...?? ?? and read_repair_chance = 0.1
...?? ?? and dclocal_read_repair_chance = 0.0
...?? ?? and populate_io_cache_on_flush = false
...?? ?? and gc_grace = 864000
...?? ?? and min_compaction_threshold = 4
...?? ?? and max_compaction_threshold = 32
...?? ?? and replicate_on_write = true
...?? ?? and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
...?? ?? and caching = 'KEYS_ONLY'
...?? ?? and default_time_to_live = 0
...?? ?? and speculative_retry = 'NONE'
...?? ?? and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.LZ4Compressor'}
...?? ?? and index_interval = 128;
273dc95f-512c-336f-b6e4-fb751560c4f2
[default@testspace] set testcf['num']['num1']=1111;
Value inserted.
Elapsed time: 91 msec(s).
[default@testspace]


2.在節點2查看數據:

[root@localhost bin]# ./cassandra-cli -h 192.168.10.104
Connected to: "Cluster1" on 192.168.10.104/9160
Welcome to Cassandra CLI version 2.0.6

The CLI is deprecated and will be removed in Cassandra 3.0.? Consider migrating to cqlsh.
CQL is fully backwards compatible with Thrift data; see http://www.datastax.com/dev/blog/thrift-to-cql3

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.

[default@unknown] use testspace;
Authenticated to keyspace: testspace
[default@testspace] list testcf;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: num
=> (name=num1, value=1111, timestamp=1397399586622000)

1 Row Returned.
Elapsed time: 421 msec(s).
[default@testspace]

可以看到,數據已同步過來了。

總結

以上是生活随笔為你收集整理的NOSQL 之 cassadra 安装与集群配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。