用户登录
用户注册

分享至

centos cassandra 3.7

  • 作者: 爱如凉水
  • 来源: 51数据库
  • 2020-09-30
首先要安装好java,并配置好java环境。现在通过创建一个新的存储库文件将Apache Cassandra存储库添加到您的存储库列表中。
nano /etc/yum.repos.d/cassandra.repo
现在将以下内容添加到文件中。
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/RedHat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
您现在可以通过运行以下命令安装Apache Cassandra。
yum -y install cassandra
通过运行以下命令重新加载系统守护程序:
systemctl daemon-reload
你现在可以通过键入来启动Cassandra
systemctl start cassandra
要启用Cassandra在启动时自动启动,请运行:
systemctl enable cassandra
您可以通过键入以下命令来验证Cassandra是否正在运行。
nodetool status
如果Cassandra正在运行,您应该看到类似的输出。
[root@ip-172-31-7-136 ~]# 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 ?136.29 KiB ?256 ? ? ? ? ?100.0% ? ? ? ? ? ?b3d26649-9e10-4bee-9b3c-8e81c4394b2e ?rack1
如果不是显示上面的输出,而是得到类似于以下输出的内容,那么您将需要配置cassandra环境配置文件。
nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
使用以下命令打开配置文件。
nano /etc/cassandra/default.conf/cassandra-env.sh
现在在配置中找到以下一行。
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
取消注释行并将其值形式<public_name>更改为localhost IP地址127.0.0.1。
配置应如下所示。
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"
保存文件并从编辑器退出,通过运行以下命令重新启动Apache Cassandra。
systemctl restart cassandra
运行nodetool命令时应该具有所需的输出。
Cassandra带有一个强大的命令行shell cqlsh来在Cluster上运行查询。 查询是用CQL或Cassandra Query语言编写的。 要访问CQL shell,请运行以下命令。
cqlsh
您将看到以下输出。
[root@www.linuxidc.com ~]# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.0 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
软件
前端设计
程序设计
Java相关