在CentOS7系统下部署KVM虚拟化管理平台WebVirtMgr

一、安装MySQL

  • 安装(略)
  • 配置
mysql> create database webvirtmgr default character set utf8;
mysql> grant all on webvirtmgr.* to webvirtmgr@"127.0.0.1" identified by "webvirtmgr";

二、部署webvirtmgr

参考官网:https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

  • 安装依赖包
shell> wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
shell> yum -y install git python-pip libvirt-python libxml2-python MySQL-python cyrus-sasl-md5
shell> pip install numpy==1.16.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
shell> pip install websockify==0.8.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
  • 安装并配置django环境
shell> cd /export/home/webroot/
shell> git clone git://github.com/retspen/webvirtmgr.git
shell> cd webvirtmgr
shell> pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

# 以下为定制化二次开发功能组件支持
shell> pip install fabric==2.4.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
# 解压二次开发的压缩包,覆盖/export/home/webroot/webvirtmgr目录下所有文件。
shell> cd /export/home/webroot
shell> wget http://dlsw.91donkey.com/software/source/webvirtmgr/webvirtmgr_custom_development.tgz
shell> mv webvirtmgr webvirtmgr.default
shell> tar zxf webvirtmgr_custom_development.tgz
  • 配置webvirtmgr
# 编辑/export/home/webroot/webvirtmgr/webvirmgr/settings.py
# 将sqlite3改为mysql数据库
#
# 原信息
DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3',

'NAME': os.path.join(os.path.dirname(__file__), '..', 'webvirtmgr.sqlite3'),

# The following settings are not used with sqlite3:

'USER': '',

'PASSWORD': '',

'HOST': '',  # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.

'PORT': '',  # Set to empty string for default.

    }

}

# 替换为
DATABASES = {

'default': {

'ENGINE': 'django.db.backends.mysql',

'NAME': 'webvirtmgr',

'USER': 'webvirtmgr',

'PASSWORD': 'webvirtmgr',

'HOST': '127.0.0.1',  # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.

'PORT': '3306',  # Set to empty string for default.

    }

}



shell> cd /export/home/webvirtmgr

shell> ./manage.py syncdb

Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'root'): root
E-mail address: [email protected]
Password: xxxxxx
Password (again): xxxxxx
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 6 object(s) from 1 fixture(s)


shell> ./manage.py collectstatic

Type 'yes' to continue, or 'no' to cancel: yes



shell> chown -R nobody. /export/home/webroot/
  • 添加其他超级用户
shell> ./manage.py createsuperuser

三、安装Nginx

  • 安装(略)
  • 配置
# 在nginx配置中增加vhost信息
server {
    server_name 10.20.73.74;
    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
    }
}

四、安装Supervisor

shell> pip install supervisor -i http://mirrors.aliyun.com/pypi/simple/--trusted-host mirrors.aliyun.com
shell> mkdir /opt/supervisor && cd /opt/supervisor
shell> echo_supervisord_conf > supervisord.conf
shell> mv supervisord.conf supervisord.conf.default
shell> mkdir /opt/supervisor/conf.d
shell> mkdir /opt/supervisor/log

配置supervisord.conf

shell> cat >> supervisord.conf << EOF
[supervisord]
logfile=/opt/supervisor/supervisord.log
logfile_maxbytes=1024MB
logfile_backups=10
loglevel=info
pidfile=/opt/supervisor/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
directory=/opt/supervisor
nocleanup=true
childlogdir=/opt/supervisor/log

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=http://10.20.73.74:9998

[inet_http_server]
port = 10.20.73.74:9998
username = 91donkey
password = 123456

[include]
files = /opt/supervisor/conf.d/*.conf
EOF

配置conf.d/webvirtmgr.conf

shell> cat >> conf.d/webvirtmgr.conf << EOF
[program:webvirtmgr]
command=/usr/bin/python /export/home/webroot/webvirtmgr/manage.py run_gunicorn -c /export/home/webroot/webvirtmgr/conf/gunicorn.conf.py
directory=/export/home/webroot/webvirtmgr
autostart=true
autorestart=true
logfile=/opt/supervisor/log/webvirtmgr.log
log_stderr=true
user=root

[program:webvirtmgr-console]
command=/usr/bin/python /export/home/webroot/webvirtmgr/console/webvirtmgr-console
directory=/export/home/webroot/webvirtmgr
autostart=true
autorestart=true
stdout_logfile=/opt/supervisor/log/webvirtmgr-console.log
redirect_stderr=true
user=root
EOF

启动supervisor服务

shell> /usr/bin/python /usr/bin/supervisord -c /opt/supervisor/supervisord.conf

转载于:https://www.cnblogs.com/91donkey/p/11476844.html

你可能感兴趣的:(在CentOS7系统下部署KVM虚拟化管理平台WebVirtMgr)