[컴] 오브젝트 스토리지(Object Storage)

백업 방법 /  여러리즌으로 / back up / 운용 / 주기적인 백업 / object storage

오브젝트 스토리지(Object Storage)

  • 아마존의 심플 스토리지 서비스(Simple Storage Service, S3)
  • 애저의 블롭 스토어
  • 구글의 클라우드 스토리지

Object storage System

계층적 디렉토리 및 서브디렉토리 구조가 없는 일종의 파일 시스템
  • 오브젝트 스토리지 시스템에 저장된 모든 오브젝트는 콘텐츠에 따라 고유 식별자(Unique IDentifier, UID)가 주어진다.
  • 보통 uid 는 SHA-1 같은 hash algorithm 응 이용해서 만든다.

오브젝트 스토리지와 블록 스토리지 간의 큰 차이

  • 오브젝트 스토리지에 저장된 모든 오브젝트는 최소한 3곳의 가용 구역으로 자동으로 복사된다
  • 오브젝트 단위로 복제를 한다.
    • 클라우드 블록 스토리지 및 보편적 RAID 시스템은 블록 수준에서 복제가 이루어진다.
  • 오브젝트는 절대로 변경되지 않는다. (위키의 편집같은 것을 생각해보자.)
    • 오브젝트가 변경되어야 한다면 그냥 새 오브젝트로 저장
    • 버전 분류가 지원된다면 이전 오브젝트 버전은 역사적 목적으로 저장
  • 오브젝트 스토리지는 위해를 끼칠 수 있는 여러 원인을 방어하는 여러 보호 수준을 자동으로 포함
  • 선택적인 WORM(Write-Once-Read-Many) 보호
  • 교차-지역 복제 등 이용 가능한 모든 베스트 프랙티스를 준수
  • 오브젝트 스토리지가 여전히 오류를 범할 수 있는 인간에 의해 작성 –> 오브젝트 스토리지 내 데이터가 미션 크리티컬이라면 백업하는 것이 적절

다른 백업 서비스 이용

  • AWS 글레이저 딥 아카이브
  • 애저 아카이브 스토리지
  • 구글 콜드라인
  • 상이한 계정 및 지역 을 이용해야 한다.

블록 볼륨 백업

  • 블록 볼륨은 백업해야 한다.
  • 스스로 이들을 백업.
  • 블록 스토리지 스냅샷
    • 다른 지역 및 계정으로 복제

오브젝트 스토리지 백업

  • 오브젝트 스토리지는 여러 가용 구역으로 복제가 자동으로 이루어진다.
  • 하지만 완벽이란 없다 –> 필요하다고 판단되면 백업을 해라.

See Also

  1. 백업 방식들

Reference

[컴] GSMA IMEI Database

imei blacklist / IMEI 블랙 리스트 / 도난 당한 폰 / 폰 도난 방지 시스템 / 중고 / 해외에 중고로 판대

GSMA IMEI Database

GSMA 가 International Mobile Equipment Identity Database (IMEI Db) 로 알려진 유일한 시스템을 유지보수한다.

블랙리스트에 올라간 IMEI 들이 GSMA 중앙 IMEI DB 에 제공된다. 그러면 이 DB를 이용해서 통신업자들이 국제, 국내망 여러 네트워크에서 그 기기를 block 할 수 있다.

하지만, 이것은 완전하진 않다. ref.2 에서 이야기하듯이 IMEI 값은 변경이 가능하다.

GSMA IMEI DB 에 기록하는 정보

IMEI 는 15자리의 숫자이며, 모바일 네트워크에서 기기를 구분하기 위해 사용된다.

IMEI DB에는 “3GPP 를 따르는 기기들” 제조사들의 모든 공식적인 기기들의 정보를 기록한다.
  • IMEI 번호 : “3GPP 를 따르는 기기들” 제조사들의 모든 공식적인
  • 제조사 이름
  • 모델이름
  • 주요 네트워크 능력(주파수 대역, 기기타입 등)

References

  1. GSMA IMEI Blacklisting - Services
  2. International Mobile Equipment Identity - Wikipedia

[컴][웹] Spring 의 thread 관련 정보

annotation / 어노테이션 /

Spring 의 thread 관련

@ControllerAdvice

기본적으로 @ControllerAdvice 는 모든 controller 에서 접근가능하다.

@ModelAttribute

@ModelAttribute@RequestMapping 이전에 실행된다.

AsyncConfigurer class

AsyncConfigurer 를 상속하고, @EnableAsync anootation 을 사용해서, the Executor instance 를 customize 할 수 있다.
Executor instance 는 async method 를 호출을 처리 한다(thread 를 만들어서 처리한다.). 주로 AsyncConfigurerSupport 를 사용하면 된다.

예시

@Configuration
@EnableAsync(proxyTargetClass = true)
@EnableScheduling
public class AsyncConfiguration extends AsyncConfigurerSupport {

    // `@Autowired` 에 의해 `threadPoolTaskExecutor` 에 bind 된다.?
    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
    ...

    // 그래서 `@Resource(name = "secondThreadRun")` 에 의해서 
    // `secondThreadRun` 에 bind 된다. 이때 `secondThreadRun` 은
    // `ApplicationContextTestResourceNameType application context` 에
    // define 되어야 한다.
    @Resource(name = "secondThread")
    private ThreadPoolTaskExecutor secondThread;

    @Override
    public Executor getAsyncExecutor() {
        return threadPoolTaskExecutor;
    }

    ...
    @Bean(destroyMethod = "shutdown")
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        // `@Bean` 을 creation 을 하고, `threadPoolTaskExecutor` 이름으로
        // Bean 이 하나 생성되고, 
        // 이것이 `@Autowired` 에 의해 `threadPoolTaskExecutor` 에 bind 된다.?
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(50);
        executor.setThreadNamePrefix("mythread-");
        executor.initialize();

        return executor;
    }

    /**
     * `createSecondThreadPool` 의 bean 은 `secondThread` 라는 이름으로 생성된다.
     *
     * @return
     */
    @Bean(name = "secondThread")
    @Qualifier
    public Executor createSecondThreadPool() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(TASK_BATCH_CORE_POOL_SIZE);
        executor.setMaxPoolSize(TASK_BATCH_MAX_POOL_SIZE);
        executor.setQueueCapacity(TASK_BATCH_QUEUE_CAPACITY);
        executor.setBeanName(EXECUTOR_BATCH_BEAN_NAME);
        executor.initialize();
        return executor;
    }
}
@Service
public class NhBatchThreadRun {
    ...
    @Autowired
    MyService1 myService1;
    @Autowired
    MyService2 myService2;

    /**
     * `@Async("secondThread")` 는 `secondThread` 라는 
     * name 의 bean 을 이용한다. 
     * 이 bean 은 configuration class 에 정의되어 있어야 한다. 
     * (`AsyncConfiguration.createSecondThreadPool` 를 확인하자.)
     * 
     * `secondThread` executor 가 `secondThreadRun` 를 실행하게 된다.
     * 
     * @ref: [How To Do @Async in Spring | Baeldung](https://www.baeldung.com/spring-async)
     *
     * @param str
     */
    @Async("secondThread")
    public void secondThreadRun(String str) {

        logger.debug("THREAD START!!!");
        // batch Start!!
        try {
            while(!Thread.interrupted()) {
                logger.debug("THREAD ING!!!! "+new Date().toString());
                myService1.send();
                myService2.insertIntoDB();
                ...
                Thread.sleep(1000 * 5);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        logger.debug("THREAD END!!!!");
    }
}

See Also

  1. java - stopping ExecutorService Threads in Tomcat - Stack Overflow





[컴] AI 관련 많이 언급되는 사람들

artificial intelligence / machine learning / ml / 인공지능 guru /

AI 관련 많이 언급되는 사람들

  1. Noam Chomsky: Noam Chomsky Explains Where Artificial Intelligence Went Wrong | Open Culture
  2. John McCarthy: John McCarthy (computer scientist) - Wikipedia
  3. Marvin Minsky: Marvin Minsky, Pioneer in Artificial Intelligence, Dies at 88 - The New York Times
  4. Allen Newell: Allen Newell - Wikipedia
  5. Ray Kurzweil: Predictions made by Ray Kurzweil - Wikipedia
  6. Andew Ng : Baidu’s Andrew Ng On the Future of Artificial Intelligence | Time

deep learning

  1. Geoffrey Hinton: The Godfather of AI Was Almost a Carpenter - Bloomberg
  2. Yann LeCun: Yann LeCun - Wikipedia
  3. Yoshua Bengio: Yoshua Bengio - Wikipedia

Reference

  1. Who are the "godfathers of AI"? | | The Frase Blog

[컴] VPN 선택시 참고할 만한 글

vpn / virtual private network / 선택 /

vpn 추천


  1. 유료 VPN 추천해주세요 - 인터넷 / 소프트웨어 - 기글하드웨어
  2. (IP우회) 무료,유료 VPN 추천 가성비, 속도 비교 | Net x Hack
  3. 한국 경찰 검찰이 ExpressVPN IP추적 못하는 이유 | Net x Hack
  4. 가장 안전하고 속도 빠른 1위 Express VPN(테스트 결과) | Net x Hack

[컴] gif 관련 도구

짤 / 동영상 소스 / gif 검색 / gif 소스 / 이미지 도구 / 움직이는 이미지

gif 관련 tools

gif 관련 도구, 앱, 어플, 사이트 등


[컴][리눅스] 방화벽 iptables 사용법

iptables / iptable / table / firewall / 방화벽
정리중…
vi 로 /etc/sysconfig/iptables 를 수정해도 된다. 하지만 좋은 방법인지는 모르겠다.

iptables 현재 상태 확인

iptables -S

-S 는 specification 을 뜻한다.
iptables -S 를 하면 어떤 식으로 iptables 이 설정됐는지 보인다.
$ iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -s 127.0.0.1/32 -p tcp -m tcp --dport 22 -j DROP
-A INPUT -s 127.0.0.1/32 -p tcp -m tcp --dport 21 -j DROP
-A INPUT -i eth1 -j ACCEPT
-A INPUT -i tun0 -j ACCEPT
-A INPUT -s 192.168.21.1/32 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -s 203.133.167.16/24 -j ACCEPT

iptables -L -n --line-numbers

아래처럼 간략하게 볼 수 있다.
$ iptables -L -n --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source destination
1    DROP       tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:22
2    DROP       tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:21
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
5    ACCEPT     all  --  203.133.167.16/24    0.0.0.0/0
27   DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22

Chain FORWARD (policy ACCEPT)
num  target     prot opt source destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source destination

-P 옵션

iptables -P INPUT ACCEPT
policy 설정 , target 은 INPUT, FORWARD, OUTPUT 등 의 built-in chain 만이 가능하다. 자세한 것은 ref.1 을 보자.

-A 옵션

append 이다. 현재 있는 rule 들 뒤에 추가(append) 하는 것이다. -A INPUT 하면 INPUT chain 에 append 하는 것이다.
# INPUT chain 에 다음 rule 을 append 해라 - interface eth1 을 ACCEPT 로 jump 해라.
iptables -A INPUT -i eth1 -j ACCEPT

-j 옵션

jum 를 뜻한다. 정해놓은 rule 에 대해 target(ACCEPT, DROP) 을 정해준다. “target 으로 jump 해라.” 정도로 기억하면 된다.
iptables -A INPUT -s 192.168.21.1/32 -j ACCEPT

-D 옵션

특정 rule 을 지울 때 사용한다.
# INPUT chain 에 있는 녀석을 지워라 - 10 번째 있는 rule
iptables -D INPUT 10

-I 옵션

rule 들이 정해진 순서대로 적용된다. 그래서 먼저 적용돼야 하는 것들은 위쪽에 넣어야 한다.
# INPUT 1 위치에 다음 rule을 insert 한다. - protocol 이 tcp 이고 port 가 80 인 녀석을 ACCEPT 로 jump 한다.
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT


DB 연결관련 iptable 설정

db 연결에 있어서 iptables 를 사용할 때 만약 아래와 같은 경우라면, 그냥 MySQL 의 inbound 만 열어주면 된다. (?)

Apache ---> MySQL
  • 모든 OUTPUT 은 열고,
  • INPUT 에서 DB쪽은 server 의 ipaddress 를 추가
  • INPUT 에서 server 쪽은 DB 의 ipaddress 를 추가


참고 예제

아래는 ref. 4 에서 가져온 내용이다. 참고하자.


#!/bin/bash

# setup basic chains and allow all or we might get locked out while the rules are running...
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# clear rules
iptables -F

# allow HTTP inbound and replies
iptables -A INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

# allow HTTPS inbound and replies
iptables -A INPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT

# limit ssh connects to 10 every 10 seconds
# change the port 22 if ssh is listening on a different port (which it should be)
# in the instance's AWS Security Group, you should limit SSH access to just your IP
# however, this will severely impede a password crack attempt should the SG rule be misconfigured
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 10 --hitcount 10 -j DROP

# allow SSH inbound and replies
# change the port 22 if ssh is listening on a different port (which it should be)
iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

# root can initiate HTTP outbound (for yum)
iptables -A OUTPUT -p tcp --dport 80 -m owner --uid-owner root -m state --state NEW,ESTABLISHED -j ACCEPT
# anyone can receive replies (ok since connections can't be initiated)
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

# root can do DNS searches (if your Subnet is 10.0.0.0/24 AWS DNS seems to be on 10.0.0.2)
# if your subnet is different, change 10.0.0.2 to your value (eg a 172.31.1.0/24 Subnet would be 172.31.1.2)
# see http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html
# DNS = start subnet range "plus two"
iptables -A OUTPUT -p udp --dport 53 -m owner --uid-owner root -d 10.0.0.2/32 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -s 10.0.0.2/32 -j ACCEPT

# apache user can talk to rds server on 10.0.0.200:3306
iptables -A OUTPUT -p tcp --dport 3306 -m owner --uid-owner apache -d 10.0.0.200 -j ACCEPT
iptables -A INPUT -p tcp --sport 3306 -s 10.0.0.200 -j ACCEPT

# now drop everything else
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# save config
/sbin/service iptables save

See Aslo

  1. linux - Using iptables to redirect traffic to a dynamic DNS name instead of an IP address? - Super User : iptables 에서 DNS 설정이 안되는 이유

References

  1. iptables(8) - Linux man page
  2. How to list all iptables rules with line numbers on Linux - nixCraft
  3. How to edit iptables rules - Fedora Project Wiki
  4. How to Configure iptables on an AWS Instance | QuickStepApps