CentOS Horizon 수동 설치

(Horizon 수동 설치에서 넘어옴)

1 개요[ | ]

manual installation of horizon on CentOS
CentOS Horizon 수동 설치

2 사전작업 1[ | ]

  • horizon 제외 packstack 설치
[root@controller ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8774            0.0.0.0:*               LISTEN      12550/python2       
tcp        0      0 0.0.0.0:9191            0.0.0.0:*               LISTEN      14477/python2       
tcp        0      0 0.0.0.0:8775            0.0.0.0:*               LISTEN      12550/python2       
tcp        0      0 0.0.0.0:8776            0.0.0.0:*               LISTEN      11390/python2       
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      9677/beam           
tcp        0      0 127.0.0.1:6633          0.0.0.0:*               LISTEN      19256/python2       
tcp        0      0 192.168.43.233:873      0.0.0.0:*               LISTEN      10697/xinetd        
tcp        0      0 192.168.43.233:27017    0.0.0.0:*               LISTEN      8487/mongod         
tcp        0      0 0.0.0.0:8778            0.0.0.0:*               LISTEN      13657/httpd         
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5076/mysqld         
tcp        0      0 192.168.43.233:6379     0.0.0.0:*               LISTEN      9141/redis-server 1 
tcp        0      0 0.0.0.0:11211           0.0.0.0:*               LISTEN      7692/memcached      
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      14409/python2       
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 127.0.0.1:6640          0.0.0.0:*               LISTEN      18378/ovsdb-server  
tcp        0      0 192.168.43.233:6000     0.0.0.0:*               LISTEN      17513/python2       
tcp        0      0 192.168.43.233:8080     0.0.0.0:*               LISTEN      15792/python2       
tcp        0      0 192.168.43.233:6001     0.0.0.0:*               LISTEN      17302/python2       
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 192.168.43.233:6002     0.0.0.0:*               LISTEN      17083/python2       
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      604/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      853/master          
tcp        0      0 0.0.0.0:16509           0.0.0.0:*               LISTEN      21273/libvirtd      
tcp        0      0 0.0.0.0:9696            0.0.0.0:*               LISTEN      16503/python2       
tcp        0      0 0.0.0.0:6080            0.0.0.0:*               LISTEN      12876/python2       
tcp6       0      0 :::5000                 :::*                    LISTEN      13657/httpd         
tcp6       0      0 :::5672                 :::*                    LISTEN      9677/beam           
tcp6       0      0 :::8777                 :::*                    LISTEN      13657/httpd         
tcp6       0      0 :::8041                 :::*                    LISTEN      13657/httpd         
tcp6       0      0 :::8042                 :::*                    LISTEN      13657/httpd         
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::80                   :::*                    LISTEN      13657/httpd         
tcp6       0      0 :::22                   :::*                    LISTEN      604/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      853/master          
tcp6       0      0 :::16509                :::*                    LISTEN      21273/libvirtd      
tcp6       0      0 :::35357                :::*                    LISTEN      13657/httpd

3 사전작업 2[ | ]

yum install python-devel python-pip gcc git
[root@controller ~]# python -V
Python 2.7.5
[root@controller ~]# rpm -q python-devel
python-devel-2.7.5-48.el7.x86_64
[root@controller ~]# pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
[root@controller ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@controller ~]# git --version
git version 1.8.3.1

4 git clone[ | ]

[root@controller ~]# cd /usr/local/
[root@controller local]# git clone https://git.openstack.org/openstack/horizon -b stable/ocata --depth=1
Cloning into 'horizon'...
remote: Counting objects: 2891, done.
remote: Compressing objects: 100% (2490/2490), done.
remote: Total 2891 (delta 841), reused 1028 (delta 184)
Receiving objects: 100% (2891/2891), 3.82 MiB | 620.00 KiB/s, done.
Resolving deltas: 100% (841/841), done.

5 pip install[ | ]

  • pip로 django 및 Python 라이브러리 등을 설치함
[root@controller local]# cd horizon
[root@controller horizon]# pip install -c http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata .
Ignoring dnspython3: markers u"python_version=='3.4'" don't match your environment
Ignoring dnspython3: markers u"python_version=='3.5'" don't match your environment
Processing /usr/local/horizon
Requirement already satisfied (use --upgrade to upgrade): Babel===2.3.4 in /usr/lib/python2.7/site-packages (from -c http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata (line 2))
Collecting Django===1.8.17 (from -c http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata (line 4))
  Downloading Django-1.8.17-py2.py3-none-any.whl (6.2MB)
    100% |████████████████████████████████| 6.2MB 167kB/s 
Collecting Pint===0.7.2 (from -c http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata (line 16))
  Downloading Pint-0.7.2.tar.gz (149kB)
    100% |████████████████████████████████| 153kB 2.6MB/s 
... (생략)
  Running setup.py install for horizon ... done
Successfully installed django-compressor-2.1 django-openstack-auth-3.1.1 django-pyscss-2.0.2 enum34-1.1.6 horizon-0.0.0 netaddr-0.7.19 pathlib-1.0.1 pyScss-1.3.4 pymongo-3.4.0 python-heatclient-1.8.1 pytz-2016.10 rcssmin-1.0.6 requests-2.12.5 rjsmin-1.0.12

6 설정파일 생성[ | ]

[root@controller horizon]# cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py
[root@controller horizon]# cat openstack_dashboard/local/local_settings.py | grep ^DEBUG
DEBUG = True
[root@controller horizon]# cat openstack_dashboard/local/local_settings.py | grep OPENSTACK_HOST
OPENSTACK_HOST = "127.0.0.1"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
[root@controller horizon]# cat openstack_dashboard/local/local_settings.py | grep ^CACHES -A4
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
[root@controller horizon]# vi openstack_dashboard/local/local_settings.py
#WEBROOT = '/'
WEBROOT = '/dashboard/'

#ALLOWED_HOSTS = ['horizon.example.com', ]
ALLOWED_HOSTS = ['*']

# 아래는 주석 해제
OPENSTACK_API_VERSIONS = {
    "data-processing": 1.1,
    "identity": 3,
    "image": 2,
    "volume": 2,
    "compute": 2,
}

# 아래는 신규 추가
COMPRESS_OFFLINE = True

7 메시지 컴파일[ | ]

  • US English 외의 다국어 지원을 위한 것
[root@controller horizon]# ./manage.py compilemessages
processing file django.po in /usr/local/horizon/horizon/locale/fi_FI/LC_MESSAGES
processing file django.po in /usr/local/horizon/horizon/locale/ca/LC_MESSAGES
processing file django.po in /usr/local/horizon/horizon/locale/it/LC_MESSAGE
... (생략)
processing file django.po in /usr/local/horizon/openstack_dashboard/locale/ks/LC_MESSAGES
processing file django.po in /usr/local/horizon/openstack_dashboard/locale/mr/LC_MESSAGES
processing file django.po in /usr/local/horizon/openstack_dashboard/locale/pl_PL/LC_MESSAGES

8 정적 asset 적용[ | ]

[root@controller horizon]# ./manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    /usr/local/horizon/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
... (생략)
Copying '/usr/local/horizon/horizon/static/horizon/tests/jasmine/string.legacy-spec.js'
Copying '/usr/local/horizon/horizon/static/horizon/tests/jasmine/tables.legacy-spec.js'
Copying '/usr/local/horizon/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js'

1761 static files copied to '/usr/local/horizon/static'.
[root@controller horizon]# ./manage.py compress
Found 'compress' tags in:
	/usr/local/horizon/openstack_dashboard/templates/horizon/_conf.html
	/usr/local/horizon/openstack_dashboard/templates/_stylesheets.html
	/usr/local/horizon/openstack_dashboard/templates/horizon/_scripts.html
Compressing... done
Compressed 6 block(s) from 3 template(s) for 2 context(s).

9 방화벽 설정·재시작[ | ]

  • iptables 파일에 내용 추가하고 적용
[root@controller horizon]# iptables -L | grep http
[root@controller horizon]# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m multiport --dports 5000,35357 -m comment --comment "001 keystone incoming keystone" -j ACCEPT
-A INPUT -p tcp -m multiport --dports 80 -m comment --comment "001 horizon 80 incoming" -j ACCEPT
-A INPUT -s 192.168.43.233/32 -p tcp -m multiport --dports 3306 -m comment --comment "001 mariadb incoming mariadb_192.168.43.233" -j ACCEPT
→ keystone이 있는 줄의 바로 다음 추가하면 됨
[root@controller horizon]# systemctl restart iptables
[root@controller horizon]# iptables -L | grep http
ACCEPT     tcp  --  anywhere             anywhere             multiport dports http /* 001 horizon 80 incoming */

10 비밀키저장소 파일[ | ]

[root@controller horizon]# touch openstack_dashboard/local/.secret_key_store
[root@controller horizon]# chown apache. openstack_dashboard/local/.secret_key_store
[root@controller horizon]# chmod 0600 openstack_dashboard/local/.secret_key_store
[root@controller horizon]#

11 아파치 설정·재시작[ | ]

  • horizon 아파치 설정파일 신규 작성
[root@controller horizon]# vi /etc/httpd/conf.d/horizon.conf
<VirtualHost *:80>
    ServerName  controller.openstack.test
    ServerAlias 192.168.56.101
    ServerAlias localhost

    DocumentRoot /usr/local/horizon/
    ErrorLog /var/log/httpd/horizon_error.log
    CustomLog /var/log/httpd/horizon_access.log combined
    LogLevel warn

    WSGIDaemonProcess apache group=apache processes=3 threads=10 user=apache
    WSGIProcessGroup apache
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias /dashboard /usr/local/horizon/openstack_dashboard/wsgi/django.wsgi
    Alias /dashboard/static /usr/local/horizon/static
    RedirectMatch permanent  ^/$ /dashboard

    <Location "/">
        Require all granted
    </Location>
    <Location "/static">
        SetHandler None
    </Location>
</Virtualhost>
[root@controller horizon]# systemctl restart httpd
[root@controller horizon]#

12 테스트[ | ]

[root@controller horizon]# curl -I localhost
HTTP/1.1 301 Moved Permanently
Date: Fri, 22 Sep 2017 11:09:21 GMT
Server: Apache/2.4.6 (CentOS)
Location: http://localhost/dashboard
Connection: close
Content-Type: text/html; charset=iso-8859-1
[root@controller horizon]# curl -I http://localhost/dashboard
HTTP/1.1 302 FOUND
Date: Fri, 22 Sep 2017 11:08:37 GMT
Server: Apache/2.4.6 (CentOS)
Vary: Accept-Language,Cookie
X-Frame-Options: SAMEORIGIN
Content-Language: en
Location: http://localhost/dashboard/auth/login/?next=/dashboard/
Connection: close
Content-Type: text/html; charset=utf-8
[root@controller horizon]# curl -I http://localhost/dashboard/auth/login/?next=/dashboard/
HTTP/1.1 200 OK
Date: Fri, 22 Sep 2017 11:09:59 GMT
Server: Apache/2.4.6 (CentOS)
Content-Language: en
Expires: Fri, 22 Sep 2017 11:09:59 GMT
Vary: Cookie,Accept-Language,Accept-Encoding
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
X-Frame-Options: SAMEORIGIN
Set-Cookie: csrftoken=jjEQVnctC8mpsZ0OxNffcyxKSRiFbjSp; Path=/
Last-Modified: Fri, 22 Sep 2017 11:09:59 GMT
Content-Length: 8637
Connection: close
Content-Type: text/html; charset=utf-8

13 같이 보기[ | ]

14 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}