Akka-CQRS(2)- 安装部署cassandra cluster,ubuntu-16.04.1-LTS and MacOS mojave
对于akka-cluster这样的分布式软件系统来说,选择配套的数据库类型也是比较讲究的,最好也是分布式的,如cassandra,能保证良好的HA特性。前面的例子里示范akka-persistence时已经使用了cassandra作为journal和snapshot-store。一直以来基本上都在一部macbookpro上开发、测试akka-cluster相关软件。这次在腾讯云上租了两台8G,50G的服务器,安装了ubuntu 16.04.1 LTS操作系统,想着可以在一个真正的环境下试试cassandra cluster的安装部署和实际使用。先是试着在ubuntu上安装部署:
在ubuntu上安装cassandra,跟着下面的步骤做:
echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.listcurl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add - sudo apt-get updatesudo apt-get install cassandra
cassandra 安装过程新增了一个默认的cassandra组和用户,需要把我的username加到cassandra组里:
sudo usermod -a -G cassandra myuser
我安装的是cassandra v3.11.3版本,所以用了debian 311x main来注明。安装完毕后可以用status看看cassandra是不是已经启动,start,stop cassandra可以用下面的命令:
sudo service cassandra status //检查运行状态 sudo service cassandra start //启动cassandra sudo service cassandra stop //停止cassandra
现在我们可以用 sudo service cassandra start 启动cassandra
然后开启cqlsh, 输入:
use system;
describe table local
注意显示的system.local表列名:
CREATE TABLE system.local (key text PRIMARY KEY,bootstrapped text,broadcast_address inet,cluster_name text,cql_version text,data_center text,gossip_generation int,host_id uuid,listen_address inet,native_protocol_version text,partitioner text,rack text,release_version text,rpc_address inet,schema_version uuid,thrift_version text,tokens set<text>,truncated_at map<uuid, blob> ...
列名里包括了配置文件cassandra.yaml中的许多配置如cluster_name,listen_address,rpc_address等。在安装cassandra时已经存放了cassandra.yaml的初始值。所以必须记住如果修改cassandra.yaml里涉及这些配置后必须把所有system表删掉让cassandra自己根据新的.yaml文件配置重新创建这些system表。
我尝试建一个两个节点node的cluster:
配置cluster:
server1 172.27.0.8 server2 172.27.0.7
用server1做seednode。配置cluster需要修改cassandra.yaml文件,具体路径如下:
sudo nano /etc/cassandra/cassandra.yaml
需要修改文件里的配置参数:
cluster_name : 统一集群名称 seed_provider : seed节点地址清单(以,号分割) listen_address : 集群节点之间使用gossip协议通讯地址 rpc_address : 客户端连接地址 endpoint_snitch : 节点所属数据中心、机架
在修改cassandra.yaml文件之前先停了cassandra: sudo service cassandra stop
下面是server1的设置:
cluster_name: 'TestPOS Cluster' listen_address: 172.27.0.8 rpc_address: 172.27.0.8 - seeds: 172.27.0.8 endpoint_snitch: SimpleSnitch
切记!!!修改完毕在启动cassandra之前必须首先删除cassandra的系统数据表system*:
sudo rm -rf /var/lib/cassandra/data/system/*
然后启动cassandra: sudo service cassandra start
好了,现在可以用nodetool命令来检查这个节点的启动状态:sudo nodetool status
结果显示server1已经成功启动了。
下面开始配置server2:
在修改cassandra.yaml文件之前先停了cassandra: sudo service cassandra stop
cluster_name: 'TestPOS Cluster' listen_address: 172.27.0.7 rpc_address: 172.27.0.7 - seeds: 172.27.0.8 endpoint_snitch: SimpleSnitch
删除cassandra的系统数据表system*:
sudo rm -rf /var/lib/cassandra/data/system/*
然后启动: sudo service cassandra start
现在可以用nodetool命令来检查这个集群中所有节点的启动状态:sudo nodetool status
很遗憾,只能看到server2一个节点。
这种现象说明server1,server2之间没有沟通。它们应该是通过各自的7000端口交流的,估计是租赁的虚拟服务器没有开启这个端口。在server1上用 nc -vc 172.27.0.7 7000 得到证实。尝试用iptables, ufw等防火墙指令都无法解决问题,看来要留给网络管理部门了。
做了些调研,下面是cassandra需要使用的端口说明:
7199 JMX monitoring port 1024 - 65355 Random port required by JMX. Starting with Java 7u4 a specific port can be specified using the com.sun.management.jmxremote.rmi.port property. 7000 Inter-node cluster 7001 SSL inter-node cluster 9042 CQL Native Transport Port 9160 Thrift
另外,如果需要完整卸载cassandra, 可以用 : sudo apt-get purge cassandra
。。。
再试试用两部macbookpro来构建一个2-node-cluster:
手头刚好有两部macbookpro,可以试试在mac上安装部署cassandra cluster。
用homebrew下载和安装cassandra 特别容易:
brew update brew install cassandra
brew info cassandra可以获取cassandra安装情况如版本等
直接用 nodetool status来检查cassandra是否已经启动
start,stop命令如下:
brew services start cassandra brew services stop cassandra或者launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist
两部macbookpro IP地址: 用mac1当作seednode
mac1 192.168.1.30 mac2 192.168.1.24
下面是brew安装后cassandra的一些重要文件路径:
- Properties:
/usr/local/etc/cassandra
- Logs:
/usr/local/var/log/cassandra
- Data:
/usr/local/var/lib/cassandra/data
配置mac1:
brew services stop cassandra
sudo nano /usr/local/etc/cassandra/cassandra.yaml
cluster_name: 'TestPOS Cluster' listen_address: 192.168.1.30 rpc_address: 192.168.1.30 - seeds: 192.168.1.30 endpoint_snitch: SimpleSnitch
同样,谨记要清除system表: sudo rm -rf /usr/local/var/lib/cassandra/data/system*
brew services start cassandra
nodetool status 显示节点mac1已经启动
配置mac2:
brew services stop cassandra
sudo nano /usr/local/etc/cassandra/cassandra.yaml
cluster_name: 'TestPOS Cluster' listen_address: 192.168.1.24 rpc_address: 192.168.1.24 - seeds: 192.168.1.30 endpoint_snitch: SimpleSnitch
同样,谨记要清除system表: sudo rm -rf /usr/local/var/lib/cassandra/data/system*
brew services start cassandra
用: nc -vc 192.168.1.30 7000 检查mac1的7000端口,果然是开启的
nodetool status 显示mac1,mac2两个节点都已经启动了
当前的endpoint_snitch使用了SimpleSnitch。但在生产环节里需要配置:
endpoint_snitch: GossipingPropertyFileSnitch
然后在/usr/local/etc/cassandra/cassandra-rackdc.properties 文件里定义本节点的物理位置(数据中心,机架)
最后还要删除/usr/local/etc/cassandra/cassandra-topology.properties 文件
转载于:https://www.cnblogs.com/tiger-xc/p/10362389.html
Akka-CQRS(2)- 安装部署cassandra cluster,ubuntu-16.04.1-LTS and MacOS mojave相关推荐
- 在Ubuntu 16.04.6 LTS上安装python3.7和pip3后出现Command '('lsb_release', '-a')' 出错问题的解决方法
在Ubuntu 16.04.6 LTS上安装python3.7和pip3后出现Command '('lsb_release', '-a')' returned non-zero exit status ...
- 安装Hadoop及Spark(Ubuntu 16.04)
安装Hadoop及Spark(Ubuntu 16.04) 安装JDK 下载jdk(以jdk-8u91-linux-x64.tar.gz为例) 新建文件夹 sudo mkdir /usr/lib/jvm ...
- 在Ubuntu 16.04.3 LTS 和 Windows 下安装 Go 环境
Ubuntu 16.04.3 LTS 环境 1.安装 sudo apt-get install golang-go 目前go的最新版本是1.9.2,但是在Ubuntu 16.04上采用预编译好的包安装 ...
- 在Ubuntu 16.04.6 LTS上升级python 3.5到3.7.3实录
缘由 我想安装一个python模块you-get,发现只能使用pip3安装,但是我发现我的Ubuntu 16.04.6 LTS上有python3.5,但是没有pip3,也无法成功安装,真是要了我的老命 ...
- 在Ubuntu 16.04.6 LTS上升级Go到最新版1.12.5实录
上一次我在Ubuntu 16.04.3 LTS上从源码安装了Go,当时最新的版本是1.10,参见我之前的博文 https://blog.csdn.net/tao_627/article/details ...
- 在Ubuntu 16.04.5 LTS上升级python的pip版本实录
在ubuntu 16.04.5 LTS上使用Python安装模块时,比较顺手的方法是使用pip命令.这次,我在安装一个模块时,老是提示下面的问题,比较不爽.所以,我就照着提示做了一遍,记录下来,以作备 ...
- 在Ubuntu 16.04.3 LTS上运行go+https+json示例
下面是我依据网上资料的实操过程,记录以作备忘.该示例给出了https通信并处理json文件的例子. 平台:Ubuntu 16.04.3 LTS go版本:1.10 1.生成自签名的服务器端的私钥KEY ...
- 在Ubuntu 16.04.3 LTS上玩转quic-go项目
说明 quic-go是使用Go来重写chromium中的QUIC协议,将来计划过渡到IETF版本的QUIC协议. 目前该协议还处于不断更新和活跃之中,目前IETF版本的QUIC协议草案版本号已经到dr ...
- 在Ubuntu 16.04.1 LTS上测试Linux AIO功能实录
我们知道nginx中有libaio这项功能,为了研究AIO的一些常用接口用法,在网上找到一个例子,异步IO读取本地文件,亲自实践了一把,记录如下: 安装依赖库 在Ubuntu 16.04上需要事先安装 ...
最新文章
- java 写文件的三种方法比较
- Dirichlet分布与多项分布的共轭性
- python多进程编程 多个函数并发执行_python并发编程之多进程编程
- 最大距离(二分 栈 思维)
- 2021牛客暑期多校训练营1 A.Alice and Bob 博弈 SG函数
- Pytorch:矩阵乘法总结
- 吸烟增加后代患哮喘的风险
- [转]如何使用BackTrack破解WIFI无线网络的WEP密钥
- android点击按钮修改文本,如何在android中每3秒动态更改按钮文本?
- Openssl建立CA系统
- 交换机端口镜像配置大全【汇集 22个各种品牌交换机】
- mac android apk反编译
- 七、基于机器学习方法对销售预测的研究
- BZOJ 2037: [Sdoi2008]Sue的小球(DP)
- 一篇走心的文章和一个不起眼的引流方法
- . java.lang.IllegalArgumentException: requirement failed: Can only call getServletHandlers on a runn
- Python采集网易云音乐
- 【转】《背包九讲》--崔添翼大神
- Google map地图限制显示区域、拖拽范围
- 网站服务器选择什么操作系统,网站服务器选择哪种操作系统比较好