Jul 4, 2019 - 네이버에는 ICMP 가 막혀있습니다.

보통 해당 서버가 죽었는지 살았는지 확인하기 위해 PING을 날리곤 합니다.

C:\Users\bymin>ping google.com

Ping google.com [172.217.31.174] 32바이트 데이터 사용:
172.217.31.174의 응답: 바이트=32 시간=42ms TTL=54
172.217.31.174의 응답: 바이트=32 시간=29ms TTL=54
172.217.31.174의 응답: 바이트=32 시간=30ms TTL=54
172.217.31.174의 응답: 바이트=32 시간=29ms TTL=54

172.217.31.174에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 4, 손실 = 0 (0% 손실),
왕복 시간(밀리초):
    최소 = 29ms, 최대 = 42ms, 평균 = 32ms

ping goolge.com 이 이와같은데요.

icpm 프로토콜을 이용해서, 반복해서 호출하게 됩니다.
다만 상태 호스트가 icpm_reply 가 열려있어야 가능한데요.

naver.com의 경우 icmp_reply가 막혀있어서, 응답을 받지 못합니다.

C:\Users\bymin>ping naver.com

Ping naver.com [210.89.160.88] 32바이트 데이터 사용:
요청 시간이 만료되었습니다.
요청 시간이 만료되었습니다.
요청 시간이 만료되었습니다.
요청 시간이 만료되었습니다.

210.89.160.88에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 0, 손실 = 4 (100% 손실),

요청시간이 만료되었습니다!

Jul 3, 2019 - logstash 설정 방법

ELK 를 사용할때,

엘라스틱서치나, 키바나의 경우 공통적인 부분이 많아 처리하는 부분이 쉽지만, logstash 의 경우는 본인이 엘라스틱서치에 전달할 데이터포맷이, 솔류션마다 다르기 때문에 해당 작업을 함에 있어, 어려움이 많아 해당 내용을 정리합니다.

input {
  file {
    path => "C:/Users/bymin/Desktop/file/RTBViewLog.20190702"
    mode => "read"
    start_position => "beginning"
  }
}

filter {
 grok  {
   match => {
     "message" => "%{DATA:timestamp}\,%{USER:tagid}\, %{WORD:s}\, %{USER:userid}\, %{USER:auid}\, %{NUMBER:bidfloor:float}\, %{NUMBER:bid:float}\, %{NUMBER:wind:float}\, "
    }
  }
   date {
        match => [ "timestamp", "YYYYMMdd-HHmmss" ]
        target => "@timestamp"
        add_field => { "debug" => "timestampMatched"}
   }
}

output {
  elasticsearch {
    hosts => ["127.0.0.1:9200"]
    index => "_20190702_1"
  }
}

path : 파일이 있는 경로를 지정합니다. \ 로 작성시에 해당 파일을 못읽을 수도 있어 안정하게 / 로 변경해주시기 바랍니다.
mode => read : 해당 파일을 전부 읽어드리겠다는 모드 설정입니다.
해당 값을 안할 경우, log 에서 한줄씩 읽어서 엘라스틱서치에 보내게 됩니다. read 설정시 디폴트가 해당 파일을 삭제합니다.

grok : grok 플러그인을 통해, 해당 패턴을 json 형태로 변환해줍니다.
grok 에 관해서는 해당 url에서 패턴을 찾을 수 있습니다. (https://grokdebug.herokuapp.com/)

날짜는 파일에 있는 timestamp 로 index를 잡아야하므로, timestamp 패턴을 date 에 적용 후, 해당 값을 실제 timestamp 에 target 시킵니다.

logstash -f "config 파일 경로"

로 파일을 실행시킵니다.

Jun 19, 2019 - 윈도우 10 우분투에 레디스 설치

원하는 경로에 redis를 설치합니다.

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make

make 명령어를 치니, make가 설치가 안되었다고 뜹니다.

root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable# make

Command 'make' not found, but can be installed with:

apt install make
apt install make-guile

apt install make 명령어를 사용하여 설치하게 됩니다.

make[3]: Entering directory '/usr/local/redis/redis-stable/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: gcc: Command not found
Makefile:156: recipe for target 'net.o' failed
make[3]: *** [net.o] Error 127
make[3]: Leaving directory '/usr/local/redis/redis-stable/deps/hiredis'
Makefile:45: recipe for target 'hiredis' failed
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory '/usr/local/redis/redis-stable/deps'
Makefile:190: recipe for target 'persist-settings' failed
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: 1: cc: not found
Makefile:248: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory '/usr/local/redis/redis-stable/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

make[3]: gcc: Command not found 라는 에러가 뜹니다. gcc를 설치해야합니다.

apt install gcc

gcc 를 설치합니다. gcc 설치 중,

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_4.15.0-39.42_amd64.deb 404 Not Found [IP: 91.189.88.31 80]

이런 에러가 발생합니다.

apt-get update

apt-get 을 update 합니다.

apt install gcc

업데이트 후 gcc를 설치하면 404 Not Found 가 발생하지 않고 정상적으로 잘 설치가 됩니다.

gcc 설치 후, 다시 make를 치면 다음과 같은 에러가 납니다.

root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable# make
cd src && make all
make[1]: Entering directory '/usr/local/redis/redis-stable/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:248: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory '/usr/local/redis/redis-stable/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

최초 설치시 gcc가 없어 실패하면서, 무언가 제대로 설치가 안된거 같습니다.

단순하게 distclean 후 다시 설치하도록 하겠습니다.

make distclean
sudo make install

그럼 이제 정상적으로 redis 가 compile 되기 시작합니다.

설치가 완료되면, src 폴더로 이동합니다.

cd src

-rwxr-xr-x 1 root    root    5216008 Jun 19 11:14 redis-cli
-rwxr-xr-x 1 root    root    8770008 Jun 19 11:14 redis-server

redis-server 실행을 합니다. 근데 실행이 안됩니다. ㅠ-ㅜ

deps 폴더에 가서, 별도의 명령어를 치는 방법.

cd deps
make hiredis jemalloc linenoise lua geohash-int

deps 로 가서 jemalloc 가 기타 등등을 실행시킵니다.

그리고 다시 make 로 설치를 진행합니다.

sudo make install

그리고 다시 ./src 폴더로 가면, redis-server를 실행시킬 수 있습니다.

root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# redis-server
3963:C 19 Jun 2019 11:57:22.660 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3963:C 19 Jun 2019 11:57:22.661 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=3963, just started
3963:C 19 Jun 2019 11:57:22.662 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
3963:M 19 Jun 2019 11:57:22.663 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 3963
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

3963:M 19 Jun 2019 11:57:22.701 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3963:M 19 Jun 2019 11:57:22.704 # Server initialized
3963:M 19 Jun 2019 11:57:22.706 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
3963:M 19 Jun 2019 11:57:22.713 * Ready to accept connections
root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# nohup ./redis-server &
[1] 3982
root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# nohup: ignoring input and appending output to 'nohup.out'

root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src#
root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src#
root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# ps -ef|grep redis
root      3982    16  0 12:00 tty1     00:00:00 ./redis-server
root      3987    16  0 12:00 tty1     00:00:00 grep --color=auto redis
root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# redis-cli
127.0.0.1:6379> set key 'melong'
OK
127.0.0.1:6379> get key
"melong"
127.0.0.1:6379>

nohup 을 이용해, redis-server 를 실행시킵니다.
redis-cli 를 이용해 간단한 테스트를 진행해봅니다.

정상적으로 key와 value 가 찍히는 것을 확인할 수 있었습니다.

이제 레디스를 종료하기 위해, 레디스를 종료했습니다.

^C4004:signal-handler (1560924252) Received SIGINT scheduling shutdown...
4004:M 19 Jun 2019 15:04:12.255 # User requested shutdown...
4004:M 19 Jun 2019 15:04:12.256 * Saving the final RDB snapshot before exiting.
4004:M 19 Jun 2019 15:04:12.263 * DB saved on disk
4004:M 19 Jun 2019 15:04:12.263 # Redis is now ready to exit, bye bye...

라는 메시지가 뜨며 종료가 되었으나, client 에서 여전히 서버에 접속이 되는 것을 확인했습니다.

root@DESKTOP-RNJILIO:/usr/local/redis/redis-stable/src# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

현재 열려있는 port 를 확인해봤으나 검색이 되지 않습니다…..

혹시… 윈도우의 cmd 창을 띄운 후에 ,

C:\Users\bymin>netstat -a -o | find ":6379"

를 실행해봤습니다. 맙소사 윈도우 10 프로세스에 떠있습니다.

C:\WINDOWS\system32>taskkill /f /pid 4176
성공: 프로세스(PID 4176)가 종료되었습니다.

관리자 권한으로 프로세스를 강제로 킬했습니다.
이제 서버가 강제로 중지되었으며 해당 redis-server에 접속이 안되는 것을 확인했습니다.

윈도우 10에서 완벽하게 우분투를 설치해서 실제로 우분투 환경의 테스트를 하기는 아직 힘든거 같네요. 관련 프로세스를 리눅스에 온전히 띄우는 방법을 찾으면 다시 정리해서 올리도록 하겠습니다.