Monasca安装配置指导(3/3) - 安装thresh、UI
作者:张航东
OpenStack版本:Newton
Linux:CentOS 7
本文主要用于个人学习、总结,欢迎转载,但请务必注明作者和出处,感谢!
7 monasca-thresh
PS:monasca-thresh是JAVA工程,所以需要maven工具进行先进行编译
7.1 安装 apache-maven
下载(apache-maven-3.5.0-bin.tar.gz):
http://maven.apache.org/download.cgi
解压:
#tar -xvf apache-maven-3.5.0-bin.tar.gz
**目录内的bin/mvn就是编译monasca-thresh工程需要的工具,
直接使用,或添加到环境变量,修改 /etc/profile中,添加如下内容:**
MAVEN_HOME=/usr/local/apache-maven-3.5.0
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
使配置生效:
#source /etc/profile
7.2 编译monasca-thresh工程
PS:monasca-thresh需要依赖monasca-common(基本所有monasca的组件都依赖common),common同时支持java和python,但是thresh目前只有java版本,所以我们需要先将common编译thresh可以引用的java包。
7.2.1 编译monasca-common
进入monasca-common目录,执行mvn命令编译:
#mvn clean install
7.2.2 编译monasca-thresh
下载:
#git clone https://github.com/openstack/monasca-thresh.git
#cd monasca-thresh
执行mvn命令编译:
#mvn package
执行完后, ./target/monasca-thresh-x.x.x-SNAPSHOT-shaded.jar 便是我们需要的thresh运行程序。
不过,这个程序并不能直接运行,需要运行在apache storm平台上。
7.3 安装apache storm
下载(apache-storm-1.1.1.tar.gz):
http://storm.apache.org/downloads.html
解压:
#tar xvf apache-storm-1.1.1.tar.gz
#cd apache-storm-1.1.1
修改配置文件 /conf/storm.yaml,添加如下内容:
########### These MUST be filled in for a storm configuration
storm.zookeeper.servers:
- “127.0.0.1”
nimbus.seeds: [“127.0.0.1”]
启动:
#bin/storm nimbus
#bin/storm supervisor
7.4 启动monasca-thresh
在7.2中,我们已经成功编译除了monasca-thresh运行的jar包(…/monasca-thresh/thresh/target/ monasca-thresh-x.x.x-SNAPSHOT-shaded.jar)
这一步,我们要基于apache storm平台,来启动monasca-thresh。
7.4.1 配置
**进去monasca-thresh工程目录
拷贝配置文件模板到 etc/monasca/目录下**
#cp thresh/src/main/config/thresh-sample-config.yml /etc/monasca/thresh.conf
修改配置文件/etc/monasca/thresh.conf,修改一下几项:
…
zookeeperConnect: 127.0.0.1:2181 (多处)
…
metadataBrokerList: 127.0.0.1:9092
…
database:
driverClass: “com.mysql.jdbc.jdbc2.optional.MysqlDataSource”
url: “jdbc:mysql://10.127.2.121/monasca?useSSL=true”
user: “monasca”
password: “monasca”
…
statsdConfig:
host: 127.0.0.1
port: 8125
7.4.2 启动
#…/apache-storm-1.1.1/bin/storm jar …/monasca-thresh/thresh/target/ monasca-thresh-x.x.x-SNAPSHOT-shaded.jar monasca.thresh.ThresholdingEngine /etc/monasca/thresh.conf thresh-cluster
8 monasca-ui
8.1 安装 horizon (源码方式)
(参考:https://docs.openstack.org/horizon/latest/install/from-source.html)
下载安装(PS:由于权限问题,尽量避免下载到/root目录,建议下载到/opt目录)
#git clone https://github.com/openstack/horizon.git
#cd horizon
#pip install -r requirements.txt
生成local_settings.py
#cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py
修改local_settings.py,配置内容如下:
COMPRESS_OFFLINE = True
ALLOWED_HOSTS = [‘*’, ]
OPENSTACK_API_VERSIONS = {
“identity”: 3,
“image”: 2,
“volume”: 2,
}OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = ‘Default’OPENSTACK_HOST = “10.127.2.121”
OPENSTACK_KEYSTONE_URL = “http://10.127.2.121:5000/v3”
OPENSTACK_KEYSTONE_DEFAULT_ROLE = “_member_”
安装语言包
#apt-get install gettext
#./manage.py compilemessages
静态文件压缩
#./manage.py collectstatic
#./manage.py compress
生成wsgi配置文件horizon.conf
#./manage.py make_web_conf –apache > /etc/httpd/conf.d/horizon.conf
修改horizon.conf,配置内容如下:
<VirtualHost *:80>
ServerAdmin webmaster@openstack.org
ServerName openstack_dashboard
DocumentRoot /opt/horizon/
LogLevel warn
ErrorLog /var/log/httpd/openstack_dashboard-error.log
CustomLog /var/log/httpd/openstack_dashboard-access.log combined
WSGIScriptReloading On
WSGIDaemonProcess openstack_dashboard_website
WSGIProcessGroup openstack_dashboard_website
WSGIApplicationGroup openstack_dashboard_website
WSGIPassAuthorization On
WSGIScriptAlias / /opt/horizon/openstack_dashboard/wsgi/horizon.wsgi
<Location "/">
Require all granted
</Location>
Alias /static /opt/horizon/static
<Location "/static">
SetHandler None
</Location>
</Virtualhost>
重启httpd服务:
#systemctl restart httpd
8.2 安装 monasca-ui
(参考:https://github.com/openstack/monasca-ui)
在horizon的requirements.txt中添加对monasca-ui的支持
进入已下载的horizon工程的目录,
#vi requirements.txt
在末尾添加如下内容:
再次执行命令(安装horzion时执行过一次)
#pip install -r requirements.txt
将monasca链接到horizon
#ln -sf $(pwd)/../monasca-ui/monitoring/enabled/_50_admin_add_monitoring_panel.py $(pwd)/openstack_dashboard/enabled/_50_admin_add_monitoring_panel.py
#ln -sf $(pwd)/../monasca-ui/monitoring/conf/monitoring_policy.json $(pwd)/openstack_dashboard/conf/monitoring_policy.json
#ln -sfF $(pwd)/../monasca-ui/monitoring $(pwd)/monitoring
重启httpd服务:
#systemctl restart httpd