安装Gnocchi

Gnocchi用于将采集数据进行计算合并和存储并提供rest api方式接收和查询监控数据。请在控制节点安装Gnocchi。

  1. 创建数据库。

    1. 以root用户登录数据库。
      mysql -u root -p 
    2. 在数据库中,创建Gnocchi数据库并授权。
      CREATE DATABASE gnocchi; 
      GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' IDENTIFIED BY 'GNOCCHI_DBPASS'; 
      GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' IDENTIFIED BY 'GNOCCHI_DBPASS';

      将GNOCCHI_DBPASS替换为Gnocchi数据库用户的密码,请根据实际进行设置。密码中请勿包含字符“#@$”,支持特殊字符“&=- _ . + ! * ()”。

    3. 退出数据库。
      exit

  2. 创建对应Keystone资源对象。

    openstack user create --domain default --password-prompt gnocchi 
    openstack role add --project service --user gnocchi admin 
    openstack service create --name gnocchi --description "Metric Service" metric 
    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

    密码中请勿包含字符“#@$”,支持特殊字符“&=- _ . + ! * ()”

  3. 安装Gnocchi。

    yum install python3-uWSGI.aarch64 
    yum install openstack-gnocchi-api openstack-gnocchi-metricd python3-gnocchiclient

  4. 修改配置文件“/etc/gnocchi/gnocchi.conf”。

    1. 打开文件。
      vi /etc/gnocchi/gnocchi.conf
    2. 按“i”进入编辑模式,修改如下内容。
      [api]  
      auth_mode = keystone 
      port = 8041 
      uwsgi_mode = http-socket 
      
      # 配置Keystone认证信息,配置文件中默认没有[keystone_authtoken]模块参数,需要新增。
      [keystone_authtoken] 
      www_authenticate_uri = http://controller:5000
      auth_type = password 
      auth_url = http://controller:5000/v3 
      memcached_servers = controller:11211
      project_domain_name = Default 
      user_domain_name = Default 
      project_name = service 
      username = gnocchi 
      password = GNOCCHI_PASSWORD
      interface = internalURL 
      region_name = RegionOne 
      service_token_roles_required = true 
       
      [indexer] 
      url = mysql+pymysql://gnocchi:GNOCCHI_DBPASS@controller/gnocchi 
      
      [storage] 
      # coordination_url is not required but specifying one will improve 
      # performance with better workload division across workers. 
      # coordination_url = redis://controller:6379 
      file_basepath = /var/lib/gnocchi 
      driver = file

      将GNOCCHI_DBPASS替换为Gnocchi数据库的密码,将GNOCCHI_PASSWORD替换为Gnocchi用户的密码,请根据实际需求进行设置。密码中请勿包含字符“#@$”,支持特殊字符“&=- _ . + ! * ()”。

    1. 按“Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。

  5. 初始化数据库。

    gnocchi-upgrade

  6. 赋予“/var/lib/gnocchi”文件可读写权限。

    chmod -R 777 /var/lib/gnocchi

  7. 启动Gnocchi服务。

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