2016. 5. 12. 15:22

1. 다운로드

리눅스 및 맥, 윈도우즈등 다양한 플랫폼을 지원한다.

http://www.planetcassandra.org/cassandra/


2. 설치

윈도우환경에서 개발할 것이므로 윈도우 MSI installer를 다운로드받고 설치를 한다. 설치 과정은 특별히 선택할게 없었다.

설치 후 윈도우 메뉴에서 아래의 이미지처럼 설치 결과를 확인할 수 있다.

3. 실행 및 데이터베이스 생성

Cassandra CQL Shell을 실행하면 카산드라 콘솔이 생성되며 아래의 스크립트를 추가해본다. 

(본 블로거도 카산드라 초보이므로 카산드라 웹사이트에서 참고하여 대충 만들었다.)

CREATE KEYSPACE demo
  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

CREATE TABLE demo.users (
  lastname text PRIMARY KEY,
  age int,
  city text,
  email text,
  firstname text
);

DROP TABLE demo.users;

4. C# 프로젝트

Nu-Get을 통하여 driver를 설치

Install-Package CassandraCSharpDriver
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cassandra;

namespace CassandraSample
{
    class Program
    {
        static void Main(string[] args)
        {
            Cluster cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
            ISession session = cluster.Connect("demo");

            session.Execute("insert into users (lastname, age, city, email, firstname) values ('Jones', 35, 'Austin', 'bob@example.com', 'Bob')");

            Row result = session.Execute("select * from users where lastname = 'Jones'").First();
            Console.WriteLine("{0} {1}", result["firstname"], result["age"]);
            Console.ReadLine();

            session.Execute("update users set age = 36 where lastname = 'Jones'");
            Row result2 = session.Execute("select * from users where lastname = 'Jones'").First();
            Console.WriteLine("{0} {1}", result2["firstname"], result2["age"]);
            Console.ReadLine();

            session.Execute("delete from users where lastname = 'Jones'");
            RowSet rows = session.Execute("select * from users");
            foreach (Row row in rows)
                Console.WriteLine("{0} {1}", result2["firstname"], result2["age"]);

            Console.ReadLine();
        }
    }
}

5. 결론

그냥 실행만 해보는 수준이다 보니 카산드라가 다른 NoSQL이나 MSSQL과 같은 DB에서 지원하는 기능을 얼마나 지원해주고 더 나은 부분을 확인은 할 수 없었다. 다만, 위에 보는 거와 같이 쉽게 연동이 가능해 보이며 ANSI SQL을 지원하기에 이미 MSSQL, ORACLE, MYSQL의 DB를 사용해본 사람이라면 쉽게 접근할 수 있지 않을까 싶다.


Reference: https://academy.datastax.com/resources/getting-started-apache-cassandra-and-c-net

Posted by CoolDragon
2013. 7. 29. 17:58

아래와 같은 오류가 발생하면 

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

아래와 같은 명령어로 해결한다.

redis 127.0.0.1:6379> config set stop-writes-on-bgsave-error no



출처 : https://github.com/antirez/redis/issues/584

Posted by CoolDragon
2013. 7. 15. 13:35

####################

# 방화벽 포트 등록 #

####################

$ vi /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT (6379 포트 항목 추가)

$ /etc/init.d/iptables restart (방화벽 포트 설정 재시작)


####################

# GCC 설치         #

####################

# yum groupinstall 'Development Tools'


####################

# Redis 설치       #

####################

$ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz

$ tar xzf redis-2.6.14.tar.gz

$ cd redis-2.6.14

$ make && make install


$ src/redis-server


$ src/redis-cli

redis> set foo bar

OK

redis> get foo

"bar":q


####################

# Redis 서비스 실행#

####################

$ mkdir /etc/redis /var/lib/redis

$ sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf


$ wget https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server

$ sed -i "s/usr\/local\/sbin\/redis/usr\/local\/bin\/redis/" redis-server

$ chmod u+x redis-server

$ mv redis-server /etc/init.d

$ /sbin/chkconfig --add redis-server

$ /sbin/chkconfig --level 345 redis-server on

$ /sbin/service redis-server start

$ ps -ef // 프로세스 체크


####################

# Redis TEST       #

####################

telnet 아이피 포트

set attitude:today "happy"

get attitude:today



[출처]

http://redis.io/download

http://www.ebrueggeman.com/blog/install-redis-centos-56

Posted by CoolDragon