본문 바로가기

programming/openstack

데브스택 설치, 에러해결 [To install Devstack and trouble shooting]

 

Devstack은 git master의 모든 최신 버전을 기반으로 Openstack 환경을 간편하게 설치할 수 있는 확장 가능한 스크립트입니다.

대부분의 Openstack를 공부 하고자 하는 초심자나 Openstack에서 기능을 추가하고자 하는 분들이 개발환경을 위해 사용합니다.

 

※Devstack은 설치 중에 시스템을 크게 변화시킵니다. 고로 이러한 용도로만 사용되는 VM이나 서버로만 Devstack을 실행하는 것이 좋습니다.

 

1. 환경준비

사용되는 환경은 리눅스입니다. 테스트 가능한 환경에서 리눅스를 새로 설치하는 게 깨끗하고 최소의 리눅스 환경이기에 가장 좋습니다. 그중에서 우분투 16.04가 가장 많이 테스트되고 가장 설치가 잘 진행됩니다. 에러 검색 시에 여러 커뮤니티에서도 우분투 16.04 환경에서 답변이 제일 많습니다. 

 

2. stack 사용자 추가

Devstack은 sudo가 활성화 된 루트가 아닌 사용자로 실행해야합니다

DevStack을 실행할 별도의 스택 사용자를 신속하게 생성 할 수 있습니다.

$ sudo useradd -s /bin/bash -d /opt/stack -m stack

이 사용자는 시스템을 많이 변경하기 때문에 sudo 권한이 있어야 합니다.

$ echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack 
$ sudo su - stack

 

3. Devstack 다운로드

git 명령어를 통해 devstack 저장소를 clone 합니다. 항상 최신버전의 openstack버전을 clone합니다. 이때 git가 없다면 apt-get install git로 설치를 해야 합니다.

$ git clone https://git.openstack.org/openstack-dev/devstack
$ cd devstack

현재 글 쓰는 시점에서 설치되는 DevStack Version: stein 이기 때문에 stein 말고 구버전을 설치하고 싶다면 -b 옵션을 사용하면 됩니다. 저는 로키 버전의 keysteon과 ldap을 연동하려고 하기 때문에 -b 옵션으로 새로 설치합니다.

$ git clone -b stable/rocky https://git.openstack.org/openstack-dev/devstack
$ cd devstack

 

4. local.conf 만들기

devstack git repo의 루트에 미리 설정된 4개의 비밀번호로 파일을 만듭니다.

[[local|localrc]]
ADMIN_PASSWORD=secret                #이 부분을 자신이 원하는 비밀번호로 설정하시면 됩니다.
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD

위의 구성은 Devstack을 시작하기 위한 최소한의 필수 구성입니다. 

controller과 compute 노드를 따로 설치하여 인스턴스를 생성하고 싶거나 다른 추가적인 설정이 필요하다면 아래를 참고하거나 문서를 읽어보시는 걸 추천드립니다.

local.conf
0.00MB

# Sample ``local.conf`` for user-configurable variables in ``stack.sh`` 
# NOTE: Copy this file to the root DevStack directory for it to work properly.
# ``local.conf`` is a user-maintained settings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``local.conf`` effectively override the
# default values. 
# This is a collection of some of the settings we have found to be useful 
# in our DevStack development environments. Additional settings are described 
# in https://docs.openstack.org/devstack/latest/configuration.html 
#local-conf
# These should be considered as samples and are unsupported DevStack code.
# The ``localrc`` section replaces the old ``localrc`` configuration file. 
# Note that if ``localrc`` is present it will be used in favor of this section.
[[local|localrc]] 
# Minimal Contents
# ----------------
# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when
# there are a few minimal variables set: 
# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter 
# values for them by ``stack.sh``and they will be added to ``local.conf``. 
ADMIN_PASSWORD=nomoresecret
DATABASE_PASSWORD=stackdb 
RABBIT_PASSWORD=stackqueue
SERVICE_PASSWORD=$ADMIN_PASSWORD 
# ``HOST_IP`` and ``HOST_IPV6`` should be set manually for best results if
# the NIC configuration of the host is unusual, i.e. ``eth1`` has the default
# route but ``eth0`` is the public interface.  They are auto-detected in 
# ``stack.sh`` but often is indeterminate on later runs due to the IP moving
# from an Ethernet interface to a bridge on the host. Setting it here also
# makes it available for ``openrc`` to include when setting ``OS_AUTH_URL``.
# Neither is set by default.
#HOST_IP=w.x.y.z
#HOST_IPV6=2001:db8::7
# Logging 
# ------- 
# By default ``stack.sh`` output only goes to the terminal where it runs.  It can
# be configured to additionally log to a file by setting ``LOGFILE`` to the full
# path of the destination log file.  A timestamp will be appended to the given name.LOGFILE=$DEST/logs/stack.sh.log
# Old log files are automatically removed after 7 days to keep things neat.  Change
# the number of days by setting ``LOGDAYS``.LOGDAYS=2
# Nova logs will be colorized if ``SYSLOG`` is not set; turn this off by setting
# ``LOG_COLOR`` false.
#LOG_COLOR=False
# Using milestone-proposed branches 
# ---------------------------------
# Uncomment these to grab the milestone-proposed branches from the
# repos:
#CINDER_BRANCH=milestone-proposed 
#GLANCE_BRANCH=milestone-proposed
#HORIZON_BRANCH=milestone-proposed
#KEYSTONE_BRANCH=milestone-proposed
#KEYSTONECLIENT_BRANCH=milestone-proposed
#NOVA_BRANCH=milestone-proposed 
#NOVACLIENT_BRANCH=milestone-proposed
#NEUTRON_BRANCH=milestone-proposed 
#SWIFT_BRANCH=milestone-proposed 
# Using git versions of clients
# -----------------------------
# By default clients are installed from pip.  See LIBS_FROM_GIT in
# stackrc for details on getting clients from specific branches or 
# revisions.  e.g. 
# LIBS_FROM_GIT="python-ironicclient"
# IRONICCLIENT_BRANCH=refs/changes/44/2.../1 
# Swift
# -----
# Swift is now used as the back-end for the S3-like object store. Setting the
# hash value is required and you will be prompted for it if Swift is enabled
# so just set it to something already:SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
# For development purposes the default of 3 replicas is usually not required.
# Set this to 1 to save some resources:SWIFT_REPLICAS=1 
# The data for Swift is stored by default in (``$DEST/data/swift``), 
# or (``$DATA_DIR/swift``) if ``DATA_DIR`` has been set, and can be
# moved by setting ``SWIFT_DATA_DIR``. The directory will be created
# if it does not exist.SWIFT_DATA_DIR=$DEST/data

 

5. 설치 시작

$ ./stack.sh

인터넷 연결 속도에 따라 20분 정도 소요됩니다. 이과정에서 많은 자식 tree와 패키지가 설치됩니다.

 

 

6. 트러블 슈팅

Devstack을 설치하는 과정에서 여러 종류의 에러가 나올 수 있습니다.

구글링이나 커뮤니티에 설루션이 있기 때문에 해결 가능한 문제들이 많습니다.

 

대부분의 에러는 local.conf파일을 잘못 수정하거나 설치 환경이 깨끗하지 않아서 입니다. 

에러를 고친후에 ./unstack.sh 후 ./stack.sh로 재설치를 하면 됩니다.

 

 

 

아래에는 제가 설치를 해보면서 해결했던 에러들을 써봅니다..

[Error] Didn’t find service registered by hostname after 60 seconds:

-       local.confENABLED_SERVICES=placement-api 추가해보라는

cp: cannot stat '/opt/stack/neutron/etc/policy.json': No such file or directory

-       /opt/stack/neutron/etc/policy.json에 빈 파일을 만들어줬더니 해결되었음.

/opt/stack/devstack/lib/databases/mysql: line 56: mysql: command not found
+lib/databases/mysql:recreate_database_mysql:1  exit_trap

-       mysql 실행할 때 mysql command를 찾을 수 없기 때문에 나오는 에러.

-       mysql의 명령어 경로 (/usr/local/mysql/bin)를 환경변수로 지정하지 않은 경우 bin폴더 외부에서 명령어를

-       호출했을 경우 발생

-       sudo vi /etc/profile으로 프로파일을 수정하면 된다.(권한 필요) 정보 맨 하단으로 이동하여 

-       export DB_HOME=/usr/local/mysql

-       export PATH="$PATH:/usr/local/mysql/bin"

-       을 추가한다.

위와 같이 했음에도 같은 에러가 보일 경우 

-       mysql설치 비밀번호를 변경해 주어야 한다.(이전에 설치돼있는 경우)

-       cat /etc/init.d/mysql 

-       dpkg -l | grep mysql-server

-       aptitude show mysql-server | grep ^State

-       명령어로 mysql확인

-       apt-get install mysql-server

-       위 명령어로 mysql-server설치 이때 MySQL의 root 계정 패스워드를 local.conf의 DATABASE_PASSWORD

-       와 같아야 한다.