root@node-1:~# nova interface-list 95985dfe-8356-4bb6-8ec7-46730d1b4c41
+------------+--------------------------------------+--------------------------------------+----------------+-------------------+
| Port State | Port ID | Net ID | IP addresses | MAC Addr |
+------------+--------------------------------------+--------------------------------------+----------------+-------------------+
| ACTIVE | fc618310-b936-4247-a5e4-2389a9d8c50e | de2df80a-5f69-4630-85ac-4081ce70de98 | 192.168.111.14 | fa:16:3e:5e:99:0c |
+------------+--------------------------------------+--------------------------------------+----------------+-------------------+
root@node-4:~# brctl show
bridge name bridge id STP enabled interfaces
br-aux 8000.e41d2d0f1091 no bond0
p_e52381cd-0
br-fw-admin 8000.3863bb3350c8 no eth2
br-mgmt 8000.e41d2d0f1091 no bond0.101
br-storage 8000.e41d2d0f1091 no bond0.103
qbrfc618310-b9 8000.26d598f1427a no qvbfc618310-b9
tapfc618310-b9
[root@eayun-admin ceph]# ceph-deploy disk list eayun-compute1
1
2
3
4
5
6
7
8
9
10
11
12
[ceph_deploy.cli][INFO ] Invoked (1.3.5): /usr/bin/ceph-deploy disk list eayun-compute1
[eayun-compute1][DEBUG ] connected to host: eayun-compute1
[eayun-compute1][DEBUG ] detect platform information from remote host
[eayun-compute1][DEBUG ] detect machine type
[ceph_deploy.osd][INFO ] Distro info: CentOS 6.5 Final
[ceph_deploy.osd][DEBUG ] Listing disks on eayun-compute1...
[eayun-compute1][INFO ] Running command: ceph-disk list
[eayun-compute1][DEBUG ] /dev/sda :
[eayun-compute1][DEBUG ] /dev/sda1 other, ext4, mounted on /
[eayun-compute1][DEBUG ] /dev/sda2 other, swap
[eayun-compute1][DEBUG ] /dev/sdb other, unknown
[eayun-compute1][DEBUG ] /dev/sdc other, unknown
[root@eayun-admin ceph]# ceph-deploy disk zap eayun-compute1:/dev/sdb
1
2
3
4
5
6
7
8
9
10
11
12
[ceph_deploy.cli][INFO ] Invoked (1.3.5): /usr/bin/ceph-deploy disk zap eayun-compute1:/dev/sdb
[ceph_deploy.osd][DEBUG ] zapping /dev/sdb on eayun-compute1
[eayun-compute1][DEBUG ] connected to host: eayun-compute1
[eayun-compute1][DEBUG ] detect platform information from remote host
[eayun-compute1][DEBUG ] detect machine type
[ceph_deploy.osd][INFO ] Distro info: CentOS 6.5 Final
[eayun-compute1][DEBUG ] zeroing last few blocks of device
[eayun-compute1][INFO ] Running command: sgdisk --zap-all --clear --mbrtogpt -- /dev/sdb
[eayun-compute1][DEBUG ] Creating new GPT entries.
[eayun-compute1][DEBUG ] GPT data structures destroyed! You may now partition the disk using fdisk or
[eayun-compute1][DEBUG ] other utilities.
[eayun-compute1][DEBUG ] The operation has completed successfully.
[root@eayun-admin ceph]# ceph-deploy disk prepare eayun-compute1:/dev/sdb
error: Failed to start domain instance-00000003
error: internal error Process exited while reading console log output: char device redirected to /dev/pts/0
qemu-kvm: -drive file=rbd:volumes/volume-59d0b231-f5a3-45d5-98a2-007319f65529:id=libvirt:key=AQCF6DRTOGGrEBAAnanwo1Qs5pONEGB2lCe49Q==:auth_supported=cephx\;none:mon_host=192.168.11.210\:6789,if=none,id=drive-ide0-0-1: error connecting
qemu-kvm: -drive file=rbd:volumes/volume-59d0b231-f5a3-45d5-98a2-007319f65529:id=libvirt:key=AQCF6DRTOGGrEBAAnanwo1Qs5pONEGB2lCe49Q==:auth_supported=cephx\;none:mon_host=192.168.11.210\:6789,if=none,id=drive-ide0-0-1: could not open disk image rbd:volumes/volume-59d0b231-f5a3-45d5-98a2-007319f65529:id=libvirt:key=AQCF6DRTOGGrEBAAnanwo1Qs5pONEGB2lCe49Q==:auth_supported=cephx\;none:mon_host=192.168.11.210\:6789: Operation not permitted
//ceph.log
2014-03-28 09:09:26.488788 7ffcd6eeb700 0 cephx server client.libvirt: couldn't find entity name: client.libvirt
###CEPH相关操作
####About Pool
To show a pool’s utilization statistics, execute:
[root@eayun-admin ceph]# rados df
1
2
3
4
5
6
7
8
9
pool name category KB objects clones degraded unfound rd rd KB wr wr KB
data - 1 1 0 0 0 17 13 4 3
images - 0 0 0 0 0 0 0 0 0
metadata - 0 0 0 0 0 0 0 0 0
rbd - 0 0 0 0 0 0 0 0 0
volumes - 0 0 0 0 0 0 0 0 0
total used 235868 1
total avail 18570796
total space 18806664
[root@eayun-admin ceph]# ceph osd pool get images size
1
2
3
4
5
6
7
8
9
10
11
12
13
size: 3 >[root@eayun-admin ceph]# ceph osd pool get images pg_num
pg_num: 1000 >[root@eayun-admin ceph]# ceph osd pool get images pgp_num
pgp_num: 1000 >[root@eayun-admin ceph]# ceph osd pool set images pgp_num 99
set pool 4 pgp_num to 99 >[root@eayun-admin ceph]# ceph osd pool set images pg_num 99
specified pg_num 99 <= current 1000 不能把一个Pool的pg_num缩小!!! >[root@eayun-admin ceph]# ceph osd pool get images pg_num
pg_num: 1000 删除一个Pool. yes, i really really mean it :^) >[root@eayun-admin ceph]# ceph osd pool delete images
Error EPERM: WARNING: this will *PERMANENTLY DESTROY* all data stored in pool images. If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, followed by --yes-i-really-really-mean-it.
[root@eayun-admin ceph]# ceph osd pool delete images images –yes-i-really-really-mean-it
root@glos-manager:/# vgdisplay cinder-volumes
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.95 GiB
PE Size 4.00 MiB
Total PE 1522
Alloc PE / Size 1338 / 5.23 GiB
Free PE / Size 184 / 736.00 MiB
VG UUID EIKfKf-mIvG-Sabt-JlV4-19Ot-XqSK-3dEXE0
root@glos-manager:/# lvdisplay
--- Logical volume ---
LV Name /dev/cinder-volumes/nova-instances
VG Name cinder-volumes
LV UUID IQCf3L-Zebu-CfrD-H5ct-qlg6-DnTI-SaQWef
LV Write Access read/write
LV Status available
# open 1
LV Size 1.99 GiB
Current LE 509
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
--- Logical volume ---
LV Name /dev/cinder-volumes/system-root
VG Name cinder-volumes
LV UUID XVAGEN-Orq2-OnRI-FXvY-G3yd-dRiE-JdDlmw
LV Write Access read/write
LV Status available
# open 1
LV Size 3.73 GiB
Current LE 954
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
root@glos-manager:/# resize2fs -p /dev/mapper/cinder--volumes-nova--instances
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/cinder--volumes-nova--instances is mounted on /var/lib/nova/instances; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/cinder--volumes-nova--instances to 521216 (4k) blocks.
The filesystem on /dev/mapper/cinder--volumes-nova--instances is now 521216 blocks long.
deftrunc_password(password): """Truncate passwords to the MAX_PASSWORD_LENGTH.""" iflen(password)>MAX_PASSWORD_LENGTH: returnpassword[:MAX_PASSWORD_LENGTH] else: returnpassword
#/nova/compute/manager.py: ComputeManager --> SchedulerDependentManager @manager.periodic_task def_report_driver_status(self,context): curr_time=time.time() ifcurr_time-self._last_host_check>FLAGS.host_state_interval: self._last_host_check=curr_time LOG.info(_("Updating host status")) # This will grab info about the host and queue it # to be sent to the Schedulers. capabilities=self.driver.get_host_stats(refresh=True) capabilities['host_ip']=FLAGS.my_ip self.update_service_capabilities(capabilities)
#/nova/manager.py: SchedulerDependentManager @periodic_task def_publish_service_capabilities(self,context): """Pass data back to the scheduler at a periodic interval.""" ifself.last_capabilities: LOG.debug(_('Notifying Schedulers of capabilities ...')) self.scheduler_rpcapi.update_service_capabilities(context, self.service_name,self.host,self.last_capabilities)
#/nova/schedule/host_manager.py: HostManager defupdate_service_capabilities(self,service_name,host,capabilities): """Update the per-service capabilities based on this notification.""" LOG.debug(_("Received %(service_name)s service update from " "%(host)s.")%locals()) service_caps=self.service_states.get(host,{}) # Copy the capabilities, so we don't modify the original dict capab_copy=dict(capabilities) capab_copy["timestamp"]=timeutils.utcnow()# Reported time service_caps[service_name]=capab_copy self.service_states[host]=service_caps
defget_all_host_states(self,context,topic): """Returns a dict of all the hosts the HostManager knows about. Also, each of the consumable resources in HostState are pre-populated and adjusted based on data in the db.
For example: {'192.168.1.100': HostState(), ...}
Note: this can be very slow with a lot of instances. InstanceType table isn't required since a copy is stored with the instance (in case the InstanceType changed since the instance was created)."""
iftopic!='compute': raiseNotImplementedError(_( "host_manager only implemented for 'compute'"))
# Get resource usage across the available compute nodes: compute_nodes=db.compute_node_get_all(context) forcomputeincompute_nodes: service=compute['service'] ifnotservice: LOG.warn(_("No service for compute ID %s")%compute['id']) continue host=service['host'] capabilities=self.service_states.get(host,None) host_state=self.host_state_map.get(host) ifhost_state: host_state.update_capabilities(topic,capabilities, dict(service.iteritems())) else: host_state=self.host_state_cls(host,topic, capabilities=capabilities, service=dict(service.iteritems())) self.host_state_map[host]=host_state host_state.update_from_compute_node(compute)
def_sync_compute_node(self,context,resources): """Create or update the compute node DB record""" def_get_service(self,context): try: returndb.service_get_all_compute_by_host(context, self.host)[0] exceptexception.NotFound: LOG.warn(_("No service record for host %s"),self.host)
ifnotself.compute_node: # we need a copy of the ComputeNode record: service=self._get_service(context) ifnotservice: # no service record, disable resource return
def_create(self,context,values): """Create the compute node in the DB""" # initialize load stats from existing instances: compute_node=db.compute_node_create(context,values) self.compute_node=dict(compute_node)
def_update(self,context,values,prune_stats=False): """Persist the compute node updates to the DB""" compute_node=db.compute_node_update(context, self.compute_node['id'],values,prune_stats) self.compute_node=dict(compute_node)
ifnotself.compute_node: resources['service_id']=service['id'] self._create(context,resources) LOG.info(_('Compute_service record created for %s ')%self.host) else: self._update(context,resources,prune_stats=True) LOG.info(_('Compute_service record updated for %s ')%self.host)
def_update_usage_from_instances(self,resources,instances): """Calculate resource usage based on instance utilization. This is different than the hypervisor's view as it will account for all instances assigned to the local compute host, even if they are not currently powered on. """ self.tracked_instances.clear()
# purge old stats self.stats.clear()
# set some intiial values, reserve room for host/hypervisor: resources['local_gb_used']=FLAGS.reserved_host_disk_mb/1024 resources['memory_mb_used']=FLAGS.reserved_host_memory_mb resources['vcpus_used']=0 resources['free_ram_mb']=(resources['memory_mb']- resources['memory_mb_used']) resources['free_disk_gb']=(resources['local_gb']- resources['local_gb_used']) resources['current_workload']=0 resources['running_vms']=0
# if it's a new or deleted instance: ifis_new_instanceoris_deleted_instance: # new instance, update compute node resource usage: resources['memory_mb_used']+=sign*instance['memory_mb'] resources['local_gb_used']+=sign*instance['root_gb'] resources['local_gb_used']+=sign*instance['ephemeral_gb']
# free ram and disk may be negative, depending on policy: resources['free_ram_mb']=(resources['memory_mb']- resources['memory_mb_used']) resources['free_disk_gb']=(resources['local_gb']- resources['local_gb_used'])
""" # available size of the disk dk_sz_gb = self.get_local_gb_total() - self.get_local_gb_used()
# Disk size that all instance uses : virtual_size - disk_size instances_name = self.list_instances() instances_sz = 0 for i_name in instances_name: try: disk_infos = jsonutils.loads( self.get_instance_disk_info(i_name)) for info in disk_infos: i_vt_sz = int(info['virt_disk_size']) i_dk_sz = int(info['disk_size']) instances_sz += i_vt_sz - i_dk_sz except OSError as e: if e.errno == errno.ENOENT: LOG.error(_("Getting disk size of %(i_name)s: %(e)s") % locals()) else: raise except exception.InstanceNotFound: # Instance was deleted during the check so ignore it pass # NOTE(gtt116): give change to do other task. greenthread.sleep(0) # Disk available least size available_least_size = dk_sz_gb * (1024 ** 3) - instances_sz return (available_least_size / 1024 / 1024 / 1024)
if sys.platform.upper() not in ['LINUX2', 'LINUX3']: return 0
m = open('/proc/meminfo').read().split() idx1 = m.index('MemFree:') idx2 = m.index('Buffers:') idx3 = m.index('Cached:') if FLAGS.libvirt_type == 'xen': used = 0 for domain_id in self.list_instance_ids(): # skip dom0 dom_mem = int(self._conn.lookupByID(domain_id).info()[2]) if domain_id != 0: used += dom_mem else: # the mem reported by dom0 is be greater of what # it is being used used += (dom_mem - (int(m[idx1 + 1]) + int(m[idx2 + 1]) + int(m[idx3 + 1]))) # Convert it to MB return used / 1024 else: avail = (int(m[idx1 + 1]) + int(m[idx2 + 1]) + int(m[idx3 + 1])) # Convert it to MB return self.get_memory_mb_total() - avail / 1024
# On certain platforms, this will raise a NotImplementedError. try: return multiprocessing.cpu_count() except NotImplementedError: LOG.warn(_("Cannot get the number of cpu, because this " "function is not implemented for this platform. " "This error can be safely ignored for now.")) return 0 def get_memory_mb_total(self): """Getthetotalmemorysize(MB)ofphysicalcomputer.
total = 0 for dom_id in self.list_instance_ids(): dom = self._conn.lookupByID(dom_id) vcpus = dom.vcpus() if vcpus is None: # dom.vcpus is not implemented for lxc, but returning 0 for # a used count is hardly useful for something measuring usage total += 1 else: total += len(vcpus[1]) # NOTE(gtt116): give change to do other task. greenthread.sleep(0) return total