리눅스 UnixBench 설치 및 테스트



gcc 와 perl 은 이미 설치되어 있다면 안해도 된다.


yum -y install gcc perl

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/byte-unixbench/UnixBench5.1.3.tgz

tar zxvf UnixBench5.1.3.tgz

cd UnixBench

make



아래는 디지털오션의 제일 저렴한 상품 VPS에서 테스트 한 결과이다.


[root@ocean-20 UnixBench]# ./Run

make all

make[1]: Entering directory `/root/UnixBench'

Checking distribution of files

./pgms  exists

./src  exists

./testdir  exists

./tmp  exists

./results  exists

make[1]: Leaving directory `/root/UnixBench'

sh: 3dinfo: command not found


   #    #  #    #  #  #    #          #####   ######  #    #   ####   #    #

   #    #  ##   #  #   #  #           #    #  #       ##   #  #    #  #    #

   #    #  # #  #  #    ##            #####   #####   # #  #  #       ######

   #    #  #  # #  #    ##            #    #  #       #  # #  #       #    #

   #    #  #   ##  #   #  #           #    #  #       #   ##  #    #  #    #

    ####   #    #  #  #    #          #####   ######  #    #   ####   #    #


   Version 5.1.3                      Based on the Byte Magazine Unix Benchmark


   Multi-CPU version                  Version 5 revisions by Ian Smith,

                                      Sunnyvale, CA, USA

   January 13, 2011                   johantheghost at yahoo period com



1 x Dhrystone 2 using register variables  1 2 3 4 5 6 7 8 9 10


1 x Double-Precision Whetstone  1 2 3 4 5 6 7 8 9 10


1 x Execl Throughput  1 2 3


1 x File Copy 1024 bufsize 2000 maxblocks  1 2 3


1 x File Copy 256 bufsize 500 maxblocks  1 2 3


1 x File Copy 4096 bufsize 8000 maxblocks  1 2 3


1 x Pipe Throughput  1 2 3 4 5 6 7 8 9 10


1 x Pipe-based Context Switching  1 2 3 4 5 6 7 8 9 10


1 x Process Creation  1 2 3


1 x System Call Overhead  1 2 3 4 5 6 7 8 9 10


1 x Shell Scripts (1 concurrent)  1 2 3


1 x Shell Scripts (8 concurrent)  1 2 3


========================================================================

   BYTE UNIX Benchmarks (Version 5.1.3)


   System: ocean.ivps.kr: GNU/Linux

   OS: GNU/Linux -- 3.10.0-327.18.2.el7.x86_64 -- #1 SMP Thu May 12 11:03:55 UTC 2016

   Machine: x86_64 (x86_64)

   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")

   CPU 0: Intel(R) Xeon(R) CPU E5-2630L 0 @ 2.00GHz (4000.0 bogomips)

          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization

   03:09:31 up 53 min,  1 user,  load average: 0.42, 0.12, 0.08; runlevel 3


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

Benchmark Run: Fri Jun 03 2016 03:09:31 - 03:37:28

1 CPU in system; running 1 parallel copy of tests


Dhrystone 2 using register variables       22474827.9 lps   (10.0 s, 7 samples)

Double-Precision Whetstone                     2926.3 MWIPS (9.3 s, 7 samples)

Execl Throughput                               2833.8 lps   (29.9 s, 2 samples)

File Copy 1024 bufsize 2000 maxblocks        595433.6 KBps  (30.0 s, 2 samples)

File Copy 256 bufsize 500 maxblocks          162140.4 KBps  (30.0 s, 2 samples)

File Copy 4096 bufsize 8000 maxblocks       1269635.0 KBps  (30.0 s, 2 samples)

Pipe Throughput                             1174541.2 lps   (10.0 s, 7 samples)

Pipe-based Context Switching                 207180.0 lps   (10.0 s, 7 samples)

Process Creation                               8227.0 lps   (30.0 s, 2 samples)

Shell Scripts (1 concurrent)                   3788.7 lpm   (60.0 s, 2 samples)

Shell Scripts (8 concurrent)                    509.5 lpm   (60.1 s, 2 samples)

System Call Overhead                        1660908.5 lps   (10.0 s, 7 samples)


System Benchmarks Index Values               BASELINE       RESULT    INDEX

Dhrystone 2 using register variables         116700.0   22474827.9   1925.9

Double-Precision Whetstone                       55.0       2926.3    532.0

Execl Throughput                                 43.0       2833.8    659.0

File Copy 1024 bufsize 2000 maxblocks          3960.0     595433.6   1503.6

File Copy 256 bufsize 500 maxblocks            1655.0     162140.4    979.7

File Copy 4096 bufsize 8000 maxblocks          5800.0    1269635.0   2189.0

Pipe Throughput                               12440.0    1174541.2    944.2

Pipe-based Context Switching                   4000.0     207180.0    517.9

Process Creation                                126.0       8227.0    652.9

Shell Scripts (1 concurrent)                     42.4       3788.7    893.6

Shell Scripts (8 concurrent)                      6.0        509.5    849.2

System Call Overhead                          15000.0    1660908.5   1107.3

                                                                   ========

System Benchmarks Index Score                                         956.2


디지털오션 Intel(R) Xeon(R) CPU E5-2630L 0 @ 2.00GHz 인데 생각보다 점수가 낮게 나왔다.


v2 2.40GHz 는 944.1점



ConoHa DigitalOcean Linode Vultr 벤치마크 테스트 결과보기 https://ivps.tistory.com/85


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 Proxy balancer 를 이용한 로드밸런싱



Apache 모듈 중에 mod_proxy_balancer 를 이용해서 로드밸런싱이 가능하다.


아래 예제는 /test 라는 경로가 지정되었지만 루트라도 관계가 없다.


loadfactor 는 가중치이다. 이 수치를 이용해서 특정 서버로 부하를 더 분산할 수도 있다.


   <IfModule mod_proxy_balancer.c>

        ProxyPass               /test       balancer://mycluster

        ProxyPassReverse        /test       balancer://mycluster

        <Proxy balancer://mycluster>

            BalancerMember http://www1.example.com/test loadfactor=25

            BalancerMember http://www2.example.com/test loadfactor=25

            BalancerMember http://www3.example.com/test loadfactor=25

            BalancerMember http://www4.example.com/test loadfactor=25

            ProxySet lbmethod=byrequests

        </Proxy>

    </IfModule>


단순 컨텐츠는 효과가 없을 듯 하고 프로그래밍 같은 경우에는 효과가 있을 것 같다.


정적인 컨텐츠는 mod_cache 를 활용하는게 더 효과적일 것 같다.


아니면 앞단의 장비에서 로드밸런싱을 하는게 낫지 않을까 싶다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

해외 VPS 11종 1TB 트래픽 기준 비교



이번에는 Traffic 1TB 기준으로 정리해봤습니다. 2TB 기준은 http://itrooms.tistory.com/160 여기를 참고.


아래의 가상서버호스팅 중에서 직접 사용해 본 곳은 ConoHa, DigitalOcean, Vultr 세군데 입니다.


Core

RAM

Storage

Traffic

Network In/Out

Price

Virtualization

Remark

BeastNode

1

512MB

25GB SSD

1TB

1Gb/s

5 USD

OpenVZ

RAID-10

ChicagoVPS

1

512MB

20GB SHDD

1TB

1Gb/s

4.5 USD

OpenVZ

ChicagoVPS

1

1GB

35GB HDD

1TB

1Gb/s

6.95 USD

KVM

ConoHa

2

1GB

50GB SSD

Unlimited

100Mb/s

900 JPY

KVM

Contabo

2

6GB

500GB SHDD

Unlimited

100Mb/s

7.99 EUR

KVM

Contabo

2

8GB

200GB SSD

Unlimited

100Mb/s

9.99 EUR

KVM

DigitalOcean

1

512MB

20GB SSD

1TB

1Gb/s

5 USD

KVM

RAID

FTPit

2

512MB

30GB HDD

1TB

100Mb/s

1.99 USD

OpenVZ

VPS1

FTPit

2

512MB

10GB SDD

1TB

100Mb/s

2.99 USD

OpenVZ

SSD1

FTPit

2

512MB

50GB HDD

1TB

100Mb/s

4.99 USD

KVM

KVM1

HostUS

2

1GB

50GB HDD

1TB

1Gb/s

4.95 USD

OpenVZ

HostUS

2

1GB

45GB HDD

1TB

1Gb/s

7.95 USD

KVM

RAID-10 / SSD

Openvirtuals

1

256MB

90GB SHDD

1TB

1Gb/s

4 USD

OpenVZ

Openvirtuals

1

256MB

5GB SSD+10GB HDD

1TB

1Gb/s

4 USD

OpenVZ

Combo

RackBurst

4

1GB

40GB SSD SuperFast

1TB

Unknown

3.29 EUR

OpenVZ

RAID-10, UK

RackBurst

4

1GB

60GB SSD Standard

1TB

Unknown

3.29 EUR

OpenVZ

RAID-10, UK

RackBurst

4

1GB

40GB SSD SuperFast

1TB

1Gb/s

3.99 EUR

OpenVZ

RAID-10, Germany

RackBurst

4

1GB

60GB SSD Standard

1TB

1Gb/s

3.99 EUR

OpenVZ

RAID-10, Germany

RamNode

1

256MB

25GB SSD

1TB

1Gb/s

8 USD / QTR

OpenVZ

RamNode

1

512MB

40GB SSD

1TB

1Gb/s

3.5 USD

OpenVZ

RamNode

1

256MB

120GB SHDD

1TB

1Gb/s

8 USD / QTR

OpenVZ

RamNode

1

256MB

8GB SSD

1TB

1Gb/s

3.5 USD

KVM

RamNode

1

512MB

10GB SSD

1TB

1Gb/s

5 USD

KVM

RamNode

1

256MB

30GB SHDD

1TB

1Gb/s

3.5 USD

KVM

Vultr

1

768MB

15GB SSD

1TB

1Gb/s

5 USD

KVM

Vultr

1

512MB

125GB HDD

1TB

1Gb/s

5 USD

KVM



해외 VPS 4종 (Conoha, DigitalOcean, Linode, Vultr) 속도 비교1 https://ivps.tistory.com/66


해외 VPS 4종 (Conoha, DigitalOcean, Linode, Vultr) 속도 비교2 https://ivps.tistory.com/81



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

Vultr vs ConoHa Linode DigitalOcean 다운로드 속도 비교



Vultr 에 Location 별 속도체크 링크가 있다.


이 파일을 각 Conoha(도쿄), DigitalOcean(싱가포르), Linode(싱가포르), Vultr(도쿄) 해외 VPS 서버에서 다운로드(인바운드) 속도를 측정한 결과이다.


맨 마지막은 SK브로드밴드 망에서 테스트해본 결과이다. 기가망이였으면 좋았을텐데 조금 아쉽다.



Vultr Locations

Conoha(JP)

DigitalOcean(SG)

Linode(SG)

Vultr(JP)

VirtualBox(SKB)

(EU) Frankfurt, DE

40.88 Mbps

28.24 Mbps

8.72 Mbps

39.68 Mbps

25.36 Mbps

(EU) Amsterdam, NL

34.96 Mbps

29.04 Mbps

29.04 Mbps

39.76 Mbps

25.28 Mbps

(EU) Paris, France

28.72 Mbps

28.24 Mbps

27.44 Mbps

21.36 Mbps

25.60 Mbps

(EU) London, UK

33.04 Mbps

28.64 Mbps

28.72 Mbps

37.12 Mbps

27.60 Mbps

(Asia) Tokyo, Japan

147.20 Mbps

130.4 Mbps

155.20 Mbps

790.40 Mbps

26.72 Mbps

New York (NJ)

48.64 Mbps

38.80 Mbps

40.08 Mbps

67.28 Mbps

27.68 Mbps

Chicago, Illinois

71.04 Mbps

46.16 Mbps

20.08 Mbps

78.16 Mbps

26.64 Mbps

Atlanta, Georgia

63.04 Mbps

42.32 Mbps

43.68 Mbps

72.88 Mbps

27.36 Mbps

Miami, Florida

6.92 Mbps

36.16 Mbps

10.96 Mbps

55.04 Mbps

27.68 Mbps

Seattle, Washington

98.40 Mbps

13.92 Mbps

8.16 Mbps

89.60 Mbps

28.32 Mbps

Dallas, Texas

72.40 Mbps

45.36 Mbps

48.80 Mbps

81.60 Mbps

25.36 Mbps

Silicon Valley, California

96.00 Mbps

67.04 Mbps

60.96 Mbps

124.00 Mbps

27.68 Mbps

Los Angeles, California

91.20 Mbps

55.04 Mbps

60.16 Mbps

104.80 Mbps

28.48 Mbps

(AU) Sydney, Australia

84.00 Mbps

82.40 Mbps

104.8 Mbps

101.60 Mbps

27.20 Mbps

평균

65.46 Mbps

47.98 Mbps

46.2 Mbps

121.66 Mbps

26.93 Mbps

평균(Tokyo제외)

59.17 Mbps

41.64 Mbps

37.82 Mbps

70.22 Mbps

26.94 Mbps


Linode Locations

Conoha(JP)

DigitalOcean(SG)

Linode(SG)

Vultr(JP)

VirtualBox(SKB)

US East (Newark)

47.60 Mbps

70.08 Mbps

71.68 Mbps

120.80 Mbps

16.40 Mbps

US South (Atlanta)

65.84 Mbps

67.20 Mbps

13.28 Mbps

112.80 Mbps

27.04 Mbps

US Central (Dallas)

49.92 Mbps

83.20 Mbps

84.00 Mbps

137.60 Mbps

46.64 Mbps

US West (Fremont)

37.12 Mbps

99.20 Mbps

83.20 Mbps

171.20 Mbps

28.64 Mbps

Frankfurt

31.12 Mbps

0.77 Mbps

60.56 Mbps

74.16 Mbps

27.28 Mbps

London

0.67 Mbps

0.75 Mbps

59.60 Mbps

0.69 Mbps

35.76 Mbps

Singapore

136.00 Mbps

692.00 Mbps

3208.00 Mbps

270.40 Mbps

44.96 Mbps

Tokyo

94.40 Mbps

202.40 Mbps

200.00 Mbps

451.20 Mbps

28.40 Mbps

평균

57.83 Mbps

151.95 Mbps

472.54 Mbps

167.36 Mbps

31.89 Mbps


같은 도쿄망내 Vultr <-> Vultr 는 제외한 평균을 보면 Vultr 가  제일 빠르다.


참고로 위에서 테스트한 VPS 는 각 VPS 업체별 최저가 상품으로 개설한 VPS이다.


두번째 테이블의 데이터는 Linode 스피드테스트용 서버를 체크한 것인데 프랑크푸르트, 런던 서버 또는 네트워크 상태가 맛이 간 듯하다.


그리고 Linode 인바운드 네트워크가 40Gbps 라더니 속도가 후덜덜하다. 싱가포르 -> 싱가포르 3.2 Gbps 속도가 나온다.


종합적으로 봤을때 Vultr 가 제일 양호한 것 같다.



테스트한 명령어는 아래와 같다.


wget -O /dev/null http://fra-de-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://ams-nl-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://par-fr-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://lon-gb-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://hnd-jp-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://nj-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://il-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://ga-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://fl-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://wa-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://tx-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://sjo-ca-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://lax-ca-us-ping.vultr.com/vultr.com.100MB.bin

wget -O /dev/null http://syd-au-ping.vultr.com/vultr.com.100MB.bin


wget -O /dev/null http://speedtest.newark.linode.com/100MB-newark.bin

wget -O /dev/null http://speedtest.atlanta.linode.com/100MB-atlanta.bin

wget -O /dev/null http://speedtest.dallas.linode.com/100MB-dallas.bin

wget -O /dev/null http://speedtest.fremont.linode.com/100MB-fremont.bin

wget -O /dev/null http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin

wget -O /dev/null http://speedtest.london.linode.com/100MB-london.bin

wget -O /dev/null http://speedtest.singapore.linode.com/100MB-singapore.bin

wget -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin



이번에는 크로스 다운로드 테스트한 결과이다.


Server

Conoha(JP)

DigitalOcean(SG)

Linode(SG)

Vultr(JP)

VirtualBox(SKB)

Conoha(JP)

101.60 Mbps

99.20 Mbps

102.40 Mbps

62.80 Mbps

DigitalOcean(SG)

98.40 Mbps

738.40 Mbps

311.20 Mbps

53.60 Mbps

Linode(SG)

98.40 Mbps

122.40 Mbps

116.00 Mbps

44.48 Mbps

Vultr(JP)

99.20 Mbps

296.80 Mbps

189.60 Mbps

29.28 Mbps

VirtualBox(SKB)

75.36 Mbps

74.16 Mbps

40.00 Mbps

76.32 Mbps


평균이 아닌 1회성 테스트여서 오차는 있을 수 있다.


그리고 Network 사양은 Conoha 100Mbps, DigitalOcean 1Gbps, Linode 125Mbps(아웃바운드), Vultr 1Gbps 이다.


코노하가 100Mbps 속도를 거의 뽑아주고 있다. 그 외에는 평균 속도는 높은데 네트워크 간 편차가 좀 심한 편이다.


디지털오션 -> 리노드 같은 싱가포르에 위치해 있다고 속도가 738.4 Mbps 가 나온다.


리노드 -> 디지털오션은 아웃바운드 125Mbps 속도제한 때문에 122.4 Mbps 속도가 나왔다.



ConoHa VPS 개통후기 보러가기 http://itrooms.tistory.com/164


DigitalOcean VPS 개통후기 보러가기 https://ivps.tistory.com/80


Linode VPS 개통후기 보러가기 https://ivps.tistory.com/65


Vultr VPS 개통후기 보러가기 https://ivps.tistory.com/56



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

DigitalOcean VPS 개통 후기

VPS 2016. 5. 30. 16:37

DigitalOcean VPS 개통 후기



제일 저렴한 1개월 5달러 요금 상품을 개통하였습니다.


1 CPU / 512MB RAM / 20GB SSD / 1TB Transfer


디지털오션 VPS 생성디지털오션 VPS 생성


Signup 이후 이메일로 날아온 확인링크 클릭하면 Update Billing 단계로 넘어갑니다.


신용카드정보 입력하고 나면 VPS 생성이 가능합니다.


아 그리고 디지털오션은 조금 특이하게도 VPS 생성시 root 암호를 이메일로 보내주는군요.


이메일로 받은 비밀번호를 입력하고 로그인하면 패스워드를 바로 바꾸라고 하네요~



디지털오션 VPS Graphs디지털오션 VPS Graphs


우리나라에서 제일 가까운 싱가포르에 개통을 하였습니다.



싱가포르 PING Average 107ms


[root@ocean ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/vda1        20G  1.1G   18G   6% /

devtmpfs        236M     0  236M   0% /dev

tmpfs           245M     0  245M   0% /dev/shm

tmpfs           245M  4.3M  241M   2% /run

tmpfs           245M     0  245M   0% /sys/fs/cgroup

tmpfs            49M     0   49M   0% /run/user/0


[root@ocean ~]# cat /etc/centos-release

CentOS Linux release 7.2.1511 (Core)


[root@ocean ~]# cat /proc/cpuinfo | grep "model name"

model name      : Intel(R) Xeon(R) CPU E5-2630L 0 @ 2.00GHz


[root@ocean ~]# free -m

              total        used        free      shared  buff/cache   available

Mem:            489          59         194           4         234         405

Swap:             0           0           0


[root@ocean ~]# dd if=/dev/zero of=/1GB.tmp bs=100M count=10

10+0 records in

10+0 records out

1048576000 bytes (1.0 GB) copied, 4.43256 s, 237 MB/s


[root@ocean ~]# hdparm -Tt /dev/vda

/dev/vda:

 Timing cached reads:   12752 MB in  2.00 seconds = 6385.06 MB/sec

 Timing buffered disk reads: 2772 MB in  3.00 seconds = 923.87 MB/sec


간략하게 테스트한 내용입니다.


핑속도가 조금 아쉽네요~


CPU 가 Xeon E5-2630L@2.00GHz 군요~

( 신규로 하나 새로 개설해서 확인해 보니 E5-2630L v2 @ 2.40GHz 복불복인가봅니다~ )



디지털오션 추천가입하기 https://m.do.co/c/20fa14be8f45


위 링크로 가입시 10달러를 받을 수 있습니다.


Give $10, Get $25

Everyone you refer gets $10 in credit. Once they’ve spent $25 with us, you'll get $25. There is no limit to the amount of credit you can earn through referrals.



DigitalOcean VPS All DropletsDigitalOcean VPS All Droplets

각 지역별로 모두 개통해서 ping 테스트를 해보았습니다.


ocean-to PING Average 261ms

ocean-ff PING Average 279ms

ocean-uk PING Average 300ms

ocean-sf PING Average 160ms

ocean-am PING Average 344ms

ocean-ny PING Average 223ms

ocean-sg PING Average 107ms


캐나다 토론토, 독일 프랑크푸르트, 영국 런던, 미국 샌프란시스코, 네덜란드 암스테르담, 미국 뉴욕, 싱가포르 순입니다.

속도는 그나마 싱가포르가 제일 좋군요.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

SSH 인증키 원격지 서버에 올려서 암호입력 없이 접속하기



백업 또는 서버관리를 위해서 SSH 사용이 아주 빈번하다. RSYNC 또는 SCP, SFTP 같은 유틸로 파일을 백업하고자 할 때,


CRON에 백업스크립트를 등록하여 자동백업 하고자 할 때 비밀번호 입력 없이 파일 업로드가 가능하다면 아주 편리할 것이다.


아래는 백업서버가 1대(conoha) 운영서버 여러대(linode, vultr, etc) 있고 운영서버의 인증키를 백업서버(원격지)에 올리는 방법이다.



▶ Linode SSH 인증키 생성 및 업로드


[root@linode ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

f9:99:30:0e:8d:cc:a1:44:c6:ac:19:6e:67:19:04:5a root@linode.ivps.kr

The key's randomart image is:

+--[ RSA 2048]----+

|  E=+            |

| o.o+            |

|.. +.o.          |

|  =.++ + .       |

| . o. = S        |

|       o + o     |

|        . +      |

|                 |

|                 |

+-----------------+


[root@linode ~]# cat ./.ssh/id_rsa.pub | ssh -p10022 root@conoha.ivps.kr "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

The authenticity of host '[conoha.ivps.kr]:10022 ([133.130.126.29]:10022)' can't be established.

ECDSA key fingerprint is d1:33:b1:93:a0:7c:5b:7e:3b:e1:5b:2b:13:8a:27:01.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[conoha.ivps.kr]:10022,[133.130.126.29]:10022' (ECDSA) to the list of known hosts.

root@conoha.ivps.kr's password:



▶ Linode SSH 인증키 생성 및 업로드


[root@vultr ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

d1:22:15:0c:4e:d5:95:19:fd:c6:c8:4f:8b:5b:f8:01 root@vultr.ivps.kr

The key's randomart image is:

+--[ RSA 2048]----+

|      o++o .o=   |

|     o .... o .  |

|      o o .  . + |

|       . o   Eo =|

|        S     ++.|

|             o +.|

|              + .|

|             . . |

|                 |

+-----------------+


[root@vultr ~]# cat ./.ssh/id_rsa.pub | ssh -p10022 root@conoha.ivps.kr "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

The authenticity of host '[conoha.ivps.kr]:10022 ([133.130.126.29]:10022)' can't be established.

ECDSA key fingerprint is d1:33:b1:93:a0:7c:5b:7e:3b:e1:5b:2b:13:8a:27:01.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '[conoha.ivps.kr]:10022,[133.130.126.29]:10022' (ECDSA) to the list of known hosts.

root@conoha.ivps.kr's password:



▶ Conoha 에서 인증키가 정상적으로 복사되었는지 확인


[root@conoha ~]# cat ~/.ssh/authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3P6CFMztEsGJzLjGhoGNomDKAQ5CgnVW5eV79zRWTGdamxHtJLZS1sq5lCk4oFAslhD4fStQguH4TKVrhFhwczK+mIX7iaycUVJshH2QB4Zce4rM+7loacU1WKOjE1LK4twWggH8LsJHkwRqBaZi/9mXYbBsUpsnR1PvBxZ5ub+61jqujD13jgwMS9tlVSLsM9VFrn/+bMEt8bAwSeVCPlY2QroeL7euu/H6CwW4NYGEPXOEnu6k9W5WKSeBo+WjTsLvip/UziJ6+jjs2z+VGeg2iyOXBG6onXAnfa9vaY+gqQ6X5ZL2/5TFP9T1nYNlask2W6FlQhe09OpDDaVA1 root@linode.ivps.kr

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIacorFIiihlSc8fDOrZNab79w7STxi6ubNOAn+BsnBBKawMlWWEb6gzQTC0BTcZUQpm/s3LFQgQGdu5cfdVi+DfmicOQo9N+bjNLv/NHfoCt0yEWmlWDx2iew37Lv1BzrV/w1T2xssx7KVCrRg+NmcUbP0yPegtGsvjR17vpCafam7jxN2TRxo3uk7ah9z8budaKACMeOpF1JhEpMSahmHvweyUXNIpN3dnBnfZIUqwFFh+RnOY3rR2L2W9c0bc6KQSGpl0BavqeGrSNhYNwVYn2tcCGcDCePqrT4mFkG+QPxhpZmNNeNrlRS5NDB9FgBbVCUMuFtI7aD4qW7itI1 root@vultr.ivps.kr


~/.ssh/authorized_keys 파일에 두 서버의 SSH 인증키가 합쳐져 있다.



▶ SSH 접속 테스트


[root@vultr ~]# ssh -p10022 root@conoha.ivps.kr

Last login: Mon May 30 13:06:06 2016 from 107.191.53.38

[root@conoha ~]# exit

logout

Connection to conoha.ivps.kr closed.

[root@vultr ~]#


[root@linode ~]# ssh -p10022 root@conoha.ivps.kr

Last login: Mon May 30 13:08:51 2016 from 107.191.53.38

[root@conoha ~]# exit

logout

Connection to conoha.ivps.kr closed.

[root@linode ~]#


이제 두 서버 모두 암호 입력없이 로그인이 된다.


scp 예제보기 https://ivps.tistory.com/77


sftp 예제보기 https://ivps.tistory.com/78



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 sftp 암호입력 없이 사용하는 방법



sftp 뿐만 아니라 rsync, ssh, scp 등 ssh 로그인을 사용하는 유틸은 모두 동일하다.


인증키를 원격지서버에 올리는 방법은 scp 를 설명하는 게시글 https://ivps.tistory.com/77 여기에도 언급되어 있지만 다시 설명하자면 아래와 같다.


ssh-keygen 으로 인증키를 만들어서 원격지 서버로 업로드하면 된다.


▶ ssh 인증키 생성


[root@conoha ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

62:1b:92:d1:58:21:4a:b1:36:86:62:1f:71:90:e0:ec root@conoha.ivps.kr

The key's randomart image is:

+--[ RSA 2048]----+

| .+++.o.         |

|oo +o=           |

|o+*.o .          |

|+o...o           |

| E .o + S        |

|     o +         |

|      .          |

|                 |

|                 |

+-----------------+


[root@conoha ~]# scp -P10022 ./.ssh/id_rsa.pub root@vultr.ivps.kr:~/.ssh/authorized_keys

root@vultr.ivps.kr's password:

id_rsa.pub                                    100%  398     0.4KB/s   00:00


위에서는 scp 로 업로드를 하였지만 sftp 로 올려도 된다.


[root@conoha ~]# sftp -P10022 root@vultr.ivps.kr

root@vultr.ivps.kr's password:

Connected to vultr.ivps.kr.

sftp> put ./.ssh/id_rsa.pub ./.ssh/authorized_keys

Uploading ./.ssh/id_rsa.pub to /root/./.ssh/authorized_keys

./.ssh/id_rsa.pub                             100%  393     0.4KB/s   00:00

sftp> ls .ssh

.ssh/authorized_keys

sftp> bye


위 처럼 /root/.ssh 디렉토리에 authorized_keys 이름으로 인증키를 업로드한 뒤 부터는 비밀번호를 묻지않고 접속이 가능해진다.

 ( 여러개 다수의 서버라면 여기를 참고 https://ivps.tistory.com/79 )



▶ sftp 옵션설명 ( 아래의 옵션은 scp 랑 같다. )


-C 전송시 파일을 압축해서 전송한다.

-l 전송속도 옵션이다. 단위는 Kbit/s

-P 포트지정 옵션이다. 22번 포트는 생략하여도 된다.

-p 원본 파일과 시간을 동일하게 복사한다.

-q 전송진행 상태를 안보여준다.

-r 하위 디렉토리까지 같이 복사하다.

-v 디버깅메시지를 보여준다. 그러나 너무 분잡하다.


그리고 sftp 접속 후의 ls, get, put 등의 명령어는 ftp 명령어랑 똑같다.


[root@conoha ~]# sftp -P10022 -Cpr root@vultr.ivps.kr

Connected to vultr.ivps.kr.

sftp> help

Available commands:

bye                                Quit sftp

cd path                            Change remote directory to 'path'

chgrp grp path                     Change group of file 'path' to 'grp'

chmod mode path                    Change permissions of file 'path' to 'mode'

chown own path                     Change owner of file 'path' to 'own'

df [-hi] [path]                    Display statistics for current directory or

                                   filesystem containing 'path'

exit                               Quit sftp

get [-Ppr] remote [local]          Download file

reget remote [local]            Resume download file

help                               Display this help text

lcd path                           Change local directory to 'path'

lls [ls-options [path]]            Display local directory listing

lmkdir path                        Create local directory

ln [-s] oldpath newpath            Link remote file (-s for symlink)

lpwd                               Print local working directory

ls [-1afhlnrSt] [path]             Display remote directory listing

lumask umask                       Set local umask to 'umask'

mkdir path                         Create remote directory

progress                           Toggle display of progress meter

put [-Ppr] local [remote]          Upload file

pwd                                Display remote working directory

quit                               Quit sftp

rename oldpath newpath             Rename remote file

rm path                            Delete remote file

rmdir path                         Remove remote directory

symlink oldpath newpath            Symlink remote file

version                            Show SFTP version

!command                           Execute 'command' in local shell

!                                  Escape to local shell

?                                  Synonym for help

sftp> !


아래는 배치파일로 업로드 및 다운로드 하는 방법이다.


[root@conoha ~]# dd if=/dev/zero of=./100M.bin bs=100M count=1

1+0 records in

1+0 records out

104857600 bytes (105 MB) copied, 0.169097 s, 620 MB/s

[root@conoha ~]# echo "put 100M.bin" > sftp.batch

[root@conoha ~]# echo "get 100M.bin" >> sftp.batch

[root@conoha ~]# sftp -P10022 -Cpr -b sftp.batch root@vultr.ivps.kr

sftp> put 100M.bin

sftp> get 100M.bin


옵션 -b 패치파일 형태이다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 서버간 scp로 파일 복사하기



리눅스 서버간에 파일을 업로드하는 방법은 ftp, rsync 도 있겠지만 ssh 를 이용하는 scp (secure copy) 도 있다.


먼저 ssh-keygen 으로 인증키를 만들어서 원격지 서버에 넣어 놓아야 scp 로 파일 복사시 암호를 더 이상 묻지 않는다.


rsync 와 거의 유사해서 백업용으로 사용이 가능하다.



▶ 인증키 만들기 (ssh-keygen -t rsa or dsa)


[root@conoha ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

62:1b:92:d1:58:21:4a:b1:36:86:62:1f:71:90:e0:ec root@conoha.ivps.kr

The key's randomart image is:

+--[ RSA 2048]----+

| .+++.o.         |

|oo +o=           |

|o+*.o .          |

|+o...o           |

| E .o + S        |

|     o +         |

|      .          |

|                 |

|                 |

+-----------------+


[root@conoha ~]# ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/root/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_dsa.

Your public key has been saved in /root/.ssh/id_dsa.pub.

The key fingerprint is:

4c:15:b1:5c:00:cc:0a:0d:60:24:0d:8e:75:94:81:fa root@conoha.ivps.kr

The key's randomart image is:

+--[ DSA 1024]----+

|o+=+== o..=+.    |

|o+o.o . oo o     |

|.o   . .. o      |

|.     .o         |

| .      S        |

|  E              |

|                 |

|                 |

|                 |

+-----------------+


암호화 방식의 차이니깐 둘 중에 마음에 드는 것을 선택하면 된다.



이제 인증키를 원격서버에 업로드 하자. ( 여러개 다수의 서버라면 여기를 참고 https://ivps.tistory.com/79 )


[root@conoha ~]# scp ./.ssh/id_rsa.pub root@vultr.ivps.kr:~/.ssh/authorized_keys

ssh: connect to host vultr.ivps.kr port 22: Connection refused

lost connection

You have new mail in /var/spool/mail/root


ssh 포트가 맞지 않아서 실패하였다.


포트 옵션을 주고 다시 실행


[root@conoha ~]# scp -P10022 ./.ssh/id_rsa.pub root@vultr.ivps.kr:~/.ssh/authorized_keys

root@vultr.ivps.kr's password:

id_rsa.pub                                    100%  398     0.4KB/s   00:00


[root@conoha ~]# scp -P10022 ./.ssh/id_rsa.pub root@vultr.ivps.kr:~/.ssh/authorized_keys

id_rsa.pub                                    100%  398     0.4KB/s   00:00


첫번째는 인증키가 원격지 서버에 아직 없으므로 패스워드를 물어본다.

두번재는 인증키가 이미 올라간 상태라서 비밀번호를 묻지 않고 바로 복사가 되었다.



▶ scp 옵션


-C 전송시 파일을 압축해서 전송한다.

-l 전송속도 옵션이다. 단위는 Kbit/s

-P 포트지정 옵션이다. 22번 포트는 생략하여도 된다.

-p 원본 파일과 시간을 동일하게 복사한다.

-q 전송진행 상태를 안보여준다.

-r 하위 디렉토리까지 같이 복사하다.

-v 디버깅메시지를 보여준다. 그러나 너무 분잡하다.



▶ scp 복사 예제


테스트용 디렉토리와 100MByte 파일 생성

[root@conoha ~]# mkdir -p ./testdir/subdir

[root@conoha ~]# dd if=/dev/zero of=./testdir/subdir/100M.bin bs=100M count=1

1+0 records in

1+0 records out

104857600 bytes (105 MB) copied, 0.227941 s, 460 MB/s


30Mbps 속도로 원격지 서버에 testdir 디렉토리를 전송 (속도가 제어되어서 전송되었다.)

[root@conoha ~]# scp -P10022 -l30000 -pr ./testdir/ root@vultr.ivps.kr:~/testdir/

100M.bin                                      100%  100MB   3.7MB/s   00:27


속도제한 없이 원격지 서버에 전송 (160Mbps 속도가 나온다.)

[root@conoha ~]# scp -P10022 -pr ./testdir/ root@vultr.ivps.kr:~/testdir/

100M.bin                                      100%  100MB  20.0MB/s   00:05


압축해서 원격지 서버에 전송 (800Mbps 속도가 나왔다. 더미파일이라서 압축효과가 있다.)

[root@conoha ~]# scp -P10022 -Cpr ./testdir root@vultr.ivps.kr:~/

100M.bin                                      100%  100MB 100.0MB/s   00:01


이번엔 원서버에 원본 디렉토리를 지우고

[root@conoha ~]# rm -rf testdir


원격지 서버의 testdir 디렉토리를 다운로드

[root@conoha ~]# scp -P10022 -Cpr root@vultr.ivps.kr:~/testdir ~/

100M.bin                                      100%  100MB  50.0MB/s   00:02

[root@conoha ~]# scp -P10022 -pr root@vultr.ivps.kr:~/testdir ~/

100M.bin                                      100%  100MB  20.0MB/s   00:05

[root@conoha ~]# ls -l ~/testdir/subdir/

합계 102400

-rw-r--r-- 1 root root 104857600  5월 27 11:53 100M.bin


rsync 의 --delete 옵션이 scp 에는 없는거 빼고는 별 차이가 없는 것 같다.


물론 rsync 는 한번 복사 이후에는 변경된 파일만 백업이 이뤄지는 아주 큰 매력이 있긴하다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 7.x 호스트네임 변경하기



기존 방식대로 /etc/hostname 파일을 수정해도 되고 hostnamectl 유틸을 사용해도 된다.



▶ 호스트네임 확인


[root@conoha bin]# hostnamectl

   Static hostname: localhost

         Icon name: computer-vm

           Chassis: vm

        Machine ID: ce592a37a02b45f78d729b0b2e24d5cf

           Boot ID: 62082661e9f840a59c2ebf6789b7a56e

    Virtualization: kvm

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 3.10.0-327.10.1.el7.x86_64

      Architecture: x86-64


▶ 호스트네임 변경


[root@conoha bin]# hostnamectl set-hostname www.example.com



변경이 되었는지 확인해보자.


[root@conoha bin]# hostnamectl

   Static hostname: www.example.com

         Icon name: computer-vm

           Chassis: vm

        Machine ID: ce592a37a02b45f78d729b0b2e24d5cf

           Boot ID: 62082661e9f840a59c2ebf6789b7a56e

    Virtualization: kvm

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 3.10.0-327.10.1.el7.x86_64

      Architecture: x86-64


[root@conoha bin]# cat /etc/hostname

www.example.com


[root@conoha bin]# hostname

www.example.com



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 아파치 서버가 살아있는지 체크하는 쉘스크립트



ping 을 막아 놓은 경우에 확인해 볼 수 있는 방법중 하나이다.


서버를 체크해서 이전 상태와 다를 경우 이메일로 결과를 전송하도록 작성해보았다.


우선 웹서버에 robots.txt 파일을 하나 생성해주자.


User-agent: *

Disallow: /


이 파일이 다운로드 받아지는지 체크하면 된다.


# touch /usr/local/bin/server-check.sh

# chmod 700 /usr/local/bin/server-check.sh

# vi /usr/local/bin/server-check.sh

#!/bin/sh


CHECK_DOMAINS="

http://www.example.com

http://www1.example.com

http://www2.example.com

http://www3.example.com

"

CHECK_FILE="robots.txt"

SAVE_PATH="/root"

TO_EMAIL="webmaster@example.com"


for DOMAIN in $CHECK_DOMAINS

do

CHECK_URL="$DOMAIN/$CHECK_FILE"

SUBJECT="$CHECK_URL 서버체크 결과"

LAST_STATE="$SAVE_PATH/$(echo $DOMAIN | base64).state"


wget -O $SAVE_PATH/$CHECK_FILE $CHECK_URL


if [ -f $LAST_STATE ] ; then

LAST_LIFE=`cat $LAST_STATE`

else

LAST_LIFE="init"

fi


if [ -s /root/$CHECK_FILE ] ; then

CURR_LIFE="true"

else

CURR_LIFE="false"

fi

echo $CURR_LIFE > $LAST_STATE


echo "LAST_LIFE : $LAST_LIFE, CURR_LIFE : $CURR_LIFE"

if [ "$LAST_LIFE" != "$CURR_LIFE" ] ; then

echo "Server status : no same"

if [ "$CURR_LIFE" == "false" ] ; then

EMAIL_MSG="$CHECK_URL 웹서비스가 반응이 없습니다."

else

EMAIL_MSG="$CHECK_URL 웹서비스가 정상입니다."

fi

echo "$EMAIL_MSG" | /bin/mail -s "$SUBJECT" "$TO_EMAIL"

else

echo "Server status : same"

fi

done


위 코드를 응용해서 크론에 등록해서 체크를 하면 된다.


[root@conoha cron.d]# echo "*/5 * * * * root /usr/local/bin/server-check.sh" > /etc/cron.d/server-check

[root@conoha cron.d]# cat /etc/cron.d/server-check

*/5 * * * * root /usr/local/bin/server-check.sh

[root@conoha cron.d]# chmod 600 /etc/cron.d/server-check

[root@conoha cron.d]# ls -l /etc/cron.d
-rw-r--r--  1 root root 128  4월  1 00:09 0hourly
-rw-r--r--. 1 root root 108  9월 19  2015 raid-check
-rw-------  1 root root  44  5월 27 10:36 server-check
-rw-------. 1 root root 235  3월  6  2015 sysstat



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,