ceilometer+gnocchi 安装

ceilometer 和 gnocchi 安装

ceilometer
安装:https://docs.openstack.org/project-install-guide/telemetry/ocata/install-base-rdo.html
这里分控制节点,和计算节点,注意分清安装步骤
这两安装官网安装就行,一下步骤与官网一致,建议先看官网

步骤一 安装配置ceilometer

设置环境变量

 $ . admin-openrc

创建认证用户ceilometer

openstack user create --domain default --password-prompt ceilometer

新增角色

openstack role add --project service --user ceilometer admin

创建ceilometer的服务实体

openstack service create --name ceilometer --description "Telemetry" metering

安装ceilometer

yum install  openstack-ceilometer-collector openstack-ceilometer-notification openstack-ceilometer-central python-ceilometerclient  

配置 /etc/ceilometer/ceilometer.conf

    [DEFAULT]
    ...
    meter_dispatchers=gnocchi
    event_dispatchers=gnocchi

    [dispatcher_gnocchi]
    # filter out Gnocchi-related activity meters (Swift driver)
    filter_service_activity = False
    # default metric storage archival policy
    archive_policy = low

    [DEFAULT]
    ...
    transport_url = rabbit://openstack:RABBIT_PASS@controller

RABBIT_PASS是你的密码

[service_credentials]
...
auth_type = password
auth_url = http://controller:5000/v3
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = CEILOMETER_PASS
interface = internalURL
region_name = RegionOne

CEILOMETER_PASS这里的密码与前面设置认证时的密码一致

注意
可以通过修改pipeline.yaml来使用gnocchi://发布者而不是notifier://来放弃收集器服务。 这样做会最大限度地减少资源需求。 在这种情况下,调度员不需要被添加到conf文件中。

由于以下的配置都是需要gnocchi已经安装的环境下,所以先安装gnocchi

步骤二 安装配置gnocchi

配置数据库

mysql -u root -p

创建 gnocchi 数据库

CREATE DATABASE gnocchi;

配置 gnocchi 数据库权限(这里密码为 GNOCCHI_DBPASS,按需修改)

GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' IDENTIFIED BY 'GNOCCHI_DBPASS';
GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' IDENTIFIED BY 'GNOCCHI_DBPASS';

退出数据库

创建认证用户gnocchi

openstack user create --domain default --password-prompt gnocchi

创建gnocchi的服务实体

openstack service create --name gnocchi --description "Metric Service" metric

为gnocchi服务实体metric创建endpoint

openstack endpoint create --region RegionOne metric public http://controller:8041 
 openstack endpoint create --region RegionOne metric internal http://controller:8041  
 openstack endpoint create --region RegionOne metric admin http://controller:8041

这里先简单的讲解下,由于ceilometer + gnocchi,即ceilometer只做采集数据,不做存储,存储统一交给gnocchi来处理,所以这里就没有ceilometer服务实体的endpoint了,查询数据就只需要gnocchi的endpoint就可以。如果不是采用gnocchi,而是采用database之类的,就需要设置ceilometer的endpoint

安装gnocchi

yum install openstack-gnocchi-api openstack-gnocchi-metricd python2-gnocchiclient -y

编辑/etc/gnocchi/gnocchi.conf

[DEFAULT]
log_dir = /var/log/gnocchi

[api]
auth_mode = keystone

[indexer]
url = mysql+pymysql://gnocchi:GNOCCHI_DBPASS@controller/gnocchi

[storage]
driver = file
file_basepath = /var/lib/gnocchi

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = gnocchi
password = GNOCCHI_PASS

注意修改GNOCCHI_PASS和GNOCCHI_DBPASS密码

gnocchi

新建文件 /etc/httpd/conf.d/10-gnocchi_wsgi.conf

Listen 8041


  ServerName controller

  ## Vhost docroot
  DocumentRoot "/var/www/cgi-bin/gnocchi"

  ## Directories, there should at least be a declaration for /var/www/cgi-bin/gnocchi

  
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  

  ## Logging
  ErrorLog "/var/log/httpd/gnocchi_wsgi_error.log"
  ServerSignature Off
  CustomLog "/var/log/httpd/gnocchi_wsgi_access.log" combined
  SetEnvIf X-Forwarded-Proto https HTTPS=1
  WSGIApplicationGroup %{GLOBAL}
  WSGIDaemonProcess gnocchi display-name=gnocchi_wsgi group=gnocchi processes=8 threads=8 user=gnocchi
  WSGIProcessGroup gnocchi
  WSGIScriptAlias / "/var/www/cgi-bin/gnocchi/app"

复制app.wsgi

mkdir /var/www/cgi-bin/gnocchi/
cp /usr/lib/python2.7/site-packages/gnocchi/rest/app.wsgi /var/www/cgi-bin/gnocchi/app
chown -R gnocchi.gnocchi /var/www/cgi-bin/gnocchi

步骤三 更新数据库,启动服务

先初始化gnocchi的数据库,然后启动gnocchi,再使用ceilometer-upgrade命令

初始化gnocchi数据库

su -s /bin/bash gnocchi -c "gnocchi-upgrade"

方式一 重启httpd加载gnocchi

systemctl restart httpd

方式二 openstack-gnocchi-api启动

这里为什么要重启httpd服务里,因为gnocchi推荐是使用wsgi的方式去启动详见https://gnocchi.xyz/
如果没有前面的10-gnocchi_wsgi.conf则需要修改gnocchi的代码,
编辑/usr/bin/gnocchi-api文件

if __name__ == "__main__":
    import argparse
    import socket
    import sys
    import wsgiref.simple_server as wss

    my_ip = socket.gethostbyname(socket.gethostname())
    parser = argparse.ArgumentParser(
        description=build_wsgi_app.__doc__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        usage='%(prog)s [-h] [--port PORT] -- [passed options]')
    parser.add_argument('--port', '-p', type=int, default=8000,
                        help='TCP port to listen on')
    parser.add_argument('args',
                        nargs=argparse.REMAINDER,
                        metavar='-- [passed options]',
                        help="'--' is the separator of the arguments used "
                        "to start the WSGI server and the arguments passed "
                        "to the WSGI application.")
    args = parser.parse_args()
    if args.args:
        if args.args[0] == '--':
            args.args.pop(0)
        else:
            parser.error("unrecognized arguments: %s" % ' '.join(args.args))
    sys.argv[1:] = args.args
    server = wss.make_server('', args.port, build_wsgi_app())

    print("*" * 80)
    print("STARTING test server gnocchi.rest.app.build_wsgi_app")
    url = "http://%s:%d/" % (my_ip, server.server_port)
    print("Available at %s" % url)
    print("DANGER! For testing only, do not use in production")
    print("*" * 80)
    sys.stdout.flush()

修改将下面这一句代码

 parser.add_argument('--port', '-p', type=int, default=8000,
                        help='TCP port to listen on')

将默认端口8000改成8041,也就是前面endpoint对应的端口
这样就不用重启httpd服务,需要启动gnocchi-api服务

systemctl enable openstack-gnocchi-api.service
systemctl start openstack-gnocchi-api

启动metricd服务

systemctl enable openstack-gnocchi-metricd 
systemctl start openstack-gnocchi-metricd

更新数据库
ceilometer-upgrade –skip-metering-database

启动ceilometer服务

systemctl enable openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service
systemctl start openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service

下面就能在gnocchi数据库的metric表中看到数据
也可以运行下面的命令查看数据

gnocchi metric list

你可能感兴趣的:(ceilometer,openstack)