아무런 설정을 하지않고 Kibana에 접속을 한뒤 왼쪽 메뉴에 Monitoring 메뉴에 들어가면


모니터링 설정이 OFF 되어있다고 메세지가 나오면서 가운데에 Turn On Data 라는 버튼이 보일 것입니다.


이 버튼을 클릭하고 수 초를 기다리고 나면 하단과 같이 Elasticsearch과 Kibana를 모니터링 하는 화면이 보입니다.


그외에 Beats와 Logstash 도 Monitoring이 가능합니다.



스프링 로그를 효율적으로 관리(?) 통계를 내기 위해 Spring Boot 와 ELK(Elasticsearch, Logstash, Kibana)를 통해서 


로그를 수집하기로 했습니다.


로그 수집하는 플로우는


Spring Boot ---> Logstash ---> Elasticsearch ---> Kibana를 통해 통계 확인 입니다.



우선은 Spring Boot는 기존에 있는 프로젝트 그대로 사용하기로 하고 ELK 를 먼저 셋팅해 보겠습니다.


먼저 ELK를 아래의 사이트에서 각 OS와 bit 에 맞게 다운로드를 해서 설치를 합니다.

(저는 윈도우10에서 진행하였습니다.)


Elasticsearch 다운로드: https://www.elastic.co/kr/downloads/elasticsearch

Kibans 다운로드: https://www.elastic.co/kr/downloads/kibana

Logstash 다운로드: https://www.elastic.co/kr/downloads/logstash



다운로드를 하고 설치까지 마쳤으면 Logstash 설정을 먼저 진행합니다.


Logstash 설정파일은 설치한 위치에서 Config 폴더 안에 보면 logstash-sample.conf 파일이 있습니다.


이 파일을 하나 복사해서 logstash.conf 라고 파일을 하나 생성합니다.


생성이 완료 되면 logstash.conf 파일을 열어서 설정파일을 수정합니다.



input 설정은 Spring Boot 와 Logstash 와 통신하기위해 TCP를 사용하였고 포트는 4560을 사용합니다.


그리고 코덱은 json을 라인별로 읽을 수 있게 설정하였습니다.


output은 Logstash에서 받은 로그를 Elasticsearch로 전송하기 위한 설정입니다.


설치한 Elasticsearch의 host 기본정보는 localhost:9200 이고 Index는 Elasticsearch에서 검색할 수 있게 패턴을 


설정할 수 있습니다. Index를 logstash-오늘날짜로 변경하였습니다.



그리고 Spring Boot logback 을 설정합니다.


기존에 작성되어있는 Spring Boot logback 설정에서 아래의 부분을 추가합니다.



<!-- Log Stash 사용시 사용할 TCP 통신 정보 -->
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>127.0.0.1:4560</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"></encoder>
</appender>


<root level="INFO">
<appender-ref ref="dailyRollingFileAppender" />
<appender-ref ref="stash" />
</root>


이 두 부분을 추가합니다.


로그가 쌓일때 Logstash 에서 설정한 TCP Port 4560에 동일한 서버에 있으니 127.0.0.1 로 설정하였습니다.


그리고 실제로 로그가 동작하기 위해 root 태그 아래 부분에 설정하였습니다.


이렇게 설정을 완료 한 후 Logstash를 실행하고 Spring Boot를 실행하면 됩니다.


Logstash 실행방법은 CMD 에서 Logstash 설치한 폴더에 bin폴더로 이동후 logstash -f ../config/logstash.conf 를 입력하면 실행이 됩니다.



그리고 Elasticsearch 실행방법 입니다.


Elasticsearch 실행 방법은 Elasticsearch 설치한 폴더에서 bin 폴더로 이동 후 CMD 에서 elasticsearch 를 입력하면 실행이 됩니다.


만약 포트 정보나 그외의 Elasticsearch 정보를 변경하고 싶으면 Elasticsearch 설치 폴더에서 config 폴더로 이동 후  elasticsearch.yml 파일에서 수정하시면


됩니다. 


실행이 정상적으로 됐는지 확인하려면 브라우저에서 http://localhost:9200/ 를 입력하면 아래와 같은 화면이 나오면 정상적으로 실행이 된것입니다.





마지막으로 Kibans 실행방법입니다.


Kibana도 Elasticsearchd와 마찬가지로 Kibana 설치한 폴더에서 bin 폴더로 이동 후 CMD 에서 kibana 를 입력하면 실행이 됩니다.


Kibana또한 실행이 되었는지 확인을 하려면 브라우저에서 http://localhost:5601 를 입력하면 아래와 같은 화면이 나오면 정상적으로 실행이 된것입니다.







윈도우에서는 공식적으로 Redis 를 사용할 수 없지만 MSOpenTech에서 지속적으로


윈도우 버전으로 포팅을 해주고 있습니다. 현재 최신 버전은 3.2.100 입니다.


아래의 링크로 접속하여 다운받은 후 설치를 진행합니다.


https://github.com/MicrosoftArchive/redis/releases


여기서 zip 버전을 다운받은 후 원하는 위치에 압축을 해제합니다.


압축을 해제후 폴더로 접근하여 redis-server.exe를 실행하면 레디스가 실행이 됩니다.


그리고 Redis Client Tool로는 아래의 링크에서 받아서 사용하시기 바랍니다.


https://fastoredis.com/anonim_users_downloads

웹서버 트래픽 폭주 대비하기 - (1) Apache + Tomcat 설정값 튜닝 사례

https://m.blog.naver.com/tmondev/220731906490


웹서버 트래픽 폭주 대비하기 - (2) APACHE vs. NGINX 성능 비교

https://m.blog.naver.com/tmondev/220737182315



파티션 정보 확인

[root@server /]# fdisk -l


Disk /dev/xvda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0009458d


    Device Boot      Start         End      Blocks   Id  System

/dev/xvda1   *           1         131     1048576   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/xvda2             131         392     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/xvda3             392        2611    17824768   83  Linux


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000



파티션 만들기

[root@server /]# fdisk  /dev/xvdb


Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xd56ebe5a.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').


Command (m for help): m <<= 도움말 보기

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)


Command (m for help): p <<= 파티션 테이블 확인


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xd56ebe5a


    Device Boot      Start         End      Blocks   Id  System


Command (m for help): n <<= 새 파티션을 추가

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1 <<= 1번 파티션 입력

First cylinder (1-10443, default 1): 엔터(기본으로 1 적용)

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): 엔터(기본으로 10443 적용)

Using default value 10443


Command (m for help): t <<= 생성한 파티션의 id를 선택하기 위해 입력

Selected partition 1

Hex code (type L to list codes): L <<= 타입 리스트 확인


 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris

 1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-

 2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-

 3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

 4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx

 5  Extended        42  SFS             86  NTFS volume set da  Non-FS data

 6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .

 7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility

 8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt

 9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access

 a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O

 b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor

 c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs

 e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT

 f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor

12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor

14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary

16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS

17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep

1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT

1e  Hidden W95 FAT1

Hex code (type L to list codes): 8e <<= Linux LVM 타입으로 선택

Changed system type of partition 1 to 8e (Linux LVM)


Command (m for help): w <<= 생성한 테이블 정보를 저장

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.



파티션 확인

[root@server /]# fdisk -l


Disk /dev/xvda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0009458d


    Device Boot      Start         End      Blocks   Id  System

/dev/xvda1   *           1         131     1048576   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/xvda2             131         392     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/xvda3             392        2611    17824768   83  Linux


Disk /dev/xvdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xd56ebe5a


    Device Boot      Start         End      Blocks   Id  System

/dev/xvdb1               1       10443    83883366   8e  Linux LVM



LV(Logical Volume) 작업 - PV(Pysical Volume) 생성

[root@server /]# pvcreate /dev/xvdb1


Physical volume "/dev/xvdb1" successfully created



LV(Logical Volume) 작업 - PV 생성 확인

[root@server /]# pvscan


PV /dev/xvdb1                      lvm2 [80.00 GiB]

Total: 1 [80.00 GiB] / in use: 0 [0   ] / in no VG: 1 [80.00 GiB]



LV(Logical Volume) 작업 - PV 정보 보기

[root@server /]# pvdisplay


"/dev/xvdb1" is a new physical volume of "80.00 GiB"

--- NEW Physical volume ---

PV Name               /dev/xvdb1

VG Name

PV Size               80.00 GiB

Allocatable           NO

PE Size               0

Total PE              0

Free PE               0

Allocated PE          0

PV UUID               Q3LGAX-jhK4-w6eL-XA3t-Y1Mg-ICP0-IFzBOE



LV(Logical Volume) 작업 - VG(Volume Group) 생성

[root@server /]# vgcreate DataVG /dev/xvdb1


Volume group "DataVG" successfully created



LV(Logical Volume) 작업 - VG 생성 확인

[root@server /]# pvscan


PV /dev/xvdb1   VG DataVG   lvm2 [80.00 GiB / 80.00 GiB free]

Total: 1 [80.00 GiB] / in use: 1 [80.00 GiB] / in no VG: 0 [0   ]



LV(Logical Volume) 작업 - VG 정보 보기

[root@server /]# vgdisplay


--- Volume group ---

VG Name               DataVG

System ID

Format                lvm2

Metadata Areas        1

Metadata Sequence No  1

VG Access             read/write

VG Status             resizable

MAX LV                0

Cur LV                0

Open LV               0

Max PV                0

Cur PV                1

Act PV                1

VG Size               80.00 GiB

PE Size               4.00 MiB

Total PE              20479

Alloc PE / Size       0 / 0

Free  PE / Size       20479 / 80.00 GiB

VG UUID               7aEQ4r-ecmp-1S5r-mcId-YIFB-aLXf-CLSTJc



LV(Logical Volume) 작업 - LV(Logical Volume) 생성

[root@server /]# lvcreate -L 80g -n Data00 DataVG


Volume group "DataVG" has insufficient free space (20479 extents): 20480 required.

[root@server /]# lvcreate -l 20479 -n Data00 DataVG


Logical volume "Data00" created



LV(Logical Volume) 작업 - LV 정보 보기

[root@server /]# lvdisplay


--- Logical volume ---

LV Path                /dev/DataVG/Data00

LV Name                Data00

VG Name                DataVG

LV UUID                NiQ37f-ilLm-m5iE-JNEl-UBP1-eNJt-mgQA7r

LV Write Access        read/write

LV Creation host, time VM1495178951968.localdomain, 2018-09-18 22:02:07 +0900

LV Status              available

# open                 0

LV Size                80.00 GiB

Current LE             20479

Segments               1

Allocation             inherit

Read ahead sectors     auto

- currently set to     256

Block device           253:0



파일 시스템 생성

[root@server /]# mkfs.ext3 /dev/DataVG/Data00


mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

5242880 inodes, 20970496 blocks

1048524 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

640 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000


Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 24 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.


마운트 작업 - 마운트 할 디렉토리 생성

[root@server /]# mkdir /data

마운트 작업 - /dev/DataVG/Data00를 /data에 마운트

[root@server /]# mount /dev/DataVG/Data00 /data


마운트 작업 - 마운트 확인

[root@server /]# mount


/dev/xvda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/xvda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

none on /proc/xen type xenfs (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

/dev/mapper/DataVG-Data00 on /data type ext3 (rw)

[root@server /]# df -h


Filesystem            Size  Used Avail Use% Mounted on

/dev/xvda3             17G   15G  1.4G  92% /

tmpfs                 1.9G     0  1.9G   0% /dev/shm

/dev/xvda1           1008M   56M  901M   6% /boot

/dev/mapper/DataVG-Data00

                       79G  184M   75G   1% /data



마운트 작업 - /etc/fstab에 마운트 정보 추가

[root@server /]# vi /etc/fstab


#

# /etc/fstab

# Created by anaconda on Wed Mar 16 15:52:09 2016

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=cc0565f7-adc2-4995-92d8-03d03830e0b3 /                       ext4    defaults        1 1

UUID=ab5b8d4a-1997-4b82-a764-05dbdf44dac2 /boot                   ext4    defaults        1 2

UUID=5cb8d624-6c99-478d-b05d-566b756ae6a5 swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/DataVG/Data00 /data ext3 defaults 1 2 <<= 추가한 내용


+ Recent posts