openstack

openstack - swift 설치

sysman 2021. 1. 19. 19:12
hostname ip os  role storage
controller x.x.x.110 centos 7.3 proxy  
compute x.x.x.111 centos 7.3 storage 1 node /dev/sdc 20gb
network x.x.x.112 centos 7.3 storage 2 node /dev/sdc 20gb

 

 

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

####### controller node 설정 ######

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

 

[root@controller ~]# source ~/keystonerc
[root@controller ~]# openstack user create --domain default --project service --password-prompt swift
User Password: swift
Repeat User Password: swift

 

[root@controller ~]# openstack role add --project service --user swift admin
[root@controller ~]# openstack service create --name swift --description "OpenStack Object Storage" object-store

[root@controller ~]# openstack endpoint create --region RegionOne object-store public http://192.168.100.110:8080/v1/AUTH_%\(tenant_id\)s

[root@controller ~]# openstack endpoint create --region RegionOne object-store internal http://192.168.100.110:8080/v1/AUTH_%\(tenant_id\)s

[root@controller ~]# openstack endpoint create --region RegionOne object-store admin http://192.168.100.110:8080/v1/AUTH_%\(tenant_id\)s

 

[root@controller ~]# openstack user list

[root@controller ~]# openstack service list

[root@controller ~]# openstack endpoint list | grep swift

 

[root@controller ~]# yum install openstack-swift-proxy python-swiftclient memcached python-memcached openssh-clients python-keystoneclient python-keystonemiddleware -y

[root@controller ~]# cp /etc/swift/proxy-server.conf /etc/swift/proxy-server.conf.bak

[root@controller ~]# vi /etc/swift/proxy-server.conf

[DEFAULT]
bind_port = 8080
user = swift
swift_dir = /etc/swift

 

순서조심

[pipeline:main]

pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk tempurl ratelimit authtoken keystone copy container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server

 

[filter:cache]
use = egg:swift#memcache
memcache_servers = 192.168.100.110:11211

 

[filter:keystone]
use = egg:swift#keystoneauth
operator_roles = admin,user

 

[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
www_authenticate_uri = http://192.168.100.110:5000
auth_url = http://192.168.100.110:5000
memcached_servers = 192.168.100.110:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = swift
password = swift
delay_auth_decision = True

 

 

3개 node 전부 같아야 한다.

[root@controller ~]# vi /etc/swift/swift.conf

[swift-hash]
swift_hash_path_suffix = HASH_PATH_SUFFIX
swift_pash_path_prefix = HASH_PATH_PREFIX

 

 

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

####### compute/network(storage) node 설정 ######

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

 

 

패키지 설치

[root@compute ~]# yum install openstack-swift-account openstack-swift-container openstack-swift-object xfsprogs rysnc openssh-clients python2-swiftclient -y 

 

볼륨 마운트

[root@compute ~]# fdisk -l 

[root@compute ~]# mkfs.xfs /dev/sdc

[root@compute ~]# mkdir -p /srv/node/sdc 
[root@compute ~]# vi /etc/fstab 

/dev/sdc                /srv/node/sdc           xfs     noatime,nodiratime,nobarrier,logbufs=8  0 2 

[root@compute ~]# mount -a 
[root@compute ~]# df  

[root@compute ~]# mount | grep sdc 

 

rsync 설정

[root@compute ~]# vi /etc/rsyncd.conf

uid = swift 
gid = swift 

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log

address = 192.168.100.111

 

[account]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/account.lock

 

[container]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/container.lock

 

[object]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/object.lock

  

[swift_server]

path = /etc/swift/

read only = true

max connections = 5

lock file = /var/lock/swift_server.lock

 

[root@compute ~]# systemctl enable rsyncd 

[root@compute ~]# systemctl start rsyncd 

[root@compute ~]# systemctl status rsyncd 

 

[root@compute ~]# lsof -i tcp:873 

 

swift 설정

[root@compute ~]# cp /etc/swift/swift.conf /etc/swift/swift.conf.bak

[root@compute ~]# vi /etc/swift/swift.conf

[swift-hash]  
swift_hash_path_suffix = HASH_PATH_SUFFIX 
swift_pash_path_prefix = HASH_PATH_PREFIX 

[root@compute ~]# vi /etc/swift/account-server.conf

bind_ip = 0.0.0.0 
bind_port = 6202 
user = swift 
swift_dir = /etc/swift 
devices = /srv/node 
mount_check = True 

[pipeline:main] 
pipeline =  account-server 

[app:account-server] 
use = egg:swift#account 

[root@compute ~]# vi /etc/swift/container-server.conf

bind_ip = 0.0.0.0 
bind_port = 6201 
user = swift 
swift_dir = /etc/swift 
devices = /srv/node 
mount_check = True

[pipeline:main] 
pipeline = container-server 

[app:container-server] 
use = egg:swift#container 

 

[root@compute ~]# vi /etc/swift/object-server.conf

bind_ip = 0.0.0.0 
bind_port = 6200 
user = swift 
swift_dir = /etc/swift 
devices = /srv/node 
mount_check = True 

[pipeline:main] 
pipeline = object-server 

[app:object-server] 
use = egg:swift#object 

 

스위프트 서비스 마운트 디렉토리

[root@compute ~]# chown -R swift.swift /srv/node

[root@compute ~]# mkdir -p /var/cache/swift

스위프트 서비스가 저장될 캐시 디렉토리

[root@compute ~]# chown -R root.swift /var/cache/swift

[root@compute ~]# chmod -R 775 /var/cache/swift

패키지 설치

[root@network ~]# yum install openstack-swift-account openstack-swift-container openstack-swift-object xfsprogs rsync openssh-clients python2-swiftclient -y

볼륨마운트

[root@network ~]# mkfs.xfs /dev/sdc

[root@network ~]# mkdir -p /srv/node/sdc
[root@network ~]# vi /etc/fstab
[root@network ~]# /dev/sdc                /srv/node/sdc           xfs     noatime,nodiratime,nobarrier,logbufs=8  0 2

[root@network ~]# mount -a
[root@network ~]# df  
[root@network ~]# mount | grep sdc

rsync 설정

[root@network ~]# vi /etc/rsyncd.conf

uid = swift

gid = swift

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log

address = 192.168.100.112

 

[account]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/account.lock

 

[container]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/container.lock

 

[object]

path = /srv/node/

read only = false

max connections = 25

lock file = /var/lock/object.lock

 

[swift_server]

path = /etc/swift

read only = true

max connections = 5

lock file = /var/lock/swift_server.lock


[root@network ~]# systemctl enable rsyncd
[root@network ~]# systemctl start rsyncd
[root@network ~]# systemctl status rsyncd

[root@network ~]# lsof -i tcp:873

swift 설정
[root@network ~]# cp /etc/swift/swift.conf /etc/swift/swift.conf.bak

[root@network ~]# vi /etc/swift/swift.conf

[swift-hash]  
swift_hash_path_suffix = HASH_PATH_SUFFIX 
swift_pash_path_prefix = HASH_PATH_PREFIX 

[root@network ~]# vi /etc/swift/account-server.conf
bind_ip = 0.0.0.0
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[root@network ~]# vi /etc/swift/container-server.conf

bind_ip = 0.0.0.0

bind_port = 6201

user = swift

swift_dir = /etc/swift

devices = /srv/node

mount_check = True

 

[pipeline:main]

pipeline = container-server

 

[app:container-server]

use = egg:swift#container

[root@network ~]# vi /etc/swift/object-server.conf

bind_ip = 0.0.0.0
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True


[pipeline:main]
pipeline = object-server

[app:object-server]
use = egg:swift#object

스위프트 서비스 마운트 디렉토리

[root@network ~]# chown -R swift.swift /srv/node

[root@network ~]# mkdir -p /var/cache/swift
스위프트 서비스가 저장될 캐시 디렉토리

[root@network ~]# chown -R root.swift /var/cache/swift

[root@network ~]# chmod -R 775 /var/cache/swift/

 

 

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

####### controller node 설정 ######

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

swift 링 생성
[root@controller ~]# cd /etc/swift/

10 : 최대 파티션 수 2: 복제 수 1: 파티션 복제 잠금시간 100 :장치간 균형유지와 비교위한 상대값
[root@controller swift]# swift-ring-builder account.builder create 10 2 1
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.111 --port 6202 --device sdc --weight 100
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 2 --ip 192.168.100.112 --port 6202 --device sdc --weight 100
[root@controller swift]# swift-ring-builder account.builder
[root@controller swift]# swift-ring-builder account.builder rebalance

[root@controller swift]# swift-ring-builder container.builder create 10 2 1
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.111 --port 6201 --device sdc --weight 100

[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 2 --ip 192.168.100.112 --port 6201 --device sdc --weight 100

[root@controller swift]# swift-ring-builder container.builder

[root@controller swift]# swift-ring-builder container.builder rebalance

 

[root@controller swift]# swift-ring-builder object.builder create 10 2 1
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.111 --port 6200 --device sdc --weight 100

[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 2 --ip 192.168.100.112 --port 6200 --device sdc --weight 100

[root@controller swift]# swift-ring-builder object.builder

[root@controller swift]# swift-ring-builder object.builder rebalance

 

생성한 링을 각 노드에 복제

[root@controller swift]# scp *.gz root@192.168.100.111:/etc/swift

[root@controller swift]# scp *.gz root@192.168.100.112:/etc/swift

 

각 노드 링 파일 소유자 및 그룹 변경

[root@controller swift]# chown swift.swift /etc/swift/*.gz

[root@network swift]# chown swift.swift /etc/swift/*.gz

[root@compute swift]# chown swift.swift /etc/swift/*.gz

 

컨트롤러 노드 그룹 변경

[root@controller swift]# chown -R root:swift /etc/swift

 

swift proxy 서비스 시작

[root@controller swift]# systemctl enable openstack-swift-proxy memccached 

[root@controller swift]# systemctl start openstack-swift-proxy memccached

[root@controller ~]# lsof -i tcp:8080

[root@controller ~]# ls -l /var/log/swift

 

 

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

####### compute/network(storage) node 서비스 실행 ######

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

[root@compute swift]# chown -R root:swift /etc/swift

[root@compute swift]# systemctl enable openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicator
[root@compute swift]# systemctl start openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicator

[root@compute swift]# systemctl enable openstack-swift-container openstack-swift-container-auditor openstack-swift-container-updater openstack-swift-container-replicator
[root@compute swift]# systemctl start openstack-swift-container openstack-swift-container-auditor openstack-swift-container-updater openstack-swift-container-replicator

[root@compute swift]# systemctl enable openstack-swift-object openstack-swift-object-auditor openstack-swift-object-updater openstack-swift-object-replicator
[root@compute swift]# systemctl start openstack-swift-object openstack-swift-object-auditor openstack-swift-object-updater openstack-swift-object-replicator

[root@compute swift]# lsof -i tcp:6200
[root@compute swift]# lsof -i tcp:6201
[root@compute swift]# lsof -i tcp:6202



[root@network swift]# chown -R root:swift /etc/swift

[root@network swift]# systemctl enable openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicator
[root@network swift]# systemctl start openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicator

[root@network swift]# systemctl enable openstack-swift-container openstack-swift-container-auditor openstack-swift-container-updater openstack-swift-container-replicator
[root@network swift]# systemctl start openstack-swift-container openstack-swift-container-auditor openstack-swift-container-updater openstack-swift-container-replicator

[root@network swift]# systemctl enable openstack-swift-object openstack-swift-object-auditor openstack-swift-object-updater openstack-swift-object-replicator
[root@network swift]# systemctl start openstack-swift-object openstack-swift-object-auditor openstack-swift-object-updater openstack-swift-object-replicator

[root@network swift]# lsof -i tcp:6200
[root@network swift]# lsof -i tcp:6201
[root@network swift]# lsof -i tcp:6202



 

 

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

####### controller node 에서 검증 ######

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

컨테이너 생성 후 파일 컨테이너 넣고 확인

[root@controller swift]# swift stat

[root@controller swift]# openstack container create container1

[root@controller ~]# cat /etc/passwd > FILE

[root@controller ~]# openstack object create container1 FILE

[root@controller ~]# openstack object list container1

[root@controller ~]# swift stat

브라우저에서도 확인 가능