zoukankan      html  css  js  c++  java
  • CentOS7 cassandra安装与测试

    3节点分别安装(192.168.6.117,192.168.6.118,192.168.6.119)
    
    #下载
    http://mirrors.hust.edu.cn/apache/cassandra/3.11.7/apache-cassandra-3.11.7-bin.tar.gz
    
    tar -xvf apache-cassandra-3.11.7-bin.tar.gz -C /opt
    cd /opt/apache-cassandra-3.11.7/
    
    sed -i 's$#MAX_HEAP_SIZE="4G"$MAX_HEAP_SIZE="2G"$g' /opt/apache-cassandra-3.11.7/conf/cassandra-env.sh
    sed -i 's$#HEAP_NEWSIZE="800M"$HEAP_NEWSIZE="400M"$g' /opt/apache-cassandra-3.11.7/conf/cassandra-env.sh
    sed -i 's$Test Cluster$cx cluster$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml
    sed -i 's$start_rpc: false$start_rpc: true$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml
    
    #节点分配:192.168.6.117,192.168.6.118分配为seeds,三节点配置完全一样
    sed -i 's$seeds: "127.0.0.1"$seeds: "192.168.6.117,192.168.6.118"$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml
    
    #下面两步替换为当前节点ip
    sed -i 's$listen_address: localhost$listen_address: 192.168.6.117$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml
    sed -i 's$rpc_address: localhost$rpc_address: 192.168.6.117$g' /opt/apache-cassandra-3.11.7/conf/cassandra.yaml
    
    启动
    
    #先启动seeds节点(192.168.6.117,192.168.6.118)再启动非seeds节点
    /opt/apache-cassandra-3.11.7/bin/cassandra -R
    
    #查看集群状态
    /opt/apache-cassandra-3.11.7/bin/nodetool status
    如果集群中任意节点状态不是UN,则查看日志:
    tail -f  /opt/apache-cassandra-3.11.7/logs/system.log
    测试
    
    #连接到Cassandra
    /opt/apache-cassandra-3.11.7/bin/cqlsh 192.168.6.117
    
    Connected to cx cluster at 192.168.6.117:9042.
    [cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4]
    Use HELP for help.
    cqlsh> CREATE SCHEMA testdb WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 };
    cqlsh> use testdb;
    cqlsh:testdb> CREATE TABLE ack_message_status (messageId varchar PRIMARY KEY,totalNum int, unreadNum int, sendTime timestamp);
    cqlsh:testdb> 
    
    设置为开机启动
    
    cat >/usr/lib/systemd/system/cassandra.service <<"EOF"
    [Unit]  
    Description=Cassandra Server Service  
    After=network.service  
      
    [Service]
    Type=simple
    PIDFile=/var/run/cassandra.pid    
    ExecStart=/opt/apache-cassandra-3.11.7/bin/cassandra -R -f -p /var/run/cassandra.pid  
    StandardOutput=journal  
    StandardError=journal  
    LimitNOFILE=100000  
    LimitMEMLOCK=infinity  
    LimitNPROC=32768  
    LimitAS=infinity  
      
    [Install]  
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl enable cassandra
  • 相关阅读:
    AM335x kernel 4.4.12 i2c eeprom AT24c02驱动移植
    AM335x tscadc platform driver 相关代码跟踪
    Linux kernel make 常用选项介绍
    Linux kernel 文件夹说明
    shell 脚本之获取命令输出字符串以及函数参数传递
    Treeview控件如何获得子节点的所有父节点的名称
    浅谈Delphi高效使用TreeView
    Delphi下Treeview控件基于节点编号的访问
    delphi中TTreeView的使用方法
    学习 TTreeView [2]
  • 原文地址:https://www.cnblogs.com/xiaochangwei/p/cassandra-install.html
Copyright © 2011-2022 走看看