10 安装Telemetry
Telemetry的组件信息请参考官方文档
10. 1 安装配置控制节点
10.1.1 配置先决条件
1 安装 MongoDB
# apt-get install mongodb-server mongodb-clients Python-pymongo
2 编辑 /etc/mongodb.conf file 完成下列操作:
bind_ip = 10.0.0.11
smallfiles = true
执行命令
# service mongodb stop
# rm /var/lib/mongodb/journal/prealloc.*
# service mongodb start
3 创建 ceilometer 数据库
# mongo --host controller --eval '
db = db.getSiblingDB("ceilometer");
db.addUser({user: "ceilometer",
pwd: "openstack",
roles: [ "readWrite", "dbAdmin" ]})'
MongoDB shell version: 2.4.9
connecting to: controller:27017/test
{
"user" : "ceilometer",
"pwd" : "347ed5cbd578cb16ce413fe1d085ce2f",
"roles" : [
"readWrite",
"dbAdmin"
],
"_id" : ObjectId("550a3f247f38cb43ba640fd7")
}
4 切换到管理员身份
$ source admin-openrc.sh
5 创建 ceilometer 用户
$ keystone user-create --name ceilometer --pass openstack
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | |
| enabled | True |
| id | d839485477e44aa8baabbefd19829392 |
| name | ceilometer |
| username | ceilometer |
+----------+----------------------------------+
为 ceilometer 用户添加admin角色:
$ keystone user-role-add --user ceilometer --tenant service --role admin
创建 ceilometer 服务实体:
$ keystone service-create --name ceilometer --type metering \
--description "Telemetry"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Telemetry |
| enabled | True |
| id | 92a5e6518c1d4b238f66c1358d472196 |
| name | ceilometer |
| type | metering |
+-------------+----------------------------------+
创建 Telemetry API endpoints
$ keystone endpoint-create \
--service-id $(keystone service-list | awk '/ metering / {print $2}') \
--publicurl http://controller:8777 \
--internalurl http://controller:8777 \
--adminurl http://controller:8777 \
--region regionOne
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://controller:8777 |
| id | f513c95f58a54d028c67db8e9d8e1e20 |
| internalurl | http://controller:8777 |
| publicurl | http://controller:8777 |
| region | regionOne |
| service_id | 92a5e6518c1d4b238f66c1358d472196 |
+-------------+----------------------------------+
10.1.2 配置先决条件
1 安装包
# apt-get install ceilometer-api ceilometer-collector ceilometer-agent-central \
ceilometer-agent-notification ceilometer-alarm-evaluator ceilometer-alarm-notifier \
python-ceilometerclient
2 生成一个随机密码
# openssl rand -hex 10
177e8037fc8c7916e329
3 编辑 /etc/ceilometer/ceilometer.conf 完成下列操作:
[DEFAULT]
...
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = openstack
...
auth_strategy = keystone
verbose = True
[keystone_authtoken]
#Comment out any auth_host, auth_port, and auth_protocol options because the identity_uri option replaces them.
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = ceilometer
admin_password = openstack
[database]
...
connection = mongodb://ceilometer:openstack@controller:27017/ceilometer
[service_credentials]
...
os_auth_url = http://controller:5000/v2.0
os_username = ceilometer
os_tenant_name = service
os_password = openstack
[publisher]
...
metering_secret = METERING_SECRET
把METERING_SECRET替换成我们上一步创建的177e8037fc8c7916e329
4 完成安装
重启服务
# service ceilometer-agent-central restart
# service ceilometer-agent-notification restart
# service ceilometer-api restart
# service ceilometer-collector restart
# service ceilometer-alarm-evaluator restart
# service ceilometer-alarm-notifier restart
10.2 安装配置计算节点
Telemetry 使用通知和代理的组合来收集计算节点的计费信息,请在每个计算节点上执行下列操作.
10.2.1 安装配置Agent
1
# apt-get install ceilometer-agent-compute
2 编辑 /etc/ceilometer/ceilometer.conf 完成下列操作:
[DEFAULT]
...
rabbit_host = controller
rabbit_password = openstack
verbose = True
[publisher]
...
metering_secret = METERING_SECRET
[keystone_authtoken]
#Comment out any auth_host, auth_port, and auth_protocol options because the identity_uri option replaces them.
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = ceilometer
admin_password = openstack
[service_credentials]
...
os_auth_url = http://controller:5000/v2.0
os_username = ceilometer
os_tenant_name = service
os_password = openstack
os_endpoint_type = internalURL
os_region_name = regionOne
把METERING_SECRET替换成我们上一步创建的177e8037fc8c7916e329
10.2.2 安装配置通知
Edit the /etc/nova/nova.conf file and configure notifications in the [DEFAULT] section:
编辑 /etc/nova/nova.conf ,配置在 [DEFAULT] 小节配置通知:
[DEFAULT]
instance_usage_audit = True
instance_usage_audit_period = hour
notify_on_state_change = vm_and_task_state
notification_driver = messagingv2
10.2.3 完成安装
# service ceilometer-agent-compute restart
# service nova-compute restart
10.2 安装配置映像服务
请在控制节点上运行下面的命令
编辑文件 /etc/glance/glance-api.conf 和 /etc/glance/glance-registry.conf 完成下面所提的操作:
[DEFAULT]
...
notification_driver = messagingv2
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = openstack
重启服务
# service glance-registry restart
# service glance-api restart
11 安装过程中遇到的问题
11.1 服务状态不对
安装的时候没有把控制节点的hostname改成controller,改完后发现有状态为down的服务
root@localhost:~# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1 | nova-cert | localhost | internal | enabled | down | 2015-03-17T09:40:43.000000 | - |
| 2 | nova-scheduler | localhost | internal | enabled | down | 2015-03-17T09:40:50.000000 | - |
| 3 | nova-consoleauth | localhost | internal | enabled | down | 2015-03-17T09:40:50.000000 | - |
| 4 | nova-conductor | localhost | internal | enabled | down | 2015-03-17T09:41:04.000000 | - |
| 6 | nova-compute | compute1 | nova | enabled | up | 2015-03-17T09:42:37.000000 | - |
| 7 | nova-cert | controller | internal | enabled | up | 2015-03-17T09:42:43.000000 | - |
| 8 | nova-scheduler | controller | internal | enabled | up | 2015-03-17T09:42:38.000000 | - |
| 9 | nova-consoleauth | controller | internal | enabled | up | 2015-03-17T09:42:38.000000 | - |
| 10 | nova-conductor | controller | internal | enabled | up | 2015-03-17T09:42:41.000000 | - |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
如果运行上述命令是报unsupported locale setting错误,请设置环境变量
export LC_ALL=en_US.UTF-8
把那些状态为down的服务删除。
root@localhost:~# nova service-delete 1
root@localhost:~# nova service-delete 2
root@localhost:~# nova service-delete 3
root@localhost:~# nova service-delete 4
root@localhost:~# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 6 | nova-compute | compute1 | nova | enabled | up | 2015-03-17T09:43:57.000000 | - |
| 7 | nova-cert | controller | internal | enabled | up | 2015-03-17T09:44:03.000000 | - |
| 8 | nova-scheduler | controller | internal | enabled | up | 2015-03-17T09:43:58.000000 | - |
| 9 | nova-consoleauth | controller | internal | enabled | up | 2015-03-17T09:43:58.000000 | - |
| 10 | nova-conductor | controller | internal | enabled | up | 2015-03-17T09:44:02.000000 | - |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
因为我在安装的过程中网络节点重装过,所以也出现了类似的情况。
root@localhost:~# neutron agent-list
+--------------------------------------+--------------------+-----------+-------+----------------+---------------------------+
| id | agent_type | host | alive | admin_state_up | binary |
+--------------------------------------+--------------------+-----------+-------+----------------+---------------------------+
| 02e5b551-197e-4fa3-8489-d19cb40e3171 | DHCP agent | network | :-) | True | neutron-dhcp-agent |
| 6ea0949b-e389-437b-9be7-eb32bc138ef1 | Metadata agent | network | :-) | True | neutron-metadata-agent |
| 77b4f1ad-4dc4-4a00-881f-6709b63c856a | Open vSwitch agent | localhost | xxx | True | neutron-openvswitch-agent |
| 809776b5-42f0-4c5c-afee-1e8fc1877be9 | DHCP agent | localhost | xxx | True | neutron-dhcp-agent |
| aeadc622-155c-46c5-bd2b-f75f715664ca | Metadata agent | localhost | xxx | True | neutron-metadata-agent |
| b18cf8ae-3893-436f-beef-315274d837b2 | L3 agent | localhost | xxx | True | neutron-l3-agent |
| cd82006e-a82d-4576-a7fa-183f68b4ae73 | L3 agent | network | :-) | True | neutron-l3-agent |
| e3fe92b0-afee-49e3-a783-e5900182fd5b | Open vSwitch agent | compute1 | :-) | True | neutron-openvswitch-agent |
| fbfc1f77-bee0-413f-a38d-eff804cc573f | Open vSwitch agent | network | :-) | True | neutron-openvswitch-agent |
+--------------------------------------+--------------------+-----------+-------+----------------+---------------------------+
root@localhost:~# neutron agent-delete 77b4f1ad-4dc4-4a00-881f-6709b63c856a
Deleted agent: 77b4f1ad-4dc4-4a00-881f-6709b63c856a
root@localhost:~# neutron agent-delete 809776b5-42f0-4c5c-afee-1e8fc1877be9
Deleted agent: 809776b5-42f0-4c5c-afee-1e8fc1877be9
root@localhost:~# neutron agent-delete aeadc622-155c-46c5-bd2b-f75f715664ca
Deleted agent: aeadc622-155c-46c5-bd2b-f75f715664ca
root@localhost:~# neutron agent-delete b18cf8ae-3893-436f-beef-315274d837b2
Deleted agent: b18cf8ae-3893-436f-beef-315274d837b2
root@localhost:~# neutron agent-list
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| id | agent_type | host | alive | admin_state_up | binary |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| 02e5b551-197e-4fa3-8489-d19cb40e3171 | DHCP agent | network | :-) | True | neutron-dhcp-agent |
| 6ea0949b-e389-437b-9be7-eb32bc138ef1 | Metadata agent | network | :-) | True | neutron-metadata-agent |
| cd82006e-a82d-4576-a7fa-183f68b4ae73 | L3 agent | network | :-) | True | neutron-l3-agent |
| e3fe92b0-afee-49e3-a783-e5900182fd5b | Open vSwitch agent | compute1 | :-) | True | neutron-openvswitch-agent |
| fbfc1f77-bee0-413f-a38d-eff804cc573f | Open vSwitch agent | network | :-) | True | neutron-openvswitch-agent |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
11.2 启动实例时报错
Build of instance 84c2c847-bcc7-4fad-8e81-4430b156cc46 aborted: Failed to allocate the network(s), not rescheduling.
查看网络节点的日志,发现报错:
neutron ImportError: No module named rabbit
网上说这是OpenStack上一个版本Icehouse的问题,我忽然意识到我在安装新的网络节点时,没有导入新的源,Ubuntu 14.04的官方源里还真就是Icehouse版本。
# apt-get install ubuntu-cloud-keyring
# echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu" \
"trusty-updates/juno main" > /etc/apt/sources.list.d/cloudarchive-juno.list
导入上面的源重新安装了包,启动服务后,不报这个错误了。
不过主机还是没启动起来。。。。 还是报Failed to allocate the network(s), not rescheduling.错误。
查看计算节点compute1上的/var/log/neutron/openvswitch-agent.log,发现如下错误:
Bridge br-ex for physical network external does not exist. Agent terminated!
仔细查看计算节点上的/etc/neutron/plugins/ml2/ml2conf.ini 时发现里面有这个`bridgemappings = external:br-ex`选项,官方安装文档里没有提这个选项,禁用它试试。
#bridge_mappings = external:br-ex
嗯,不报上面的错误了。
不过云主机还是启动不起来,还是报Failed to allocate the network(s), not rescheduling。
查看计算节点compute1上的/var/log/nova/nova-compute.log发现这个错误
VirtualInterfaceCreateException: Virtual Interface creation failed
这个帖子解决了我的问题,在计算节点的nova.conf里加入
[DEFAULT]
#加入下面两行
vif_plugging_is_fatal: false
vif_plugging_timeout: 0
实例终于启动起来了。
在我启动控制节点后,
# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 6 | nova-compute | compute1 | nova | enabled | down | 2015-03-18T09:33:33.000000 | - |
| 7 | nova-cert | controller | internal | enabled | down | 2015-03-18T09:33:26.000000 | - |
| 8 | nova-scheduler | controller | internal | enabled | down | 2015-03-18T09:33:28.000000 | - |
| 9 | nova-consoleauth | controller | internal | enabled | down | 2015-03-18T09:33:28.000000 | - |
| 10 | nova-conductor | controller | internal | enabled | down | 2015-03-18T09:33:28.000000 | - |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
这几个服务的日志报的都是这个错误:
AMQP server controller:5672 closed the connection. Check login credentials: Socket closed
我傻乎乎的重启了N遍服务,还怀疑是iptables的问题。其它错误里说得挺清楚的:Check login credentials。不过我真没想到重启会让guest的密码失效。重新设置一下这个密码就OK了。
rabbitmqctl change_password guest openstack
- 如何设置ceilometer的轮询间隔
https://ask.openstack.org/en/question/5882/how-to-change-the-polling-period-of-ceilometer/
启动实例的
apache的错误日志显示:
[Tue Mar 24 17:31:32.200854 2015] [:error] [pid 23314:tid 140209584568064] Internal Server Error: /horizon/project/instances/launch
[Tue Mar 24 17:31:32.200922 2015] [:error] [pid 23314:tid 140209584568064] Traceback (most recent call last):
[Tue Mar 24 17:31:32.200931 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 112, in get_response
[Tue Mar 24 17:31:32.200939 2015] [:error] [pid 23314:tid 140209584568064] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Mar 24 17:31:32.200945 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 36, in dec
[Tue Mar 24 17:31:32.200952 2015] [:error] [pid 23314:tid 140209584568064] return view_func(request, *args, **kwargs)
[Tue Mar 24 17:31:32.200958 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 52, in dec
[Tue Mar 24 17:31:32.200964 2015] [:error] [pid 23314:tid 140209584568064] return view_func(request, *args, **kwargs)
[Tue Mar 24 17:31:32.200970 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 36, in dec
[Tue Mar 24 17:31:32.200977 2015] [:error] [pid 23314:tid 140209584568064] return view_func(request, *args, **kwargs)
[Tue Mar 24 17:31:32.200983 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 84, in dec
[Tue Mar 24 17:31:32.200989 2015] [:error] [pid 23314:tid 140209584568064] return view_func(request, *args, **kwargs)
[Tue Mar 24 17:31:32.200995 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 69, in view
[Tue Mar 24 17:31:32.201002 2015] [:error] [pid 23314:tid 140209584568064] return self.dispatch(request, *args, **kwargs)
[Tue Mar 24 17:31:32.201008 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 87, in dispatch
[Tue Mar 24 17:31:32.201014 2015] [:error] [pid 23314:tid 140209584568064] return handler(request, *args, **kwargs)
[Tue Mar 24 17:31:32.201020 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/workflows/views.py", line 165, in post
[Tue Mar 24 17:31:32.201027 2015] [:error] [pid 23314:tid 140209584568064] context = self.get_context_data(**kwargs)
[Tue Mar 24 17:31:32.201033 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/workflows/views.py", line 89, in get_context_data
[Tue Mar 24 17:31:32.201039 2015] [:error] [pid 23314:tid 140209584568064] workflow = self.get_workflow()
[Tue Mar 24 17:31:32.201045 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/workflows/views.py", line 79, in get_workflow
[Tue Mar 24 17:31:32.201051 2015] [:error] [pid 23314:tid 140209584568064] entry_point=entry_point)
[Tue Mar 24 17:31:32.201069 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/workflows/base.py", line 648, in __init__
[Tue Mar 24 17:31:32.201075 2015] [:error] [pid 23314:tid 140209584568064] valid = step.action.is_valid()
[Tue Mar 24 17:31:32.201081 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/forms/forms.py", line 129, in is_valid
[Tue Mar 24 17:31:32.201086 2015] [:error] [pid 23314:tid 140209584568064] return self.is_bound and not bool(self.errors)
[Tue Mar 24 17:31:32.201092 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/forms/forms.py", line 121, in errors
[Tue Mar 24 17:31:32.201097 2015] [:error] [pid 23314:tid 140209584568064] self.full_clean()
[Tue Mar 24 17:31:32.201103 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/forms/forms.py", line 274, in full_clean
[Tue Mar 24 17:31:32.201108 2015] [:error] [pid 23314:tid 140209584568064] self._clean_form()
[Tue Mar 24 17:31:32.201113 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/django/forms/forms.py", line 300, in _clean_form
[Tue Mar 24 17:31:32.201119 2015] [:error] [pid 23314:tid 140209584568064] self.cleaned_data = self.clean()
[Tue Mar 24 17:31:32.201124 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/instances/workflows/create_instance.py", line 167, in clean
[Tue Mar 24 17:31:32.201131 2015] [:error] [pid 23314:tid 140209584568064] usages = quotas.tenant_quota_usages(self.request)
[Tue Mar 24 17:31:32.201136 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/horizon/utils/memoized.py", line 90, in wrapped
[Tue Mar 24 17:31:32.201142 2015] [:error] [pid 23314:tid 140209584568064] value = cache[key] = func(*args, **kwargs)
[Tue Mar 24 17:31:32.201148 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 224, in tenant_quota_usages
[Tue Mar 24 17:31:32.201153 2015] [:error] [pid 23314:tid 140209584568064] disabled_quotas=disabled_quotas):
[Tue Mar 24 17:31:32.201159 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 165, in get_tenant_quota_data
[Tue Mar 24 17:31:32.201165 2015] [:error] [pid 23314:tid 140209584568064] tenant_id=tenant_id)
[Tue Mar 24 17:31:32.201171 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 147, in _get_quota_data
[Tue Mar 24 17:31:32.201177 2015] [:error] [pid 23314:tid 140209584568064] quotasets.append(getattr(cinder, method_name)(request, tenant_id))
[Tue Mar 24 17:31:32.201182 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/api/cinder.py", line 363, in tenant_quota_get
[Tue Mar 24 17:31:32.201188 2015] [:error] [pid 23314:tid 140209584568064] return base.QuotaSet(c_client.quotas.get(tenant_id))
[Tue Mar 24 17:31:32.201193 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/cinderclient/v1/quotas.py", line 39, in get
[Tue Mar 24 17:31:32.201199 2015] [:error] [pid 23314:tid 140209584568064] "quota_set")
[Tue Mar 24 17:31:32.201204 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/cinderclient/base.py", line 151, in _get
[Tue Mar 24 17:31:32.201209 2015] [:error] [pid 23314:tid 140209584568064] return self.resource_class(self, body[response_key], loaded=True)
[Tue Mar 24 17:31:32.201215 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/cinderclient/openstack/common/apiclient/base.py", line 429, in __init__
[Tue Mar 24 17:31:32.201227 2015] [:error] [pid 23314:tid 140209584568064] self._add_details(info)
[Tue Mar 24 17:31:32.201233 2015] [:error] [pid 23314:tid 140209584568064] File "/usr/lib/python2.7/dist-packages/cinderclient/openstack/common/apiclient/base.py", line 450, in _add_details
[Tue Mar 24 17:31:32.201238 2015] [:error] [pid 23314:tid 140209584568064] setattr(self, k, v)
[Tue Mar 24 17:31:32.201244 2015] [:error] [pid 23314:tid 140209584568064] UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-11: ordinal not in range(128)
在看了python对unicode的支持后,修改了源代码 “/usr/lib/python2.7/dist-packages/cinderclient/openstack/common/apiclient/base.py”
setattr(self, k.encode('UTF-8'), v.encode('UTF-8'))
#setattr(self, k, v)
可以了.
