美文网首页数据库
安装 Cassandra

安装 Cassandra

作者: ___n | 来源:发表于2018-01-15 10:56 被阅读28次

    Download JDK 1.8.0.40

    cd /opt/

    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-x64.tar.gz"

    tar xzf jdk-8u40-linux-x64.tar.gz

    cd /opt/jdk1.8.0_40/

    alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 2

    alternatives --config java

    There are 3 programs which provide 'java'.
      Selection    Command
    -----------------------------------------------
    *  1           /opt/jdk1.8.0/bin/java
     + 2           /opt/jdk1.8.0_25/bin/java
       3           /opt/jdk1.8.0_40/bin/java
    Enter to keep the current selection[+], or type selection number: 3
    

    alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_40/bin/jar 2

    alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_40/bin/javac 2

    alternatives --set jar /opt/jdk1.8.0_40/bin/jar

    alternatives --set javac /opt/jdk1.8.0_40/bin/javac

    java -version

    java version "1.8.0_40"
    Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
    Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
    

    vi /etc/yum.repos.d/datastax.repo

    [datastax]
    name = DataStax Repo for Apache Cassandra
    baseurl = http://rpm.datastax.com/community
    enabled = 1
    gpgcheck = 0
    

    export JAVA_HOME=/usr/java/jre1.8.0_40/

    export PATH=$PATH:/usr/java/jre1.8.0_40/bin/

    yum install dsc22 cassandra22 libev-devel jna

    pip install cassandra-driver

    cp -r /usr/lib/python2.7/site-packages/cqlshlib/ /usr/local/lib/python2.7/site-packages/.

    service cassandra start

    Create Database

    Login to DB

    cqlsh ip.ip.ip.ip port

    CREATE KEYSPACE db_name WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };

    Create Table

    CREATE TABLE products_sinbad (
              id uuid PRIMARY KEY,
              product_id bigint,
              title text,
              description text,
              url text,
              listing_price int,
              price int,
              price_adult int,
              price_child int,
            price_type varchar,
            tripdays int,
            start_city text,
            destination_city text,
            package_type varchar,
            package_includes text,
            package_excludes text,
            visa_terms text,
            order_terms text,
            trip_alerts text,
            images text);
    

    相关文章

      网友评论

        本文标题:安装 Cassandra

        本文链接:https://www.haomeiwen.com/subject/loyroxtx.html