cassandra什么鬼

https://cassandra.apache.org/download/
Download the latest Apache Cassandra 3.11 release: 3.11.6 (pgp, sha256 and sha512), released on 2020-02-14.

解压进入
D:\Tools\apache-cassandra-3.11.6\bin

WARNING! Powershell script execution unavailable.
   Please use 'powershell Set-ExecutionPolicy Unrestricted'
   on this user-account to run cassandra with fully featured
   functionality on this platform.
Starting with legacy startup options
JAVA_HOME environment variable must be set!

管理员运行:powershell Set-ExecutionPolicy Unrestricted

nodetool status

The JAVA_HOME environment variable must be set to run this program!

我的电脑->属性->高级系统设置->高级->环境变量->系统变量->新建-> JAVA_HOME

Datacenter: datacenter1

Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 70.09 KiB 256 100.0% 582fdf24-60ec-4c73-8ac6-82a06612a3d7 rack1

DOS 窗口中文乱码的问题,打开新的窗口,输入:chcp 65001,即可设为 UTF-8 编码

cqlsh

Can't detect Python version!

except ImportError, e: cqlsh.py

cassandra不支持python3环境,需要单独安装python2.7,并在bin\cqlsh.bat文件中设置path变量
https://www.python.org/downloads/release/python-2714/

WARNING: console codepage must be set to cp65001 to support utf-8 encoding on Windows platforms.
If you experience encoding problems, change your console codepage with 'chcp 65001' before starting cqlsh.

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.6 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
WARNING: pyreadline dependency missing.  Install to enable tab completion.

参考文献:
https://www.jianshu.com/p/cd24ad207354
https://blog.csdn.net/MrsHorse/article/details/82695353
https://www.it610.com/article/5866481.htm

apt install -y openjdk-8-jdk
apt install wget
wget http://mirrors.tuna.tsinghua.edu.cn/apache/cassandra/3.11.6/apache-cassandra-3.11.6-bin.tar.gz
tar -xvf apache-cassandra-3.11.6-bin.tar.gz
cd apache-cassandra-3.11.6/conf/
apt install vim
vi cassandra.yaml
更改
cluster_name
seeds
listen_address
rpc_address

cd ../..
groupadd cassandra
useradd -g cassandra cassandra
chown -R cassandra:cassandra apache-cassandra-3.11.6/
mv apache-cassandra-3.11.6 /opt/apache-cassandra

su cassandra
cd /opt/apache-cassandra
./bin/cassandra

./bin/nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 70.05 KiB 256 100.0% 344fbfe7-3ca5-4138-b25a-be506dcbfbaa rack1

Datacenter: datacenter1

Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.1.180 69.89 KiB 256 64.3% 7b663680-2f34-41c3-9d6a-2a4c302dc5ac rack1
UN 192.168.1.229 69.93 KiB 256 63.7% c8d61e37-d49b-4f40-bd6f-d391e80f0b53 rack1
UN 192.168.1.247 69.95 KiB 256 72.0% 112ceca1-d456-4cd9-9984-dee6239930e1 rack1

./bin/cqlsh
No appropriate python interpreter found.
apt install python2.7
https://www.w3cschool.cn/cassandra/cassandra_shell_commands.html
CAPTURE '/home/CassandraOutput' # 不显示输出
select * from emp;
https://www.it610.com/article/5866481.htm
describe keyspaces;
CREATE KEYSPACE IF NOT EXISTS myCas WITH REPLICATION = {'class': 'SimpleStrategy','replication_factor':1};
describe keyspaces;
use mycas;
CREATE TABLE user ( id int, user_name varchar, PRIMARY KEY (id) );
describe tables;
INSERT INTO user (id,user_name) VALUES (1,'zhangsan');
select * from user;
select * from user where id=1;

create index on user(user_name);
select * from user where user_name='zhangsan';

update users set user_name='lisi' where id=1;
delete from users where id=1;

capture off; # 显示输出
describe cluster;
select * from user;
show host;
show version;

备注
cqlsh远程连接非本地节点 Last error: Connection refused
https://www.e-learn.cn/index.php/content/wangluowenzhang/164659

You need to edit cassandra.yaml on the node you are trying to connect to and set the node ip address for rpc_address and listen_address and restart Cassandra.
rpc_address is the address on which Cassandra listens to the client calls.
listen_address is the address on which Cassandra listens to the other Cassandra nodes.

标签: none

添加新评论