# apt-get install haproxy

# vi /etc/default/haproxy


# root@node01:/etc/keepalived# cat /etc/default/haproxy

# Set ENABLED to 1 if you want the init script to start haproxy.

ENABLED=0 -> 1 //수정

# Add extra flags here.

#EXTRAOPTS="-de -m 16"


https://serversforhackers.com/load-balancing-with-haproxy 파라미터 값 참조

Load Balancing Configuration

To get started balancing traffic between our three HTTP listeners, we need to set some options within HAProxy:

  • frontend - where HAProxy listens to connections
  • backend - Where HAPoxy sends incoming connections
  • stats - Optionally, setup HAProxy web tool for monitoring the load balancer and its nodes



global

        log /dev/log    local0

        log /dev/log    local1 notice

        chroot /var/lib/haproxy

        user haproxy

        group haproxy

        daemon


defaults

        log     global

        mode    http

        option  httplog

        option  dontlognull

        retries 3

        redispatch

        maxconn 2000

        contimeout 5000

        clitimeout 50000

        srvtimeout 50000

        errorfile 400 /etc/haproxy/errors/400.http

        errorfile 403 /etc/haproxy/errors/403.http

        errorfile 408 /etc/haproxy/errors/408.http

        errorfile 500 /etc/haproxy/errors/500.http

        errorfile 502 /etc/haproxy/errors/502.http

        errorfile 503 /etc/haproxy/errors/503.http

        errorfile 504 /etc/haproxy/errors/504.http


frontend http-in

        mode http

        bind *:80

        log global

        option httplog

        default_backend servers


backend servers

        mode http

        balance roundrobin

        option forwardfor

        server web01 192.168.100.103:80 check


###

Try http://x.x.x.x:3000/stats  URL to login into statistics report for HAProxy.


listen stats *:3000  //

        mode http

        stats enable

        stats uri /stats

        stats hide-version

        stats auth admin:admin




'나만의 Cloud' 카테고리의 다른 글

go PATH 설정  (2) 2017.03.17
pacemaker  (0) 2016.11.23
ubuntu apache2 포트 변경 및 DocumentRoot 변경  (0) 2016.06.02
SLA  (0) 2016.05.09
ubuntu keepalived  (0) 2016.04.20
Posted by 뭉탁거림
,

python pexpect, paramiko 라이브러리를 이용한 원격지 서버의 명령어 수행


1) pip 설치

2) pip install pexepect, paramiko 


#!/usr/bin/python


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


import pexpect

import paramiko

import time

import sys


def ssh_conn(host,passwd,command):

result=""

ssh = paramiko.SSHClient()  

ssh.load_system_host_keys()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect(host,username='root',password=passwd)

stdin, stdout, stderr = ssh.exec_command(command)

for i in stdout.readlines():

result+=i

print result


ssh.close()


return result


if __name__ == "__main__":

try:

num = 1

mgmt = ""

networks = ["172.16.193.", "172.16.194.", "172.16.196.", "172.16.197."]

for i in networks:

print i + "X MGMT Network POD " + "\n"

for j in range(1,9):

mgmt = i + str(j)

ssh_conn(mgmt, "password", sys.argv[1])

time.sleep(1)

except Exception, e:

print str(e)

'Python_Study' 카테고리의 다른 글

[python] pass, continue 차이  (2) 2015.09.23
[python] class , self  (0) 2015.09.10
python pip  (0) 2015.08.21
Flask 정리  (0) 2015.02.05
52장 카드만들기  (0) 2014.08.20
Posted by 뭉탁거림
,

bosh sample release를 개발하기 위해 사전 테스트 작업으로 apache를 bosh를 통해 배포하여 보자

 


1. Release 생성

# bosh init release test-release


root@jenkins:~/workspace/test-release# tree

├── blobs

├── config

   └── blobs.yml

├── jobs

├── packages

└── src



2. Package 생성 : 배포에 필요한 binary file과 job에서 사용할 src 및 dependency file 제공


# bosh generate package apache2


root@jenkins:~/workspace/bosh_install_test/packages# tree

└── apache2

    ├── packaging

    ├── pre_packaging

    └── spec


또.. 여러개 파일이 default로 생성된다...

1) spec 파일 수정

   - name : package name

   - dependencies : Package's dependencies

   - files :The location where BOSH can find the binaries and other files that the package needs at compile time


---

name: apache2


dependencies:


files:

  - apache2/httpd-2.2.25.tar.gz


 2) src 디렉토리에시 필요한 파일 download

# mkdir src/apache2

# cd src/apache2

# wget 'http://apache.tradebit.com/pub/httpd/httpd-2.2.25.tar.gz'


 3) packaging (compilation script) 작성

echo "Extracting apache https..."

tar xzf apache2/httpd-2.2.25.tar.gz


echo "Building apache https..."

(

   cd httpd-2.2.25

    ./configure \

    --prefix=${BOSH_INSTALL_TARGET} \

    --enable-so

    make

    make install

}

EOF 


release의 package 설정을 대강 마무리 됬고 pre_packaging의 용도는 모르겠다.

아래로 대망의 job 생성


3. job 생성

# bosh generate job apache2



create jobs/apache2

create jobs/apache2/templates

create jobs/apache2/spec

create jobs/apache2/monit


또 이것저것 만들고...


1) spec : spec 파일은 job metadata 정의한 파일로 bosh 통해 deploy 해석되어 사용된다

         name, description, templates, package, properties 구성 되어 있음

         spec 파일의 자세한 schema https://bosh.io/docs/jobs.html 참조


  • Compile 단계에 BOSH는 template들을 file 변환하여 JOB VM 복사함
  • Key/value 형식으로 선언되며, key template 폴더의 파일 name, value JOB VM 복사되는 PATH 파일 이름

    /var/vcap/jobs/<job_name>/bin/ctl on the job VM


---

name: apache2

 

description: This job runs a simple HTTP server.

 

templates:

  httpd.conf.erb: config/httpd.conf

 

packages:

  - apache2

 

properties:

  name:

     description: name set test

  age:

     description: age deafult set test

     default: 99



너무 길어지니.. 우선 여기까지~





 

'CloudFoundry' 카테고리의 다른 글

[bosh] job lifecycle  (0) 2016.06.02
[bosh] release, job  (0) 2016.06.02
bosh-lite 이용한 CloudFoundry deploy  (0) 2016.04.20
[CloudFoundry] cf push process(application 배포)  (0) 2016.04.20
CloudFoundry user-provide-service setting  (0) 2016.04.20
Posted by 뭉탁거림
,