jdk 설치 



zookeeper 설치 
# wget http://apache.mirror.cdnetworks.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

# tar zxvf zookeeper-3.4.5.tar.gz

# cp -Rf zookeeper-3.3.5 /usr/local/zookeeper

# cd /usr/local/zookeeper




# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/usr/data/zookeeper
# the port at which the clients will connect
clientPort=2181

server.1=175.207.8.151:2888:3888
server.2=175.207.8.152:2888:3888
server.3=175.207.8.153:2888:3888


기타 작업 
1. 디렉토리 생성 /usr/data/zookeeper 
2. 파일 생성  cat > /usr/data/zookeeper/myid  
3. myid파일에  멀티 서버 설정한 server.1  번호를 입력  .. ##문자 입력하니 java 숫자 변환 에러 발생 -_- 문자 된다고했는데 몬가 이상함 




 ip 포트 설정 

iptables -I OUTPUT 1 -p tcp --dport 2888 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 2888 -j ACCEPT
iptables -I OUTPUT 1 -p tcp --dport 3888 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 3888 -j ACCEPT
iptables -I OUTPUT 1 -p tcp --dport 2181 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 2181 -j ACCEPT
service iptables save
service iptables restart

 

log 4j 설정 
 Define some default values that can be overridden by system properties
zookeeper.root.logger=INFO, CONSOLE
zookeeper.console.threshold=INFO
zookeeper.log.dir=/usr/local/zookeeper/log
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=/usr/local/zookeeper/log
zookeeper.tracelog.file=zookeeper_trace.log

#
# ZooKeeper Logging Configuration
#

# Format is "<default threshold> (, <appender>)+

# DEFAULT: console appender only
#log4j.rootLogger=${zookeeper.root.logger}

# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

# Example with rolling log file and tracing
log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
"conf/log4j.properties" 58L, 2207C






path 설정 


# vi ~/.bash_profile

JAVA_HOME=/usr/local/java
ZOOKEEPER_HOME=/usr/local/zookeeper
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin

# source ~/.bash_profile




주키퍼 테스트 블로그 : 


이클립스 플러그인 

http://www.massedynamic.org/mediawiki/index.php?title=Eclipse_Plug-in_for_ZooKeeper
 


 

성능 모니터를 이용하여 SQL Server 의 Disk I/O 를 측정하여 Disk 병목 현상이 있는지 확인 후 디스크 증가 등의 성능 튜닝을 진행한다.

 

<성능 모니터 카운터>
Disk Reads/sec : 선택된 디스크 (또는 디스크 어레이) 에서 초당 수행된 읽기 작업 횟수
Disk Writes/sec : 선택된 디스크 (또는 디스크 어레이) 에서 초당 수행된 쓰기 작업 횟수
Avg. Disk Queue Length : 샘플 간격 동안 선택된 디스크에 대해 큐에 있는 읽기 및 쓰기 요청의 평균 수
Avg. Disk Sec/Read : 샘플 간격 동안 선택된 디스크에서 데이터 읽기에 소요된 평균 시간(초)
Avg. Disk Sec/Write : 샘플 간격 동안 선택된 디스크에서 데이터 쓰기에 소요된 평균 시간(초)

 

<임계값>

카운터

임계값

초당 디스크 당 I/O 수

100 이하

Disk Reads/sec

0.015 (15ms) 이하

Disk Writes/sec

0.015 (15ms) 이하

Avg. Disk Queue Length

2 이하

 

<I/O 계산>
디스크 당 I/O 수 = [읽기 + (2 * 쓰기)] / 디스크 수

 

#RAID 10 어레이로 구성된 8개 디스크 드라이브의 예

카운터

측정값

Disk Reads/sec

420

Disk Reads/sec

300

Avg. Disk Queue Length

43

Avg. Disk Sec/Read

0.032

Avg. Disk Sec/Read

0.025

 

[420 + (2 * 300)] / 8 = 127.5 디스크 당 물리적 I/O 수

결과값 127.5는 초당 100 I/O라는 한계값을 초과하므로, 이 경우 약간의 디스크 병목을 가지게 된다. 읽기 및 쓰기에 걸린 시간 값만을 조사하여도 병목이 발생함을 알 수 있다. 또, 평균 큐 길이가 43으로 I/O 요청이 큐에서 잠시 기다림으로 인해 긴 대기시간이 발생함을 의미한다.

 

<디스크 최소 개수>

[420 읽기 + (2 * 300 쓰기)] = 1020 I/O
1020 전체 I/O / 100 디스크 당 I/O = 10.2 필요한 디스크 수 
10.2 디스크는 가질 수 없으므로 12개의 디스크로 반올림 (RAID 10을 위해서는 짝수개의 디스크 필요)

 

 

출처 : SQL Server 2000 성능 튜닝 (하성희 역)
 
BCP 란.
대량의 데이터를 파일을 통하여 빠르게 처리하는 명령어( 유틸리티) 
특징 
1. 특징 콜솔상에서 명령어를 입력
2. 원격지에 있는 데이터도 추출 할 수 있다.
3. 추출한 데이터는 로컬에 쌓인다. 

명령어 예제. 
 CMD 상에서 아래 명령어를 입력 한다.
bcp CHACHACHAF_REPLICATION..TB_CAR out bcp_data_titles2.txt -c -q -T -S 127.0.0.1,5432 -U 아이디 -P 비번
bcp CHACHACHAF_REPLICATION..TB_PRESENT_TROPHY out bcp_data_TB_PRESENT_TROPHY2.txt -c -q -T -S 127.0.0.1,5432 -U 아이디 -P 비번
bcp CHACHACHA2_DDR..TB_DDR out bcp_data_TB_DDR.txt -c -q -S 175.207.8.112,1434 -U 아이디 -P 비번

쿼리로 가능  ?  (비권장)
쿼리로 CMD 명령어가 가능하지만 권한 문제로 할 수 없음 오픈해 주면 가능 하지만 보안 문제가 있다고한다. 하지만
웹서비스 풀 쿼리를 이용하는데서 발생 할 수 있는 문제인듯하다. 게임에서는 프로시저를 통하기 때문에 발생 하지 않을듯 하다. 

예제 
DECLARE @query VARCHAR (500)
SET @query = 'bcp CHACHACHAF_REPLICATION..TB_PRESENT_TROPHY out D:\MS_SQl_DB_FILE\bcp\bcp_data_TB_PRESENT_TROPHY2.txt -c -q -T -S 127.0.0.1,5432 -U 비번 -P 아이디
EXEC MASTER ..xp_cmdshell @query
  





SELECT * FROM TB_CAR
SELECT * FROM TB_PRESENT_TROPHY
/*

bcp CHACHACHAF_REPLICATION..TB_CAR out bcp_data_titles2.txt -c -q -T -S 127.0.0.1,5432 -U sa -P ab1020!!

bcp CHACHACHAF_REPLICATION..TB_PRESENT_TROPHY out bcp_data_TB_PRESENT_TROPHY2.txt -c -q -T -S 127.0.0.1,5432 -U sa -P ab1020!!

bcp CHACHACHA2_DDR..TB_DDR out bcp_data_TB_DDR.txt -c -q -S 175.207.8.112,1434 -U sa -P q1w2e3r4t5y6

*/

BULK INSERT CHACHACHAF_REPLICATION.dbo .TB_CAR FROM 'D:\MS_SQl_DB_FILE\bcp\bcp_data_titles2.txt'



BULK INSERT CHACHACHAF_REPLICATION.dbo .TB_PRESENT_TROPHY FROM 'D:\MS_SQl_DB_FILE\bcp\bcp_data_TB_PRESENT_TROPHY2.txt'





DECLARE @query VARCHAR (500)
SET @query = 'bcp CHACHACHAF_REPLICATION..TB_PRESENT_TROPHY out D:\MS_SQl_DB_FILE\bcp\bcp_data_TB_PRESENT_TROPHY2.txt -c -q -T -S 127.0.0.1,5432 -U sa -P ab1020!!'
EXEC MASTER ..xp_cmdshell @query




bcp AdventureWorks2012.HumanResources.Department format nul -T -n -f Department-n.fmt

bcp AdventureWorks2012..MyTestFormatFiles format nul -c -t, -f myTestFormatFiles.Fmt -T


bcp AdventureWorks2012..MyTestFormatFiles format nul -c -t, -x -f myTestFormatFiles.Xml -T


  

  

 

java 에서 나온 타임스템프값 

 1459180800000
DB로 할대는 뒤 3자리 제거

 

select CONVERT (varchar ( 30), dateadd( second , 1459180800/*timestamp 값*/, cast( '1970-01-01 00:00:00.000' as datetime )) , 121 ) vtimestamp
go
select CONVERT (varchar ( 30), dateadd( second , 1459138500/*timestamp 값*/, cast( '1970-01-01 00:00:00.000' as datetime )) , 121 ) vtimestamp
 go

 

하나의 테이블에 모든 로우의 개수를 알고 싶을때 보통 아래와 같이 작성을 많이 한다.


SELECT COUNT(*) FROM TestTable;


뭐 저렇게 사용해도 상관은 없지만 속도측면에서 좀 더 나은 방법이 있어서 소개 한다.


SELECT rows FROM sysindexes WHERE id = OBJECT_ID('TestTable') AND indid < 2;


대충 보면 이해가 될 것이니 설명은 패스한다.


속도차이는 COUNT를 하려는 테이블의 총 로우 개수가 100개 미만이라면 COUNT가 더 빠르다.


100개 이상이라면 위에 적어놓은 쿼리가 훨씬 빠르다.


속도 차이가 나는 이유는 COUNT 키워드를 실행하게 되면 table scan을 하게되지만 


대체 쿼리에서는 해당 rows값을 가져오기 때문에 더 빠르다.


물론 내가 테스트해본거니 확인은 다들 해보고 적용하기 바란다.


* 해당 쿼리는 테이블의 전체 로우 개수를 가져올때만 유효하다.

▶ snapshot replication (원하는 테이블 컬럼 가져올 수 있음)

1. DB 인스턴스 2개 설정

    --> 게임DB
    --> 운영툴(구독 DB)
2. 게임 DB : snapshot 설정
     --> 배포 설정 
     --> 구독 설정 주기는 게임 환경에 맞게 설정 테이블 종류에 맞게 설정 (테이블, 프로시저, 뷰  가능 , 필드및 필더 가능 )
3. 운영툴(구독 DB ) 구독 설정 
     --> 구독 설정 
     --> 관련된 통계 프로시저 작성
     --> 잡설정
4. 단점 
     --> 한 스키마에서 다양한 게임 DB 정보를 취합하기 어려움...??

▶ DB snapshot (통자로 데이터 복사됨)

1. 특정 시간마다 스키마 snapshot를 생성 
     --> 게임DB 1,2 
2. 프로시저를 통하여 데이터 Select Insert 
    
3. view 제공

4. 단점 
     --> 작업 자동화 힘듬 DB 추가 될때마다 프로시저 수정 요지 있음.


▶ 직접 구현 
1.  본서버-> 통계서버로 테이블 복사 
2.  통계서버 -> 작업 진행 
3. 운영툴 제공 
 
4. 단점 
   --> 개발자 작업량



▶ 직접 구현 구상안 1
1. snapshot replication 데이터 복사
     --> 게임 DB (배포,계시), 1:1 구독 DB 구현 
2. 통계 테이블로 데이터 취합  ( 스케줄러 )
     --> 구독 DB 정보를  취합 ( 프로시저 작업 ) 
     --> 통계 정보 가공 ( 기본정보, 요구 사항 처리 ) 
3. view 제공
      --> 통계 정보 화면 표현 

▶ 직접 구현 구상안 2
1. BCP로 직접 데이터  추출 
     1) CMD 명령어 Batch 파일 마들어서 추출 
     2) 명령 프로그램 구현 
     3) SQL 스케줄러로 구현 ( 권한 필요함 ) -http://zaco.tistory.com/249
2. SQL 스케줄러로 테이블 입력 ( Bluk Insert  > BCP IN 보다 빠름) 
     1) bluk inser
     2) 통계 데이터 추출 

 




스키마 전체 스넵샵 설정

CREATE DATABASE CHACHACHAF_GAME_SHAPSHOT

ON (NAME = CHACHACHAF_GAME, FILENAME = 'D:\MS_SQl_DB_FILE\SNAPSHOT\CHACHACHAF_GAME_SHAPSHOT.mdf' )

as SNAPSHOT OF CHACHACHAF_GAME;



USE CHACHACHAF_GAME_SHAPSHOT
  

1. 일단 2.8 기준으로 설정한다. 


2. conf 파일을 만든다.
6379.conf  6479.conf  6579.conf  6679.conf  6779.conf  6879.conf  6979.conf
이처럼 6개파일을 만든다.
위 컴피그를 수정한다. 
[root@localhost conf]# vi 6379.conf

## Generated by install_server.sh ##
################################## INCLUDES ###################################
# include /path/to/local.conf
# include /path/to/other.conf
################################ GENERAL  #####################################
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
tcp-backlog 511
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1
# unixsocket /tmp/redis.sock
# unixsocketperm 700
timeout 0
tcp-keepalive 0
loglevel notice
logfile /usr/local/redis/log/redis_6379.log
# syslog-enabled no
# Specify the syslog identity.
# syslog-ident redis
# syslog-facility local0
databases 16

################################ SNAPSHOTTING  ################################
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /usr/local/redis/data/6379

################################# REPLICATION #################################
# slaveof <masterip> <masterport>
# masterauth <master-password>
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
# repl-ping-slave-period 10
# repl-timeout 60
repl-disable-tcp-nodelay no
# repl-backlog-size 1mb
# repl-backlog-ttl 3600
slave-priority 100
# min-slaves-to-write 3
# min-slaves-max-lag 10
################################## SECURITY ###################################
# requirepass 1234
# rename-command CONFIG ""

################################### LIMITS ####################################
# maxclients 10000
# maxmemory <bytes>
# maxmemory-policy noeviction
# maxmemory-samples 5
############################## APPEND ONLY MODE ###############################
appendonly yse
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes

################################ LUA SCRIPTING  ###############################
lua-time-limit 5000

################################ REDIS CLUSTER  ###############################
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 15000
# cluster-slave-validity-factor 10
# cluster-migration-barrier 1
# cluster-require-full-coverage yes

################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128

################################ LATENCY MONITOR ##############################
latency-monitor-threshold 0

############################# EVENT NOTIFICATION ##############################
notify-keyspace-events ""

3. 위설정한 디렉토리는 전부 있어야한다.

4. 만든 컨피그로 모든 레디스 실행한다 
/usr/local/redis/redis-cluster-test/6379/redis-server /usr/local/redis/redis-cluster-test/6379/6379.conf
/usr/local/redis/redis-cluster-test/6479/redis-server /usr/local/redis/redis-cluster-test/6479/6479.conf
/usr/local/redis/redis-cluster-test/6579/redis-server /usr/local/redis/redis-cluster-test/6579/6579.conf
/usr/local/redis/redis-cluster-test/6679/redis-server /usr/local/redis/redis-cluster-test/6679/6679.conf
/usr/local/redis/redis-cluster-test/6779/redis-server /usr/local/redis/redis-cluster-test/6779/6779.conf
/usr/local/redis/redis-cluster-test/6879/redis-server /usr/local/redis/redis-cluster-test/6879/6879.conf



5. 클러스터 설정 자동으로 클라스터 설정을 잡는다. 노드 범위도 자동으로 분활해준다. 만약 노드 범위를 바꾸려면 옵션으로 변경가능하다.

./redis-trib.rb create --replicas 1 175.207.8.169:6379 175.207.8.169:6479 \175.207.8.169:6579 175.207.8.169:6679 175.207.8.169:6779 175.207.8.169:6879



6. 에러 발생 

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable
이동 
$ cd /usr/localrvm/bin
$ rvm install 2.2.0+
gem 설치 
# yum install rubygems
gem redis
#gem install redis


7. 참고사항 
위 클러스터 설정은 기존에 있던 sentinel + sharding 기능을 한다고 보면된다.




참고 싸이트 
http://redis.io/topics/cluster-tutorial -- 클러스터 튜토리얼 공식
http://the-earth.tistory.com/182 --번역본 
http://ddakker.tistory.com/327 --4번 설정시 에러 날때 해결법 ruby 설정


/usr/local/redis/src/redis-cli -p 6379 shutdown
/usr/local/redis/src/redis-cli -p 6479 shutdown 
/usr/local/redis/src/redis-cli -p 6579 shutdown 
/usr/local/redis/src/redis-cli -p 6679 shutdown 
/usr/local/redis/src/redis-cli -p 6779 shutdown 
/usr/local/redis/src/redis-cli -p 6879 shutdown  


rm -f  /usr/local/redis/data/6379/*
rm -f  /usr/local/redis/data/6479/* 
rm -f  /usr/local/redis/data/6579/* 
rm -f  /usr/local/redis/data/6679/* 
rm -f  /usr/local/redis/data/6779/* 
rm -f  /usr/local/redis/data/6879/* 





1. 데이터 입력중 마스터 DB가 중지댈때 데이터 보장되는 지 확인 


1.1 소스코드 

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.data.redis.RedisConnectionFailureException;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.jedis.exceptions.JedisConnectionException;

/**
* @Auth Hong Seungkyun
* @Description
* <pre></pre>
*/
public class RedisTest {

     public static void main(String[] args) throws Exception {

          Set<String> sentinelIps = new HashSet<>();
          sentinelIps.add("175.207.8.166:26379");
          sentinelIps.add("175.207.8.167:26379");
          sentinelIps.add("175.207.8.168:26379");

          GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();

          JedisSentinelPool jedisSentinelPool = new JedisSentinelPool("mymaster", sentinelIps, poolConfig, 5000, "1020");
          Jedis jedis1 = jedisSentinelPool.getResource();
          String[] keys = new String[100];
         
         
         
          //삭제처리
          StringBuffer delkey = new StringBuffer();
          for (int i = 0; i < 100; i++) {    
               keys[i] ="Test_"+i;
          }    
          jedis1.del(keys);
              

          for (int i = 0; i < 100; i++) {              
               try {
                    RedisTest.setData(jedisSentinelPool, "Test_"+i, "value_"+i);
                    System.out.println("input > key : Test_"+i+" , value :  value_"+i);
               } catch (Exception e) {
                    System.out.println(e.getMessage());
                    System.out.println("에러 발생");
               }         
              
               Thread.sleep(500);
          }
         
          for (int i = 0; i < 100; i++) {
               Jedis jedis = jedisSentinelPool.getResource();
               try {
                    String value = jedis.get("Test_" + i);
                    System.out.println("output > key : Test_"+i+" , value :"+value);
               } catch (RedisConnectionFailureException e) {
                    e.printStackTrace();
                    jedisSentinelPool.returnBrokenResource(jedis);
               } finally {

                    try {

                         jedisSentinelPool.returnResource(jedis);

                    } catch (JedisConnectionException e) {

                         System.out.println(e);

                    }
               }
          }

          /*
          * JedisPool jedisPool = new JedisPool(new JedisPoolConfig(), "175.207.8.166",6379,0,"1020");
          * Jedis jedis = jedisPool.getResource();
          * try {
          * jedis.set("foo", "client_test");
          * } catch (Exception e) {
          * System.out.println(e.getMessage());
          * }
          * System.out.println(">>>>> : "+jedis.get("foo"));
          */

     }
     public  static void  setData(JedisSentinelPool jedisSentinelPool, String key , String value ){
          Jedis jedis =null;
          try {              
               jedis = jedisSentinelPool.getResource();
               jedis.set(key, value);
          } catch (RedisConnectionFailureException e) {
               System.out.println(e);
               System.out.println("헐헐2!!");
               jedisSentinelPool.returnBrokenResource(jedis);
          } finally {
               try {
                    jedisSentinelPool.returnResource(jedis);
               } catch (JedisConnectionException e) {                   
                    System.out.println(e);
                    System.out.println("헐헐3!!");
               }
          }
         
     }

}
1.2 서버 콘솔 
입력 도중 
# redis-cli -a 1020 shutdown 명령 입력 

1.3 데이터 처리 로그 

1월 27, 2015 11:16:22 오전 redis.clients.jedis.JedisSentinelPool initSentinels
정보: Trying to find master from available Sentinels...
1월 27, 2015 11:16:23 오전 redis.clients.jedis.JedisSentinelPool initSentinels
정보: Redis master running at 175.207.8.167:6379, starting Sentinel listeners...
1월 27, 2015 11:16:23 오전 redis.clients.jedis.JedisSentinelPool initPool
정보: Created JedisPool to master at 175.207.8.167:6379
input > key : Test_0 , value :  value_0
.......
input > key : Test_16 , value :  value_16
input > key : Test_17 , value :  value_17 ==>> 에러 최초 발생 
Unexpected end of stream.
에러 발생
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Software caused connection abort: socket write error
헐헐3!!
java.net.SocketException: Software caused connection abort: socket write error
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
Could not get a resource from the pool
에러 발생
1월 27, 2015 11:17:03 오전 redis.clients.jedis.JedisSentinelPool initPool
정보: Created JedisPool to master at 175.207.8.168:6379
Could not get a resource from the pool
에러 발생

input > key : Test_41 , value :  value_41 ==> 마스터 체이진 정상 입력
input > key : Test_42 , value :  value_42
........
input > key : Test_99 , value :  value_99

//데이터 읽기
output > key : Test_0 , value :value_0
output > key : Test_1 , value :value_1
output > key : Test_2 , value :value_2
........
output > key : Test_17 , value :value_17
output > key : Test_18 , value :null
output > key : Test_19 , value :null
output > key : Test_20 , value :null
......
output > key : Test_36 , value :null
output > key : Test_37 , value :null
output > key : Test_38 , value :null
output > key : Test_39 , value :null
output > key : Test_40 , value :null

output > key : Test_41 , value :value_41
output > key : Test_42 , value :value_42
........
output > key : Test_95 , value :value_95
output > key : Test_96 , value :value_96
output > key : Test_97 , value :value_97
output > key : Test_98 , value :value_98
output > key : Test_99 , value :value_99

결론 
강제 셧다운시 10초  이후에 시스템이 정상 운영됨 
1. 10 초 사이데이터 처리 방안이 필요함 ( 서버 체크 시간 8초로 설정해서 11초후에 정상 처리  시스템  설정 시간보다 다소 시간이 지연됨.)


참고 싸이트 

 


 

 

1. 설치 위치 : http://www.redis.io/download

2. 설치 하기 


$ wget http://download.redis.io/releases/redis-2.8.15.tar.gz
$ tar xzf redis-2.8.15.tar.gz
$ cd redis-2.8.15
$ make
$ make install


2. 인스톨 하기 
$ cd utils
$ ./install_server.sh

3. 실행/종료 

$ /etc/init.d/redis_6379 start
$ /etc/init.d/redis_6379 stop


4. 테스트 

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"


5. 비밀번호 설정  

$ vi etc/redis/6379.conf 

requirepass 비밀번호

파일 저장 

$ /etc/init.d/redis_6379 stop
$ /etc/init.d/redis_6379 start


6. 접속 테스트 
src/redis-cli
auth 비밀번호 
ok
사용 하면 끝



7. 포트 열기 기본 레디스 + 센티널 포트 열기


# iptables -I INPUT 1 -p tcp --dport 6379 -j ACCEPT 
# iptables -I OUTPUT 1 -p tcp --dport 6979 -j ACCEPT  
# iptables -I INPUT 1 -p tcp --dport 26379 -j ACCEPT 
iptables -I OUTPUT 1 -p tcp --dport 26379 -j ACCEPT 


# service iptables save
# service iptables restart





8. Master/ slave 설정
Master 의 경우
      SECURITY 섹션에서 requirepass 를 설정하기만 하면 된다.
   # requirepass foobared
      이 부분을 주석 제거하고, 원하는 비밀번호로 설정.. 센티널 설정할려면 이부분 설정한다.

Slave 의 경우    
   # slaveof <masterip> <masterport>
      주석 제거하고, 마스터의 아이피와 포트를 적는다. 기본 포트를 사용한다면 6379

    REPLICATION 섹션에서 설정을 변경한다.
   # masterauth <master-password>
      주석 제거하고, requirepass에서 설정한 비밀번호를 적는다.
   # repl-ping-slave-period 10
      주석 제거하고, 기본값 10으로 사용
   # repl-timeout 60
      주석 제거하고, 기본값 60으로 사용
      repl-ping-slave-period 값보다 큰 값을 사용하라는 코멘트가 있다.

  


9. 기타 사항 
1. 마스터 서버 종료하기 
./redis-cli - a 비밀번호
> SHUTDOWN





참고 싸이트 

1. http://trend21c.tistory.com/1645 에러 관련 정리  잘되어있슴
2. http://lovedev.tistory.com/?page=3 설치 관련 정보

문제 해결 

$yum -y install gcc

$ make distclean
$ make
$ make test

$ yum -y install tcl
$ make test



10. sentinel 설정
11. 준비 과정 
          --> master/slave 설정을 완료하고 레디스를 실행한다.
          --> sentinel.conf 설정을 해당 서버 환경에 맞게 설정한다.
          --> 실행시에는 redis-sentinel /usr/local/reids/conf/sentinel.conf(프로퍼티 파일으 내가만든파일 위치)     

12. 센티널 설정 
sentinel.conf 설정 (설정파일은 redis 설치한 디렉토리에 보면 샘플 파일이 있다 이것을 복사해서 써도대고 새로 만들어도 된다)
## 마스터/ 슬레이브 설정
sentinel monitor mymaster 175.207.8.168 6379 2
sentinel down-after-milliseconds mymaster 30000
sentinel auth-pass mymaster 1020
sentinel failover-timeout mymaster 80000
sentinel parallel-syncs mymaster 1
 

 --> 마스터만 설정을 전부 다하고 
 --> 슬레이브는 마스터만 등록하면된다.

13. 설정참고 URL

14. 개발 운영 참고
15. 개잘 참고 사이트 
http://yakolla.tistory.com/47 -- 자바 관련 설명되어있다.

16. shiding