{"id":266604,"date":"2023-03-08T06:05:52","date_gmt":"2023-03-07T22:05:52","guid":{"rendered":"https:\/\/gulass.cn\/lqdcqdcjqzys.html"},"modified":"2023-03-08T06:05:52","modified_gmt":"2023-03-07T22:05:52","slug":"lqdcqdcjqzys","status":"publish","type":"post","link":"https:\/\/gulass.cn\/lqdcqdcjqzys.html","title":{"rendered":"linux \u542f\u52a8cassandra Linux\u542f\u52a8Cassandra\uff1a\u6280\u5de7\u3001\u6ce8\u610f\u4e8b\u9879\u4e0e\u5b9e\u7528\u5efa\u8bae"},"content":{"rendered":"

Cassandra\u662f\u4e00\u4e2a\u9ad8\u5ea6\u53ef\u6269\u5c55\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93linux\u4f0a\u7538\u56ed\uff0c\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406\u3002\u5728Linux<\/a>\u7cfb\u7edf<\/a>\u4e2d\u542f\u52a8Cassandra\u9700\u8981\u4e00\u4e9b\u6280\u5de7\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u4e0b\u542f\u52a8Cassandra\u3002<\/p>\n

1.\u5b89\u88c5Java\u73af\u5883<\/p>\n

\u5728\u5b89\u88c5Cassandra\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b89\u88c5Java\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4<\/a>\u5b89\u88c5OpenJDK\uff1a<\/p>\n

```<\/p>\n

sudo apt-get install openjdk-8-jdk<\/p>\n

```<\/p>\n

2.\u4e0b\u8f7d\u5e76\u89e3\u538b\u7f29Cassandra<\/p>\n

\u5728\u5b98\u7f51\uff08\uff09\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Cassandralinux \u542f\u52a8cassandra<\/strong>\uff0c\u5e76\u89e3\u538b\u7f29\u5230\u6307\u5b9a\u76ee\u5f55\uff1a<\/p>\n

```<\/p>\n

tar -xvzf apache-cassandra-x.x.x-bin.tar.gz<\/p>\n

```<\/p>\n

3.\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n

\u8fdb\u5165\u89e3\u538b\u540e\u7684Cassandra\u76ee\u5f55\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6cassandra.yaml\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8be5\u6587\u4ef6\u5305\u542b\u8bb8\u591a\u91cd\u8981\u7684\u914d\u7f6e\u9009\u9879\uff0c\u5982\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\u3001\u5907\u4efd\u7b56\u7565\u3001\u7f51\u7edc\u8bbe\u7f6e\u7b49\u3002<\/p>\n

```<\/p>\n

cluster_name:'Test Cluster'<\/p>\n

num_tokens: 256<\/p>\n

seed_provider:<\/p>\n

- class_name: org.apache.cassandra.locator.SimpleSeedProvider<\/p>\n

parameters:<\/p>\n

- seeds:\"127.0.0.1\"<\/p>\n

listen_address: localhost<\/p>\n

rpc_address: localhost<\/p>\n

endpoint_snitch: GossipingPropertyFileSnitch<\/p>\n

```<\/p>\n

4.\u542f\u52a8Cassandra<\/p>\n

\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Cassandra\uff1a<\/p>\n

```<\/p>\n

bin\/cassandra -f<\/p>\n

```<\/p>\n

-f\u53c2\u6570\u8868\u793a\u4ee5\u524d\u53f0\u6a21\u5f0f\u8fd0\u884c\uff0c\u5373\u8f93\u51fa\u65e5\u5fd7\u5230\u63a7\u5236\u53f0\u3002\u5982\u679c\u8981\u4ee5\u540e\u53f0\u6a21\u5f0f\u8fd0\u884c\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

```<\/p>\n

bin\/cassandra -p pidfile<\/p>\n

```<\/p>\n

\u5176\u4e2dpidfile\u662f\u4e00\u4e2a\u5305\u542b\u8fdb\u7a0bID\u7684\u6587\u4ef6\u540d\u3002<\/p>\n

5.\u4f7f\u7528cqlsh\u8fde\u63a5\u5230Cassandra<\/p>\n

cqlsh\u662f\u4e00\u4e2a\u57fa\u4e8eCQL\uff08Cassandra Query Language\uff09\u7684\u547d\u4ee4\u884c\u5de5\u5177linux \u542f\u52a8cassandra<\/strong>linux\u6559\u7a0b\uff0c\u53ef\u4ee5\u7528\u4e8e\u4e0eCassandra\u4ea4\u4e92\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230\u672c\u5730\u8fd0\u884c\u7684Cassandra\u5b9e\u4f8b\uff1a<\/p>\n

```<\/p>\n

bin\/cqlsh localhost<\/p>\n

```<\/p>\n

6.\u521b\u5efaKeyspace\u548cTable<\/p>\n

\u5728\u8fde\u63a5\u5230cqlsh\u540e\uff0c\u53ef\u4ee5\u521b\u5efaKeyspace\u548cTable\u3002\u4f8b\u5982\uff1a<\/p>\n

```<\/p>\n

CREATE KEYSPACE mykeyspace WITH replication ={'class':'SimpleStrategy','replication_factor':'3'};<\/p>\n

CREATE TABLE mytable (id int PRIMARY KEY, name text, age int);<\/p>\n

INSERT INTO mytable (id, name, age) VALUES (1,'Alice', 20);<\/p>\n

SELECT * FROM mytable;<\/p>\n

```<\/p>\n

7.\u5173\u95edCassandra<\/p>\n

\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5173\u95ed\u6b63\u5728\u8fd0\u884c\u7684Cassandra\u5b9e\u4f8b\uff1a<\/p>\n

```<\/p>\n

bin\/nodetool stopdaemon<\/p>\n

```<\/p>\n

8.\u603b\u7ed3<\/p>\n

\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Linux\u7cfb\u7edf\u4e2d\u542f\u52a8\u3001\u8fde\u63a5\u3001\u521b\u5efaKeyspace\u548cTable\u4ee5\u53ca\u5173\u95edCassandra\u5b9e\u4f8b\u7684\u65b9\u6cd5\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5e94\u8be5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u66f4\u52a0\u8be6\u7ec6\u548c\u590d\u6742\u7684\u914d\u7f6e\u548c\u7ba1\u7406\u3002<\/p>\n

\u201c\u6bcf\u4e2a\u4eba\u90fd\u6709\u4e24\u6761\u751f\u547d\u7ebf\u3002\u7b2c\u4e00\u6761\u65ad\u6389\u4e86\uff0c\u8fd8\u6709\u7b2c\u4e8c\u6761\uff1b\u4f46\u5927\u591a\u6570\u4eba\u90fd\u628a\u7b2c\u4e8c\u6761\u4e5f\u6d6a\u8d39\u6389\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Linux\u7cfb\u7edf\u4e2d\u542f\u52a8Cassandra\u9700\u8981\u4e00\u4e9b\u6280\u5de7\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5OpenJDK\uff1a\u5982\u679c\u8981\u4ee5\u540e\u53f0\u6a21\u5f0f\u8fd0\u884c\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230\u672c\u5730\u8fd0\u884c\u7684Cassandra\u5b9e\u4f8b\uff1a\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Linux\u7cfb\u7edf\u4e2d\u542f\u52a8\u3001\u8fde\u63a5\u3001\u521b\u5efaKeyspace\u548cTable\u4ee5\u53ca\u5173\u95edCassandra\u5b9e\u4f8b\u7684\u65b9\u6cd5\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5e94\u8be5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u66f4\u52a0\u8be6\u7ec6\u548c\u590d\u6742\u7684\u914d\u7f6e\u548c\u7ba1\u7406\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-266604","post","type-post","status-publish","format-standard","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/266604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=266604"}],"version-history":[{"count":0,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/266604\/revisions"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=266604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=266604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=266604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}