본문 바로가기

IT-Consultant

OpenStack Swift 설치 / Ubuntu 13.10

Proxy 서버 1대, 스토리지 노드 2대 총 3대에 설치할 예정이다. 

참고로 스토리지 노드에는 2개의 디스크가 있고, 각각 OS와 데이터 영역으로 사용한다. 


Proxy Server : 192.168.0.100 

Storage Node 1 : 192.168.0.110

Storage Node 1 : 192.168.0.111


Proxy Server에서 비밀번호 없이 스토리지 노드에 접속할 수 있도록 authorized_keys 파일을 설정하면 더 편하게 설치할 수 있다.(비밀번호 없이 접속하기) 




모든 서버에 공통으로 적용 

  1. swift 관련 패키지 설치 

  2. apt-get install python-software-properties add-apt-repository ppa:swift-core/release : 이 부분은 12.04 버전부터 필요 없다. apt-get update apt-get install swift python-swiftclient openssh-server

  3. swift 디렉토리 생성 

    mkdir -p /etc/swift
    chown -R swift:swift /etc/swift/
  4. Swift 설정 파일 생성, 아래 hash 데이터는 모든 노드가 동일해야 한다. 

    cat >/etc/swift/swift.conf <<EOF
    [swift-hash]
    # random unique strings that can never change (DO NOT LOSE)
    swift_hash_path_prefix = `od -t x8 -N 8 -A n </dev/random`
    swift_hash_path_suffix = `od -t x8 -N 8 -A n </dev/random`
    EOF
  5. 클러스터 내 모든 노드는 4번에서 생성한 파일을 복사해서 사용한다. 

    scp /etc/swift/swift.conf root@192.168.0.110:/etc/swift/ scp /etc/swift/swift.conf root@192.168.0.111:/etc/swift/

  6. Swift 설치를 위한 환경변수 설정 
    나중에 보면 알겠지만, 설정파일에 있는 내용을 일괄적으로 변경하기 위한 작업이다. 

    export STORAGE_LOCAL_NET_IP=192.168.0.110 export PROXY_LOCAL_NET_IP=192.168.0.100

  7. /etc/rc.local 파일에서 "exit 0" 바로 앞에 아래 내용을 추가한다. 
    이것은 swift 실행중에 필요하다. 그리고 시스템 종료시 삭제되나, 다시 시작할때 이 디렉토리를 생성한다. 그때 이 디렉토리에 권한이 있어야 한다. 

    mkdir -p /var/run/swift
    chown swift:swift /var/run/swift
  8. 아래 설정은 Storage Node에만 필요한다. Proxy 서버에도 해줘도 무관하다. 

    mkdir -p /var/cache/swift /srv/node/
    chown swift:swift /var/cache/swift

Note

링에서 파일 블럭 맵핑을 결정할때 /etc/swift/swift.con 파일에 있는 랜덤 스트링은 필수적이다. 

원문에서는 소금과 같다니. 그냥 절대적으로 필요수적인가보다. 


Configure the Proxy node

Note

아래 모든 명려어는 root로 실행해야 한다. 

  1. Install swift-proxy service:

    apt-get install swift-proxy memcached
  2. Create self-signed cert for SSL:

    cd /etc/swift
    openssl req -new -x509 -nodes -out cert.crt -keyout cert.key

Note

SSL 설정을 위해서 2번 항목이 필요한데, 인증서를 만들어 주는게 좋다. 실제 이용할때도 SSL은 필수다. openssl을 사용해서 만들기 때문에 별도의 비용도 들지 않는다. 

  1. memcached 설정 파일 수정 

    perl -pi -e "s/-l 127.0.0.1/-l $PROXY_LOCAL_NET_IP/" /etc/memcached.conf
  2. memcache server 재시작

    service memcached restart
  3. Create /etc/swift/proxy-server.conf:

    cat >/etc/swift/proxy-server.conf <<EOF
    [DEFAULT]
    cert_file = /etc/swift/cert.crt
    key_file = /etc/swift/cert.key
    bind_port = 8080
    workers = 8
    user = swift
    
    [pipeline:main]
    pipeline = healthcheck proxy-logging cache tempauth proxy-logging proxy-server
    
    [app:proxy-server]
    use = egg:swift#proxy
    allow_account_management = true
    account_autocreate = true
    
    [filter:proxy-logging]
    use = egg:swift#proxy_logging
    
    [filter:tempauth]
    use = egg:swift#tempauth
    user_system_root = testpass .admin https://$PROXY_LOCAL_NET_IP:8080/v1/AUTH_system
    
    [filter:healthcheck]
    use = egg:swift#healthcheck
    
    [filter:cache]
    use = egg:swift#memcache
    memcache_servers = $PROXY_LOCAL_NET_IP:11211
    EOF

    Note

    만약 Proxy 서버가 여러대이면 아래처럼 memcache에 대해서 아래처럼 해주면 된다. 
    10.1.2.3:11211,10.1.2.4:11211

  4. the account, container and object rings. 3가지 콤포넌트 생성.
    첫번째 18 숫자는 2의 18승을 이야기한다. 이것은 파티션 개수를 나타내는 것으로 테스트할때는 문제 없고 수백PB의 스토리지를 운영할때는 고려해봐야할 값이다. 두번째 3은 복제본의 수다. 예3벌로 백업된다는  이야기다.  마지막 1은 시간당 파티션간 이동 횟수 제한값이다.(사실 뭔말인지 이해가 안된다.) 어쨋든 나는 테스트용으로 할 것이니깐 3벌까지 복제할 필요는 없으니 2로 설정 

  5. cd /etc/swift swift-ring-builder account.builder create 18 2 1 swift-ring-builder container.builder create 18 2 1 swift-ring-builder object.builder create 18 2 1

    Note

    링에 대해서 조금 더 알고 싶다면 요길... The Rings.

  6. 각 노드의 디바이스 추가 

    swift-ring-builder account.builder add r1z1-192.168.0.110:6002/sdb1 100
    swift-ring-builder container.builder add r1z1-192.168.0.110:6001/sdb1 100
    swift-ring-builder object.builder add
    r1z1-192.168.0.110:6000/sdb1 100 swift-ring-builder account.builder add r1z1-192.168.0.111:6002/sdb1 100 swift-ring-builder container.builder add r1z1-192.168.0.111:6001/sdb1 100 swift-ring-builder object.builder add r1z1-192.168.0.111:6000/sdb1 100
  7. 링이 제대로 설치되었는지 확인 

    swift-ring-builder account.builder
    swift-ring-builder container.builder
    swift-ring-builder object.builder
  8. Rebalance the rings:

    swift-ring-builder account.builder rebalance
    swift-ring-builder container.builder rebalance
    swift-ring-builder object.builder rebalance

    Note

    리밸런싱 작업은 시간이 좀 걸린다. 허접한 내 테스트 머신에선 10분정도 걸린것 같다. 

  9. Proxy서버의 account.ring.gz, container.ring.gz, and object.ring.gz 파일을 스토리지 노드의 /etc/swift에 복사 

  10. 디렉토리 소유권 변경 

    chown -R swift:swift /etc/swift
  11. 프락시 서버 시작 

    swift-init proxy start



Configure the Storage nodes

Note

랙스페이스에서 테스트해보니 xfs를 사용하는게 좋단다. 

  1. swift 관련 패키지 설치 

    apt-get install swift-account swift-container swift-object xfsprogs
  2. device mount 

    fdisk /dev/sdb  (set up a single partition)
    mkfs.xfs -i size=512 /dev/sdb1
    echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
    mkdir -p /srv/node/sdb1
    mount /srv/node/sdb1
    chown swift:swift /srv/node/sdb1
  3. Create /etc/rsyncd.conf:

    cat >/etc/rsyncd.conf <<EOF uid = swift gid = swift log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 192.168.0.111 [account] max connections = 2 path = /srv/node/ read only = false lock file = /var/lock/account.lock [container] max connections = 2 path = /srv/node/ read only = false lock file = /var/lock/container.lock [object] max connections = 2 path = /srv/node/ read only = false lock file = /var/lock/object.lock EOF

  4. Edit the RSYNC_ENABLE= line in /etc/default/rsync:

    perl -pi -e 's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync
  5. Start rsync daemon:

    service rsync start

    Note

    The rsync daemon requires no authentication, so it should be run on a local, private network.

  6. Create /etc/swift/account-server.conf:

    cat >/etc/swift/account-server.conf <<EOF [DEFAULT] bind_ip = 192.168.0.111 workers = 2 [pipeline:main] pipeline = account-server [app:account-server] use = egg:swift#account [account-replicator] [account-auditor] [account-reaper] EOF

  7. Create /etc/swift/container-server.conf:

    cat >/etc/swift/container-server.conf <<EOF [DEFAULT] bind_ip = 192.168.0.111 workers = 2 [pipeline:main] pipeline = container-server [app:container-server] use = egg:swift#container [container-replicator] [container-updater] [container-auditor] [container-sync] EOF

  8. Create /etc/swift/object-server.conf:

    cat >/etc/swift/object-server.conf <<EOF [DEFAULT] bind_ip = 192.168.0.111 workers = 2 [pipeline:main] pipeline = object-server [app:object-server] use = egg:swift#object [object-replicator] [object-updater] [object-auditor] EOF

  9. 서비스 시작

    swift-init all start


Create Swift admin account and test

  1. 사용자 추가 

    curl -k -v -H 'X-Storage-User: system:root' -H 'X-Storage-Pass: testpass' https://110.14.220.65:8080/auth/v1.0
  2. Check that you can HEAD the account:

    curl -k -v -H 'X-Auth-Token: <token-from-x-auth-token-above>' <url-from-x-storage-url-above>
  3. Check that swift works (at this point, expect zero containers, zero objects, and zero bytes):

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass stat
  4. Use swift to upload a few files named ‘bigfile[1-2].tgz’ to a container named ‘myfiles’:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload myfiles bigfile1.tgz
    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload myfiles bigfile2.tgz
  5. Use swift to download all files from the ‘myfiles’ container:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass download myfiles
  6. Use swift to save a backup of your builder files to a container named ‘builders’. Very important not to lose your builders!:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass upload builders /etc/swift/*.builder
  7. Use swift to list your containers:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass list
  8. Use swift to list the contents of your ‘builders’ container:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass list builders
  9. Use swift to download all files from the ‘builders’ container:

    swift -A https://$PROXY_LOCAL_NET_IP:8080/auth/v1.0 -U system:root -K testpass download builders