[기타] 구글 크롤링 관련 ( robots.txt – 스크랩)

로봇 배제 표준

위키백과, 우리 모두의 백과사전.

“Robots.txt”는 이 문서를 가리킵니다. 위키백과의 Robots.txt의 파일을 보실려면, 미디어위키:Robots.txt 와 ko.wikipedia.org/robots.txt를 참조하시길 바랍니다.

로봇 배제 표준은 웹 사이트에 로봇이 접근하는 것을 방지하기 위한 규약으로, 일반적으로 접근 제한에 대한 설명을 robots.txt에 기술한다.

이 규약은 1994년 6월에 처음 만들어졌고, 아직 이 규약에 대한 RFC는 없다.

이 규약은 권고안이며, 로봇이 robots.txt 파일을 읽고 접근을 중지하는 것을 목적으로 한다. 따라서, 접근 방지 설정을 하였다고 해도, 다른 사람들이 그 파일에 접근할 수 있다.

목차

[숨기기]

[편집]

만약 모든 로봇에게 문서 접근을 허락하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: *
Allow: /

모든 로봇을 차단하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: *
Disallow: /

모든 로봇에 세 디렉터리 접근을 차단하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /junk/

모든 로봇에 특정 파일 접근을 차단하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: *
Disallow: /directory/file.html

BadBot 로봇에 모든 파일 접근을 차단하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: BadBot
Disallow: /

BadBot 과 Googlebot 로봇에 특정 디렉터리 접근을 차단하려면, robots.txt에 다음과 같이 입력하면 된다.

User-agent: BadBot
User-agent: Googlebot
Disallow: /private/

다양하게 조합하여 사용 할 수 있다.

User-agent: googlebot        # googlebot 로봇만 적용
Disallow: /private/          # 이 디렉토리를 접근 차단한다.

User-agent: googlebot-news   # googlebot-news 로봇만 적용
Disallow: /                  # 모든 디렉토리를 접근 차단한다.

User-agent: *                # 모든 로봇 적용
Disallow: /something/        # 이 디렉토리를 접근 차단한다.

대안[편집]

HTML의 meta 태그를 이용할 수도 있다.

<meta name=”Robots” content=”Noindex,Nofollow” />

하지만 이러한 방법은 일반적인 방법이 아니고, 아직까지는 일부의 로봇만이 지원한다.

각주[편집]

 

바깥 고리[편집]

[기타] 신뢰할수 있는 루트 인증서 등록 하는 법

Mac OS X

Add

Use command:

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/new-root-certificate.crt

Remove

Use command:

sudo security delete-certificate -c “<name of existing certificate>”

Windows

Add

Use command:

certutil -addstore -f “ROOT” new-root-certificate.crt

Remove

Use command:

certutil -delstore “ROOT” serial-number-hex

Linux (Ubuntu, Debian)

Add

  1. Copy your CA to dir /usr/local/share/ca-certificates/
  2. Use command:

sudo cp foo.crt /usr/local/share/ca-certificates/foo.crt

  1. Update the CA store:

sudo update-ca-certificates

Remove

  1. Remove your CA.
  2. Update the CA store:

sudo update-ca-certificates –fresh

Restart Kerio Connect to reload the certificates in the 32-bit versions or Debian 7.

Linux (CentOs 6)

Add

  1. Install the ca-certificates package:

yum install ca-certificates

  1. Enable the dynamic CA configuration feature:

update-ca-trust force-enable

  1. Add it as a new file to /etc/pki/ca-trust/source/anchors/:

cp foo.crt /etc/pki/ca-trust/source/anchors/

  1. Use command:

update-ca-trust extract

Restart Kerio Connect to reload the certificates in the 32-bit version.

Linux (CentOs 5)

Add

Append your trusted certificate to file /etc/pki/tls/certs/ca-bundle.crt

cat foo.crt >> /etc/pki/tls/certs/ca-bundle.crt

Restart Kerio Connect to reload the certificates in the 32-bit version.

[linux] redis clustering (redis-trib 이용)

redis 3.0 이상 필요.

설치하고 난 뒤에 다음과 같이 redis.conf를 변경해줍니다.

daemonize yes

pidfile /var/run/redis.pid

port 6379

tcp-backlog 511

timeout 0

tcp-keepalive 0

loglevel notice

logfile “/services/log/redis/redis.log”

databases 16

save 900 1

save 300 10

save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes

rdbchecksum yes

dbfilename dump.rdb

dir /services/data/redis/

slave-serve-stale-data yes

slave-read-only yes

repl-diskless-sync no

repl-diskless-sync-delay 5

repl-disable-tcp-nodelay no

slave-priority 100

appendonly yes

appendfilename “appendonly.aof”

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

aof-load-truncated yes

lua-time-limit 5000

cluster-enabled yes

cluster-node-timeout 2000

cluster-slave-validity-factor 1

cluster-config-file nodes.conf

slowlog-log-slower-than 10000

slowlog-max-len 128

latency-monitor-threshold 0

notify-keyspace-events “”

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-entries 512

list-max-ziplist-value 64

set-max-intset-entries 512

zset-max-ziplist-entries 128

zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

activerehashing yes

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit slave 256mb 64mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes

그 다음 루비루비젬을 설치해주고, redis 를 설치해줘야 한다그래야 클러스터 관련 스크립트가 실행됨 (include redis)

yum install ruby rubygem

gem install –http-proxy http://10.10.10.100:8080 redis

이후 레디스 소스파일이 위치한 경로에 src 폴더안에 redis-trib.rb 를 이용하면된다.

명령어

for i in $(cat centos_redis30.txt);do ssh $i “hostname;yum install ruby rubygem -y”;done

for i in $(cat centos_redis30.txt);do ssh $i “hostname;gem install –http-proxy http://10.10.10.100:8080 redis “;done

설정파일은 master / slave 구분없이 동일하므로 scp로 넣어준다.

설정 파일 복사 후 적용을 위해서 service redis restart

그다음 1번 서버에서 다음과 같은 명령어를 날려준다.

echo yes | /services/src/redis-3.0.1/src/redis-trib.rb create –replicas 1 10.10.10.21:6379 10.10.10.22:6379 10.10.10.23:6379 10.10.10.24:6379 10.10.10.25:6379 10.10.10.26:6379

(클러스터링 및 리플리카를  M M M S S S 순으로 넣어줍니다. )

레디스 클러스터링에서는

사용 포트가 서비스포트 + 10000번이 자동 할당된다.

해당 포트를 통해서 redis clustering command 가 실행되며해당 포트를열지 않으면클러스터링이 안됨.

.

Redis-trib 사용법

Redis-trib 사용법

http://download.redis.io/redis-stable/src/redis-trib.rb

명령 설명

o    create   클러스터를 생성한다. replicas 지정해서 슬레이브 개수를 지정할  있다.

o    reshard   슬롯을 노드에 할당 또는 재할당한다. Source 노드와 destination 노드를 지정한다.

o    add-node   클러스터에 노드를 추가한다마스터 또는 슬레이브로 추가할  있다.

o    del-node   클러스터에서 노드를 제거한다.

redis-trib CREATE

o    클러스터를 생성한다.

o    명령   redis-trib.rb create [–replicas n] ip1:port1 … ipn:portn

o    –replicas n   마스터  슬레이브 노드를   만들지를 정한다.   생략하거나 0으로 설정하면 슬레이브 노드를 만들지 않고 마스터로만 클러스터를 구성한다.  

o    ip1:port1 … ipn:portn   클러스터에 참여할 레디스 노드들의 ip:port 입력한다.   명령을 실행하는 머신과 같은 ip 사용해도 ip 반드시 입력해야 한다.

o    Standalone mode 시작한 레디스는 클러스터에 참여할  없다.   지정한 ip:port  standalone mode Redis-trib 종료한다.

o    DB 데이터가 있으면 클러스터를 생성하지 못하고 종료한다.   그러므로 클러스터를 생성할 노드는 AOF  RDB 부터 데이터를 읽어들이면 안된다.   Cluster mode 시작한 레디스는 클러스터가 구성되지 않은 상태에서는 set 명령같은 데이터를 입력/수정/삭제/조회하는 명령을 수행할  없다.   하지만 Flushdb 또는 flushall 명령은 실행가능하다 명령을 실행해서 데이터를 모두 삭제했어도 클러스터는 구성되지 않는다처음부터 데이터를 읽어 들이지 않는 방법이 가장 좋다.

o    레디스 노드는 최소 3 이상을 지정해야 한다.   Replicas 0으로 지정하면 참여한 노드가 모두 마스터가 된다.   Replicas 1 지정하면 최소 마스터슬레이브 3쌍으로 구성되어 6노드 이상이 있어야 한다.   Cluster 명령을 직접 사용하면 이러한 제한은 없어서, 1 노드로도 클러스터를 만들  있다.

o    IP 같은 경우 클러스터 구성   IP 같으면 명령에 지정된 순서대로 마스터와 슬레이브가 정해진다.

o    다음과 같이 replicas 1 지정하고 5001부터 5006까지 포트를 지정하면 아래와 같이 구성된다.

$ src/redis-trib.rb create –replicas 1 127.0.0.1:5001 127.0.0.1:5002 127.0.0.1:5003 127.0.0.1:5004 127.0.0.1:5005 127.0.0.1:5006

설명: Redis Cluster Create redis_trib

o    replicas 2 지정하고 9 노드를 지정하면 다음과 같이 구성된다.

설명: Redis Cluster Create redis-trib replicas 2

o    3 IP 레디스 노드 2개씩 지정하고 replicas 1 하면 다음과 같이 구성된다.   세번째 박스(IP 105)  박스안에 마스터슬레이브가 구성되었으므로  박스가 다운되면 클러스터가 다운되는 상황이 된다.

설명: Redis Cluster Create redis_trib 3boxes 6nodes

o    redis-trib 클러스터 구성을   하려고 하지만완벽하지 않아서 위와 같은 상황이 발생할  있으므로세밀한 구성을 위해서는 클러스터 명령으로 직접 구성하는 것이 좋은 방법이다.

o    redis-trib create했을때 구성 형태에 대한 자세한 내용은 여기를 보세요.   레디스 클러스터 자동 구성 형태

o    다음은 6 노드로 마스터 3, 슬레이브 3으로 구성했을때 나오는 메시지이다.   redis 3.0.2 포한된 redis-trib.rb 실행한 것이다.    길지만 생략하지 않고 그대로 보여준다.

$ src/redis-trib.rb create –replicas 1 127.0.0.1:5001 127.0.0.1:5002 127.0.0.1:5003 127.0.0.1:5004 127.0.0.1:5005 127.0.0.1:5006

>>> Creating cluster

Connecting to node 127.0.0.1:5001: OK

Connecting to node 127.0.0.1:5002: OK

Connecting to node 127.0.0.1:5003: OK

Connecting to node 127.0.0.1:5004: OK

Connecting to node 127.0.0.1:5005: OK

Connecting to node 127.0.0.1:5006: OK

>>> Performing hash slots allocation on 6 nodes…

Using 3 masters:

127.0.0.1:5001

127.0.0.1:5002

127.0.0.1:5003

Adding replica 127.0.0.1:5004 to 127.0.0.1:5001

Adding replica 127.0.0.1:5005 to 127.0.0.1:5002

Adding replica 127.0.0.1:5006 to 127.0.0.1:5003

M: a2c1abd1e2db46fe31beed7e4d40f81cc8abe28d 127.0.0.1:5001

     slots:0-5460 (5461 slots) master

M: ed6274c72384c208154e9f06e3c40a7f893197f6 127.0.0.1:5002

     slots:5461-10922 (5462 slots) master

M: 4c385777933bf54eb0636ebe7bda4903e0da0ade 127.0.0.1:5003

     slots:10923-16383 (5461 slots) master

S: 813e57347d2de9f3a9f36f7846642a5732c1519e 127.0.0.1:5004

     replicates a2c1abd1e2db46fe31beed7e4d40f81cc8abe28d

S: cfd9827e915e79c4550afddad2b546c3d1298872 127.0.0.1:5005

     replicates ed6274c72384c208154e9f06e3c40a7f893197f6

S: d324144ecfb33f75ef5e90b47388423f0656ab95 127.0.0.1:5006

     replicates 4c385777933bf54eb0636ebe7bda4903e0da0ade

Can I set the above configuration? (type ‘yes’ to accept): yes

>>> Nodes configuration updated

>>> Assign a different config epoch to each node

>>> Sending CLUSTER MEET messages to join the cluster

Waiting for the cluster to join…

>>> Performing Cluster Check (using node 127.0.0.1:5001)

M: a2c1abd1e2db46fe31beed7e4d40f81cc8abe28d 127.0.0.1:5001

     slots:0-5460 (5461 slots) master

M: ed6274c72384c208154e9f06e3c40a7f893197f6 127.0.0.1:5002

     slots:5461-10922 (5462 slots) master

M: 4c385777933bf54eb0636ebe7bda4903e0da0ade 127.0.0.1:5003

     slots:10923-16383 (5461 slots) master

M: 813e57347d2de9f3a9f36f7846642a5732c1519e 127.0.0.1:5004

     slots: (0 slots) master

     replicates a2c1abd1e2db46fe31beed7e4d40f81cc8abe28d

M: cfd9827e915e79c4550afddad2b546c3d1298872 127.0.0.1:5005

     slots: (0 slots) master

     replicates ed6274c72384c208154e9f06e3c40a7f893197f6

M: d324144ecfb33f75ef5e90b47388423f0656ab95 127.0.0.1:5006

     slots: (0 slots) master

     replicates 4c385777933bf54eb0636ebe7bda4903e0da0ade

[OK] All nodes agree about slots configuration.

>>> Check for open slots…

>>> Check slots coverage…

[OK] All 16384 slots covered.

redis-trib RESHARD

o    슬롯을 재할당한다슬롯과 데이터를 같이 옮겨준다.

o    명령   redis-trib.rb reshard ip:port

o    ip:port 접속해서 작업할 노드이다. Reshard  source 노드나 destination 노드로 접속할 필요는 없다.

o    Reshard  노드를 추가했을때  노드에 슬롯을 할당하기 위해 사용하거나기존 노드의 슬롯을 다른 노드로 옮길때 사용한다.   Reshard 명령은 destination 노드로 데이터를 migrate 명령으로 옮긴다.

o    Source 노드는 1 이상 또는 모두를 지정할  있고, destination 노드는 하나만 지정한다.   옮길 슬롯의 개수를 지정한다특정 슬롯을 지정하거나 특정 범위를 지정할  없다.

o    다음은 reshard할때 나오는 메시지이다옮길 슬롯의 갯수만큼 메시지가 나오므로여기서는 5 슬롯만 지정했다.   Source node #1 에서 all 입력하면 모든 노드로 부터 슬롯을 받는다.   특정 노드 id 여러개 입력할  있다모두 입력했으면 done 입력한다.   Source node  Destination(Receiving) node 모두 마스터 노드만 지정해야 된다슬레이브 노드는 지정할  없다.   입력해야  부분은 굵게 표시했다.

redis-trib.rb reshard 127.0.0.1:5001

>>> Performing Cluster Check (using node 127.0.0.1:5001)

[OK] All nodes agree about slots configuration.

>>> Check for open slots…

>>> Check slots coverage…

[OK] All 16384 slots covered.

How many slots do you want to move (from 1 to 16384)? 5

What is the receiving node ID? 4c385777933bf54eb0636ebe7bda4903e0da0ade

Please enter all the source node IDs.

  Type ‘all’ to use all the nodes as source nodes for the hash slots.

  Type ‘done’ once you entered all the source nodes IDs.

Source node #1:a2c1abd1e2db46fe31beed7e4d40f81cc8abe28d

Source node #2:done

Ready to move 5 slots.

Do you want to proceed with the proposed reshard plan (yes/no)? yes

Moving slot 0 from 127.0.0.1:5001 to 127.0.0.1:5003:

Moving slot 1 from 127.0.0.1:5001 to 127.0.0.1:5003:

Moving slot 2 from 127.0.0.1:5001 to 127.0.0.1:5003:

Moving slot 3 from 127.0.0.1:5001 to 127.0.0.1:5003:

Moving slot 4 from 127.0.0.1:5001 to 127.0.0.1:5003:

redis-trib ADD-NODE

o    클러스터에 노드를 추가한다마스터 또는 슬레이브로 추가할  있다.

o    명령   redis-trib.rb add-node [–slave] [–master-id id] new_ip:port existing_ip:port

o    –slave    노드를 슬레이브로 추가할  사용한다지정하지 않으면 마스터로 추가된다.

o    –master-id id   slave 옵션을 사용했을때 마스터 노드 ID 지정한다생략할  있다생략하면 existing_ip:port 노드의 슬레이브가 된다.

o    new_ip:port   추가할 ip:port 지정한다. Cluster mode 시작되어 있어야 하고데이터가 없어야 한다.

o    existing_ip:port   접속해서 작업할 기존 노드를 지정한다.

o    다음은 5007 노드를 마스터로 클러스터에 등록하는 명령과 메시지이다.   중간에 입력해야 하는 것은 없다.   이후에 reshard 명령으로 슬롯을 할당해야 마스터로서 역할을 수행할  있다.

redis-trib.rb add-node 127.0.0.1:5007 127.0.0.1:5001

>>> Adding node 127.0.0.1:5007 to cluster 127.0.0.1:5001

>>> Performing Cluster Check (using node 127.0.0.1:5001)

[OK] All nodes agree about slots configuration.

>>> Check for open slots…

>>> Check slots coverage…

[OK] All 16384 slots covered.

Connecting to node 127.0.0.1:5007: OK

>>> Send CLUSTER MEET to node 127.0.0.1:5007 to make it join the cluster.

[OK] New node added correctly.

o    다음은 5007 노드를 5002 슬레이브로 등록하는 명령이다마지막에 다른 부분만 표시한다.  

redis-trib.rb add-node –slave 127.0.0.1:5007 127.0.0.1:5002

>>> Adding node 127.0.0.1:5007 to cluster 127.0.0.1:5002

….. 중간 생략 …..

[OK] All 16384 slots covered.

Automatically selected master 127.0.0.1:5002

Connecting to node 127.0.0.1:5007: OK

>>> Send CLUSTER MEET to node 127.0.0.1:5007 to make it join the cluster.

Waiting for the cluster to join.

>>> Configure node as replica of 127.0.0.1:5002.

[OK] New node added correctly.

o    다음은 master-id 옵션을 지정한 명령 예이다.

$ redis-trib.rb add-node –slave –master-id 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 127.0.0.1:5007 127.0.0.1:5001

redis-trib DEL-NODE

o    클러스터에서 노드를 제거한다.   슬롯이 할당되어 있으면 제거할  없다.   Reshard 명령으로 슬롯과 데이터를 다른 노드에 할당한  del-node 명령을 실행한다.   제거할 노드가 슬레이브면 reshard  필요없다.

o    명령   redis-trib.rb del-node ip:port node-id

o    ip:port   접속해서 작업할 노드를 지정한다.

o    node-id   제거할 노드 ID 지정한다.

o     명령은 마지막에 레디스 인스턴스를 shutdown 한다.

o    다운된 노드에 대해서는  명령을 실행할  없다.   왜냐하면  명령은 해당 노드에 접속해서 확인  진행하는데접속할  없기 때문이다.   이때는 redis-cli 접속해서 cluster forget node-id 명령으로 제거한다.

o    다음은 5001번에 접속해서 5007 노드를 제거하는 명령과 메시지다.

redis-trib.rb del-node 127.0.0.1:5001 b8b8b72fb2b5305ad63290bb1aa24cf81fce1bc2

>>> Removing node b8b8b72fb2b5305ad63290bb1aa24cf81fce1bc2 from cluster 127.0.0.1:5001

>>> Sending CLUSTER FORGET messages to the cluster…

>>> SHUTDOWN the node.

원본 위치 <http://www.redisgate.com/redis/cluster/redis-trib.php>

확인 작업

아래 생성된 슬롯수 및 ok가 일치하면 (클러스터링 개당 슬롯이 분리되어있음)

Nodes 수가 설정값과 일치하는지 known nodes 확인

Size 에서 클러스터링 값을 확인

[root@ip-10-24-20-62 redis]# redis-cli -h localhost

localhost:6379> cluster info

cluster_state:ok

cluster_slots_assigned:16384

cluster_slots_ok:16384

cluster_slots_pfail:0

cluster_slots_fail:0

cluster_known_nodes:6

cluster_size:3

cluster_current_epoch:6

cluster_my_epoch:4

cluster_stats_messages_sent:4481

cluster_stats_messages_received:4440

localhost:6379>

클러스터 노드수는 아래와 같이 확인

localhost:6379> cluster nodes

[python] django – web dev framework 기본 구성

Django Mysql로 설치

 

Pip install django

Pip install python-mysql

 

Django-admin startproject [프로젝트명]

 

Python manage.py help

 

먼저 mysql에 데이터베이스 셍성

생성된 프로젝트 settings.py 에 다음과 같이 데이터베이스를 mysql로 설정 (기본 sqlite3)

 

DATABASES = {

‘default’: {

‘ENGINE’: ‘django.db.backends.mysql’,

‘NAME’ : ‘HONGDB’,

‘USER’ : ‘사용자’,

‘PASSWORD’ : ‘비밀번호’,

‘HOST’ : ‘127.0.0.1’,

‘PORT’ : ‘3306’,

#’ENGINE’: ‘django.db.backends.sqlite3′,

#’NAME’: os.path.join(BASE_DIR, ‘db.sqlite3′),

}

}

 

Python manage.py migrate

디비 생성후

Python manage.py createsuperuser

슈퍼 유저 생성

 

프로젝트의 views.py 를 이용해서 해당 function을 이용하기 위해 import 를 해준다.

여기서 webapps는 나의 프로젝트명이고, views.py 는 그냥 내가 만들어준 function용 py다.

# sungho make views page

from webapps.views import index, sungho

 

Url 패턴 입력시 인덱스 및 특정 펑션 설정을 해준다.

urlpatterns = [

url(r’^admin/’, admin.site.urls),

url(r’^$’, index),  #add index

url(r’^sungho/’, sungho), #add sungho

]

 

Views.py

from django.http import HttpResponse

def index(request):

return HttpResponse(“Index Page”)

def sungho(request):

return HttpResponse(“Hello My Name is sungho”)

 

Django의 http를 이용해 response를 설정해준다.

위에서는 간단하게 스트링을 리턴하여, 화면에 출력하는 용도로 만들었음.

 

 

다음..

 

mysql> grant all privileges on sungho.* to ‘nic2hong’@’127.0.0.1′ identified by ’12Tjdgh#$’;

Query OK, 0 rows affected, 1 warning (0.01 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

 

 

[MySQL] validate_password Plugin

Mysql_secure_installation 을 하려는 도중, 암호화 적용 법칙이 맞지 않아, 암호 설정이 빈번하게 실패한다.

암호 복잡성 요구를 확인해본다.

 

 

mysql> show global variables like ‘%vali%’;

+————————————–+——–+

| Variable_name                        | Value  |

+————————————–+——–+

| query_cache_wlock_invalidate         | OFF    |

| validate_password_dictionary_file    |        |

| validate_password_length             | 8      |

| validate_password_mixed_case_count   | 1      |

| validate_password_number_count       | 1      |

| validate_password_policy             | MEDIUM |

| validate_password_special_char_count | 1      |

+————————————–+——–+

7 rows in set (0.00 sec)

 

위 내용 중 암호에서 특수문자를 입력하고 싶지 않아, 아래와 같이 변경하였다.

 

mysql> set global validate_password_special_char_count=0;

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

이후 적용 상황은 암호에 특문이 없기 때문에 8자 이상, 대소문자 및 숫자만 포함하면 되도록 해놨음.

 

Global 변수는 데이터베이스 영향없이 공통설정이므로, 루트 권한으로 바로 실행하고 적용하면 된다.

 

 

 

[aws] S3 버킷 접근 제한 (IAM – policy 이용)

아래와 같이 폴리시를 생성하여 유저에 attach 시킴

{

    “Version”: “2012-10-17”,

    “Statement”: [

        {

            “Effect”: “Allow”,

            “Action”: “s3:*”,

            “Resource”: [

                “arn:aws:s3:::버킷1”,

                “arn:aws:s3:::버킷1/*”,

                “arn:aws:s3:::버킷2”,

                “arn:aws:s3:::버킷2/*”

            ]

        }

        ]

}

위 예제에 사용되는 형태는 Json type이며, 버킷1 과 버킷2 의 접근을 허용함

[linux] BASE64 Encode / Decode 손쉽게 이용하기

 

Php를 이용해서 아래와 같이 편하게 할 수 있음

#!/bin/bash -e

INPUT=$1;

 

if [ -z $INPUT ];

then

echo ” Input your encoding Plain text”

else

php -r “echo base64_encode($INPUT);”;

echo “\n”;

fi

 

 

예전엔, 이렇게 openssl을 이용했엇따.

 

[root@jinstalk ~]# printf “mail.shhong” | openssl base64

bWFpbC5zaGhvbmc=

 

Decode는 해당 openssl을 이용해서 이런식으로 가능합니다.

#!/bin/bash -e

INPUT=$1;

 

if [ -z $INPUT ];

then

echo ” Input your decoding Base64Encoded text”

else

echo $INPUT | openssl base64 -d;

echo “”;

fi

 

[linux] RPM BUILD 환경 구성하기

#RPM BUILD INSTALL

yum install rpm-build

yum install redhat-rpm-config

#STATUS FOR RPM-BUILD

rpm -qs rpm-build

#Environment for BUILD

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

# rpm 설치시 /etc/rpm/macro.dist 설정

#아래 매크로는 따로 설정하지 않아도 동작함.

echo ‘%_topdir %(echo $HOME)/rpmbuild’ > ~/.rpmmacros

#COMPILER Install

yum install make gcc

# 쌘트 6에서 공식 지원하는건 gcc 4.4

# RH 프로젝트를 통해서 비공식적으로 파이선 2.7 버전과, gcc 4.8을 Virtual ENV 형태로 제공 받을 수 있음.

[aws] sriov (enhanced network enable)

aws –profile sungho ec2 modify-instance-attribute –instance-id i-ab1234cd –sriov-net-support simple

 

 

aws ec2 describe-instance-attribute –instance-id i-ab1234cd –attribute sriovNetSupport

——————————

|  DescribeInstanceAttribute |

+————-+————–+

|  InstanceId |  i-ab1234cd  |

+————-+————–+

aws ec2 modify-instance-attribute –instance-id i-ab1234cd –sriov-net-support simple

###      적용 시 아무 메시지도 나타나지 않는다!    ###

aws ec2 describe-instance-attribute –instance-id i-ab1234cd –attribute sriovNetSupport

——————————

|  DescribeInstanceAttribute |

+————-+————–+

|  InstanceId |  i-ab1234cd  |

+————-+————–+

||      SriovNetSupport     ||

|+———–+————–+|

||  Value    |  simple      ||

|+———–+————–+|

[root@ip-10-11-20-10 temp_aws_scripts_make_instance]#

 

 

 

 

해당 이미지를 통해 생성한 AMI에서는 아래와 같은 명령어를 통해서 적용 여부를 확인할 수 있다.

aws ec2 describe-image-attribute –image-id ami-ab1234cd –attribute sriovNetSupport

—————————–

|  DescribeImageAttribute   |

+———-+—————-+

|  ImageId |  ami-ab1234cd  |

+———-+—————-+

||     SriovNetSupport     ||

|+———–+————-+|

||  Value    |  simple     ||

|+———–+————-+|

 

[nginx] best performance tuning _config & kernel param

nginx.conf

# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn’t benefit from more than one worker per CPU.)
worker_processes 24;

# Number of file descriptors used for Nginx. This is set in the OS with ‘ulimit -n 200000’
# or using /etc/security/limits.conf
worker_rlimit_nofile 200000;

# only log critical errors
error_log /var/log/nginx/error.log crit

# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# “Max clients” is also limited by the number of socket connections available on the system (~64k)
worker_connections 4000;

# essential for linux, optmized to serve many clients with each thread
use epoll;

# Accept as many connections as possible, after nginx gets notification about a new connection.
# May flood worker_connections, if that option is set too low.
multi_accept on;

# Caches information about open FDs, freqently accessed files.
# Changing this setting, in my environment, brought performance up from 560k req/sec, to 904k req/sec.
# I recommend using some varient of these options, though not the specific values listed below.
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

# Buffer log writes to speed up IO, or disable them altogether
#access_log /var/log/nginx/access.log main buffer=16k;
access_log off;

# Sendfile copies data between one FD and other from within the kernel.
# More efficient than read() + write(), since the requires transferring data to and from the user space.
sendfile on;

# Tcp_nopush causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames. This is useful for prepending headers before calling sendfile,
# or for throughput optimization.
tcp_nopush on;

# don’t buffer data-sends (disable Nagle algorithm). Good for sending frequent small bursts of data in real time.
tcp_nodelay on;

# Timeout for keep-alive connections. Server will close connections after this time.
keepalive_timeout 30;

# Number of requests a client can make over the keep-alive connection. This is set high for testing.
keepalive_requests 100000;

# allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
reset_timedout_connection on;

# send the client a “request timed out” if the body is not loaded by this time. Default 60.
client_body_timeout 10;

# If the client stops reading data, free up the stale client connection after this much time. Default 60.
send_timeout 2;

# Compression. Reduces the amount of data that needs to be transferred over the network
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable “MSIE [1-6]\.”;

sysctl.conf

# Increase system IP port limits to allow for more connections

net.ipv4.ip_local_port_range = 2000 65000

net.ipv4.tcp_window_scaling = 1

# number of packets to keep in backlog before the kernel starts dropping them
net.ipv4.tcp_max_syn_backlog = 3240000

# increase socket listen backlog
net.core.somaxconn = 3240000
net.ipv4.tcp_max_tw_buckets = 1440000

# Increase TCP buffer sizes
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_congestion_control = cubic