기존에 geoip iptables 설치하려면



./geoip/xt_geoip_dl"


./geoip/xt_geoip_build GeoIPCountryWhois.csv"


이부분 진행했었는데 이중에서 ./geoip/xt_geoip_dl" 요거 이제 에러난다.


~/geoip/xtables-addons-1.47.1/geoip]# ./xt_geoip_dl  

--2019-02-15 10:45:49--  http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz

Resolving geolite.maxmind.com... 104.16.37.47, 104.16.38.47, 2606:4700::6810:262f, ...

Connecting to geolite.maxmind.com|104.16.37.47|:80... connected.

HTTP request sent, awaiting response... 404 Not Found

2019-02-15 10:45:50 ERROR 404: Not Found.


--2019-02-15 10:45:50--  http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip

Connecting to geolite.maxmind.com|104.16.37.47|:80... connected.

HTTP request sent, awaiting response... 404 Not Found

2019-02-15 10:45:50 ERROR 404: Not Found.


gzip: GeoIPv6.csv.gz: No such file or directory

unzip:  cannot find or open GeoIPCountryCSV.zip, GeoIPCountryCSV.zip.zip or GeoIPCountryCSV.zip.ZIP.




http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz

http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip


위 두 파일이 없다고 한다. 실제로 홈페이지 들어가보면 not found 뜬다. 파일이 없다.

http://geolite.maxmind.com/download/geoip/database/ 여기까지만 들어가보면 홈페이지가 바꼈다.

https://dev.maxmind.com/geoip/geoip2/geolite2/ 여기로 들어가진다.


geolite2가 나오면서 저 파일들도 없어지고 뭐 이것저것 한것같다.


그럼 어떡해야할까 우리는 설치하고싶은데 


http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz

http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip

위 두파일이 뭐로 대체됐는지 찾으면 되겠찌 ?

사실 가장 정확한 방법은 새로 변경된 geolite2 를 이용해 iptables에 적용을 해야하는데... 모르겠다. 어렵다


하여튼 다운로드 경로 들어가보면 아래 파일들이 보인다.


GeoLite2 City

GeoLite2 Country

GeoLite2 ASN (Autonomous System Number)


이중에서 시티는 말그대로 도시일꺼고 컨츄리는 나라일꺼고 ASN은 들어가보니까 sk 브로드밴드도 있고 kt도 있고한거보니까 통신사 넘버인듯


하여튼 GeoLite2 Country 이거 csv로 다운받는다.


-rw-r--r-- 1 root root 11734000 2019-02-13 07:08 GeoLite2-Country-Blocks-IPv4.csv

-rw-r--r-- 1 root root  3464092 2019-02-13 07:08 GeoLite2-Country-Blocks-IPv6.csv

-rw-r--r-- 1 root root     9864 2019-02-13 07:08 GeoLite2-Country-Locations-de.csv

-rw-r--r-- 1 root root     9937 2019-02-13 07:08 GeoLite2-Country-Locations-en.csv

-rw-r--r-- 1 root root     9992 2019-02-13 07:08 GeoLite2-Country-Locations-es.csv

-rw-r--r-- 1 root root    10230 2019-02-13 07:08 GeoLite2-Country-Locations-fr.csv

-rw-r--r-- 1 root root    14998 2019-02-13 07:08 GeoLite2-Country-Locations-ja.csv

-rw-r--r-- 1 root root    11422 2019-02-13 07:08 GeoLite2-Country-Locations-pt-BR.csv

-rw-r--r-- 1 root root    14932 2019-02-13 07:08 GeoLite2-Country-Locations-ru.csv

-rw-r--r-- 1 root root    11732 2019-02-13 07:08 GeoLite2-Country-Locations-zh-CN.csv


압축 풀어보면 이런식으로 나온다........... 안에 들어가보면 csv 양식이 바꼈따 ...... 흠


https://github.com/mschmitt/GeoLite2xtables

여기에 geolite2 를 기존 geolite .csv 로 컨버팅하는 스크립트가 있다. 요걸로 하면 잘된다 ㅋㅋ


하는방법은 아래와같다.

xt_geoip_dl 파일안의 내용을 
#########

#!/bin/bash


rm -rf GeoLite2-Country-CSV*


wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip

unzip -o -j GeoLite2-Country-CSV.zip '*/GeoLite2-Country-Blocks*'


wget http://download.geonames.org/export/dump/countryInfo.txt


cat GeoLite2-Country-Blocks-IPv{4,6}.csv | ./20_convert_geolite2 CountryInfo.txt > GeoIPCountry.csv

######

20_convert_geolite2 요것만 다운받아주고

ㄴperl 모듈 설치하라고 나오면 cpan -i NetAddr::IP 이거 하면된다.

위와같이 바꿔준다. 그리고 실행하면 된다.

나머지부터는 

check_function "./geoip/xt_geoip_build GeoIPCountry.csv"



mkdir -p /usr/share/xt_geoip

cp -r {BE,LE} /usr/share/xt_geoip/


이거 동일하게 하면됨


ps1.

"perl-Text-CSV_XS"는 쉼표(,)로 이루어진 값들을 구성하고, 분해하는 역할을 하는 패키지입니다. 엑셀 비슷하다고 보시면 됩니다.

"xtables-addons"는 커널/IPTables에서 제공하지 않는 기능을 추가적으로 지원해주는 Addons<확장팩(?) 비슷한 개념>입니다.


출처: https://sata.kr/entry/IPTables-12-IPTables에-GeoIP를-설치해보자-GeoIP-CentOS-6CentOS-7 [SATAz BLOG]

>> Real Server Group 1# cur

Current real server group 1:

  name , metric hash, backup none, realthr 0, ipver v4

  rmetric roundrobin, health tcp, content 

  DSR VIP health: enabled

  Workload Manager: none

  IDS Group: disabled  IDS rport: any   IDS flood: disabled

  Operation: enabled

  adv health: 

  real servers:

     1: 192.168.0.11, enabled, name , weight 1, timeout 10 mins, maxcon 200000

       group ena, backup none, inter 2, retry 4, restr 2

       remote disabled, proxy enabled, submac disabled

       fasthc enabled, subdmac enabled

       cookie assignment server: disabled

       exclusionary string matching: disabled

     2: 192.168.0.12, enabled, name , weight 1, timeout 10 mins, maxcon 200000

       group ena, backup none, inter 2, retry 4, restr 2

       remote disabled, proxy enabled, submac disabled

       fasthc enabled, subdmac enabled

       cookie assignment server: disabled

       exclusionary string matching: disabled

     3: 192.168.0.13, enabled, name , weight 1, timeout 10 mins, maxcon 200000

       group ena, backup none, inter 2, retry 4, restr 2

       remote disabled, proxy enabled, submac disabled

       fasthc enabled, subdmac enabled

       cookie assignment server: disabled

       exclusionary string matching: disabled

  real ports:

    4306: vport 4306, rtspslb none

      virtual server:  1, IP4 192.168.0.10,    enabled


L4 알테온 스위치에서 설정하면 메트릭은 뭔지 알겄는데 r메트릭은 뭐지 ?


metric은 뭐 말그대로 부하분산 방식 설정하는건데 구글링하면 겁내 많이 나온다.

근데 rmetric은 도대체 멀까 ? 


일단

     metric   - Set metric used to select next server in group

     rmetric  - Set metric used to select next rport in server(서버에서 다음 rport를 선택하는데 사용되는 메트릭을 설정)
라는데... 음 그렇군요


MariaDB [(none)]> SHOW ENGINE INNODB STATUS\G


latest detected deadlock 항목에서 데드락을 확인할 수 있다.

마지막에 발생한 deadlock만 확인된다. 

내용을 보면


------------------------

LATEST DETECTED DEADLOCK

------------------------

2019-01-24 04:00:03 7f2914242b00 ## 데드락 발생시간

*** (1) TRANSACTION:  ##첫번째 트랜잭션

TRANSACTION 47312201250, ACTIVE 0 sec fetching rows

mysql tables in use 3, locked 3

LOCK WAIT 266 lock struct(s), heap size 30248, 2129 row lock(s)

MySQL thread id 13168615, OS thread handle 0x7f28fac80b00, query id 120397240 192.168.0.213 root updating

UPDATE `TABLE` SET `rsInstall` = '123123', `rsOpen` = '123123'   ##쿼리내용

WHERE `rsToday` = '123123'

AND `rsAdmIdx` = '123123'

AND `rsAffIdx` = '3123123'

AND `rsAdsIdx` = '123123'

AND `rsSubAffIdx` = '1123123'

*** (1) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 9873 page no 170251 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201250 lock_mode X locks rec but not gap waiting lock hold time 0 wait time before grant 0     ##이부분이 지금 데드락에 빠진거고

*** (2) TRANSACTION:   ##두번째 트랜잭션

TRANSACTION 47312201244, ACTIVE 0 sec fetching rows

mysql tables in use 3, locked 3

241 lock struct(s), heap size 30248, 5827 row lock(s), undo log entries 22

MySQL thread id 13168659, OS thread handle 0x7f2914242b00, query id 120397235 192.168.0.213 root updating

UPDATE `TABLE` SET `rInstall` = '18123123, `rOpen` = '123123'   ##쿼리내용

WHERE `rsToday` = '123123'

AND `rsAdmIdx` = '123123'

AND `rsAffIdx` = '123123'

AND `rsAdsIdx` = '123213'

AND `rsSubAffIdx` = '123123'

*** (2) HOLDS THE LOCK(S):

RECORD LOCKS space id 9873 page no 170251 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201244 lock_mode X locks rec but not gap lock hold time 0 wait time before grant 0    ##여기도 데드락에 빠졌꼬 

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 9873 page no 170473 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201244 lock_mode X locks rec but not gap waiting lock hold time 0 wait time before grant 0    ##데드락을 해결하기위해 이부분이 롤백됨

*** WE ROLL BACK TRANSACTION (2)   


위 두개의 트랜잭션이 데드락에 빠졌꼬 이를 해결하기 위해 두번째 트랜잭션이 롤백됐음 을 확인할 수 있다.


음. 난 dba가 아니라서 이걸보고 그다음 뭘 어떠케 해줘야 하는지 모르겠네 그래도 일단 dba한테 알려는 줄 수 있는 se가 되자 

+ Recent posts