My Mostly Linux Stuff

تجربیات ابری – قسمت اول

سلام. بعضی مشکلات و نیازهایی رو که خودم در حین کار با اپن استک بهشون نیاز داشتم رو به صورت سوال جواب اینجا آوردم:

چطوری نام کاربری رو تعویض کنم (البته با تمام متعلقاتش)؟

http://docs.openstack.org/cli-reference/content/keystoneclient_commands.html#keystoneclient_subcommand_user-update

$ keystone user-update –name hpc demo

$ keystone tenant-update –name hpc demo

$ neutron net-update demo-net –name hpc-net

$ neutron subnet-update demo-subnet –name hpc-subnet

$ neutron router-update demo-router –name hpc-router

چطوری یک نود کامپیوت رو از کنترلر حذف کنم ؟

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/4/html/Installation_and_Configuration_Guide/Safely_Removing_Compute_Resources.html

$ source admin-openrc.sh
$ nova service-list
+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| Binary           | Host       | Zone     | Status   | State | Updated_at                 | Disabled Reason |
+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| nova-consoleauth | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-cert        | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-scheduler   | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-conductor   | controller | internal | enabled  | up    | 2015-03-27T09:25:36.000000 | -               |
| nova-compute     | compute1   | nova     | enabled  | up    | 2015-03-27T09:25:37.000000 | -               |
| nova-compute     | compute2   | nova     | enabled  | up    | 2015-03-27T09:25:42.000000 | -               |
| nova-compute     | compute3   | nova     | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
...

اکنون با استفاده از فرمان زیر هاست مورد نظر رو غیر فعال کنید تا در موقع راه اندازی ماشین های مجازی، هاست مدنظر مورد استفاده قرار نگیرد.: 
$ nova service-disable HOST nova-compute
$ nova service-disable  compute26 nova-compute
+-----------+--------------+----------+
| Host      | Binary       | Status   |
+-----------+--------------+----------+
| compute26 | nova-compute | disabled |
+-----------+--------------+----------+


باقی می ماند؟ build چرا برخی اوقات موقع ایجاد ماشین مجازی، سیستم در حالت

: را دوباره راه اندازی نماییدnova-compute  رفته و سرویس compute بر روی نود

# service nova-compute restart

چگونه یک دی ان اس سرور خاص را برای ماشین های مجازی ست نماییم:

راه حل اول  با استفاده از ست کردن دستی بر روی ماشین مجازی :

echo ‘nameserver ‘ >> /etc/resolv.conf

راه حل اصلی:

neutron subnet-update   –dns-nameservers list=true  ...

: nova availability zone نحوه ایجاد یک

$ nova aggregate-create test-aggregate2 test-az
+----+-----------------+-------------------+-------+----------+
| Id | Name            | Availability Zone | Hosts | Metadata |
+----+-----------------+-------------------+-------+----------+
| 2  | test-aggregate2 | test-az           |       |          |
+----+-----------------+-------------------+-------+----------+

ref: http://blog.russellbryant.net/2013/05/21/availability-zones-and-host-aggregates-in-openstack-compute-nova/

چرا با توجه به اینکه نود کامپیوت خالی داریم ولی سیستم در حین اجرای ماشین مجازی پیغام

 رو دریافت می کنیم ؟ Error: No valid host was found.

اگر به پیغام های خطا در فایل

سلام. بعضی مشکلات و نیازهایی رو که خودم در حین کار با اپن استک بهشون نیاز داشتم رو به صورت سوال جواب اینجا آوردم:

چطوری نام کاربری رو تعویض کنم (البته با تمام متعلقاتش)؟

http://docs.openstack.org/cli-reference/content/keystoneclient_commands.html#keystoneclient_subcommand_user-update

$ keystone user-update –name hpc demo

$ keystone tenant-update –name hpc demo

$ neutron net-update demo-net –name hpc-net

$ neutron subnet-update demo-subnet –name hpc-subnet

$ neutron router-update demo-router –name hpc-router

چطوری یک نود کامپیوت رو از کنترلر حذف کنم ؟

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/4/html/Installation_and_Configuration_Guide/Safely_Removing_Compute_Resources.html

$ source admin-openrc.sh
$ nova service-list
+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| Binary           | Host       | Zone     | Status   | State | Updated_at                 | Disabled Reason |
+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| nova-consoleauth | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-cert        | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-scheduler   | controller | internal | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
| nova-conductor   | controller | internal | enabled  | up    | 2015-03-27T09:25:36.000000 | -               |
| nova-compute     | compute1   | nova     | enabled  | up    | 2015-03-27T09:25:37.000000 | -               |
| nova-compute     | compute2   | nova     | enabled  | up    | 2015-03-27T09:25:42.000000 | -               |
| nova-compute     | compute3   | nova     | enabled  | up    | 2015-03-27T09:25:35.000000 | -               |
...

اکنون با استفاده از فرمان زیر هاست مورد نظر رو غیر فعال کنید تا در موقع راه اندازی ماشین های مجازی، هاست مدنظر مورد استفاده قرار نگیرد.: 
$ nova service-disable HOST nova-compute
$ nova service-disable  compute26 nova-compute
+-----------+--------------+----------+
| Host      | Binary       | Status   |
+-----------+--------------+----------+
| compute26 | nova-compute | disabled |
+-----------+--------------+----------+


باقی می ماند؟ build چرا برخی اوقات موقع ایجاد ماشین مجازی، سیستم در حالت

: را دوباره راه اندازی نماییدnova-compute  رفته و سرویس compute بر روی نود

# service nova-compute restart

چگونه یک دی ان اس سرور خاص را برای ماشین های مجازی ست نماییم:

راه حل اول  با استفاده از ست کردن دستی بر روی ماشین مجازی :

echo ‘nameserver ‘ >> /etc/resolv.conf

راه حل اصلی:

neutron subnet-update   –dns-nameservers list=true  ...

: nova availability zone نحوه ایجاد یک

$ nova aggregate-create test-aggregate2 test-az
+----+-----------------+-------------------+-------+----------+
| Id | Name            | Availability Zone | Hosts | Metadata |
+----+-----------------+-------------------+-------+----------+
| 2  | test-aggregate2 | test-az           |       |          |
+----+-----------------+-------------------+-------+----------+

ref: http://blog.russellbryant.net/2013/05/21/availability-zones-and-host-aggregates-in-openstack-compute-nova/

چرا با توجه به اینکه نود کامپیوت خالی داریم ولی سیستم در حین اجرای ماشین مجازی پیغام 

 رو دریافت می کنیم ؟ Error: No valid host was found.

: مراجعه نماییم با خطای زیر مواجه می شویم /var/log/nova/nova-scheduler.log اگر به پیغام های خطا در فایل

2015-08-15 14:38:36.496 929 INFO nova.filters [req-dfb4facf-205d-4277-8e3d-c6fa5b993177 bb00ebc3588144bf892a0ea9ba3819ca 8a70cf18a2c84768a25cc2a99821f1af] Filter RamFilter returned 0 hosts

دلیل این امر اینه که احتمالا بر روی نود کامپیوت ماشین مجازی بوده  و شما اونو حذف کردین ولیکن در پایگاه داده بروز رسانی نشده و در اینجا خطا میده که فضای حافظه اصلی کمتر از میزان درخواستی داریم. با استفاده از دستور زیر میشه فهمید که چقدر از منابع یک نود کامپیوت مصرف شده

iman@work:~/OpenStack$ nova host-describe compute10
+———–+————+—–+———–+———+
| HOST      | PROJECT    | cpu | memory_mb | disk_gb |
+———–+————+—–+———–+———+
| compute10 | (total)    | 8   | 7982      | 454     |
| compute10 | (used_now) | 16  | 8512      | 200     |
| compute10 | (used_max) | 0   | 0         | 0       |
+———–+————+—–+———–+———+

راه حل اینه که سرویس کامپیوت بر روی نود کامپیوتی که این مشکل رو داره رو  دوباره راه اندازی کنین :

root@compute10:~# service nova-compute restart

اگر دوباره خروجی بگیریم بصورت زیر در میاد

iman@work:~/OpenStack$ nova host-describe compute10
+———–+————+—–+———–+———+
| HOST      | PROJECT    | cpu | memory_mb | disk_gb |
+———–+————+—–+———–+———+
| compute10 | (total)    | 8   | 7982      | 454     |
| compute10 | (used_now) | 0   | 512       | 0       |
| compute10 | (used_max) | 0   | 0         | 0       |
+———–+————+—–+———–+———+

howto enable text mode in ubuntu 14.04 to use console in TEXTCONS ILO HP servers

hi.

by default, when you ssh to ilo of server and type TEXTCONS (to use shell) you see this error:

Monitor is in graphics mode or an unsupported text mode.

so you need to add “vga=normal nomodeset 3″  to kernel boot parameters like this:

1. open /etc/default/grub config file:

#vim /etc/default/grub

2. add the following line to the file like this:

GRUB_CMDLINE_LINUX_DEFAULT=”vga=normal nomodeset 3”
3. update grub:

# update-grub

BTW: you need to disable Power-On logo in system BIOS. At boot time, press F9 and when you are in RBSU locate Advanced Options > Advanced System ROM Options > Power-On Logo, and set it to Disabled. The first part is solved, when you boot your server you can watch POST messages on ilo text cons while booting up.

ref: http://h20565.www2.hp.com/hpsc/doc/public/display?sp4ts.oid=4091412&docId=emr_na-c02700808&lang=en&cc=us

http://ops.kinja.com/dealing-with-ilo-text-console-634258567

howto enable HBA port directly from kvm to windows server virual guest by using pci passtrough ?!

hi. this is mini howto, to enable HBA port directly from kvm to windows server virual guest by using pci passtrough. i tested it, on “HP DL380 G8 PRO” with no problem.

1. Enable the Intel VT-d extensions in the BIOS. (this option is enabled by default for dl380 g8 pro)
2. Enable SR-IOV in the BIOS. (this option is in “advanced options” of bios menu)
3. Activate Intel VT-d in the kernel by appending the intel_iommu=on in the /etc/default/grub file, like this:
GRUB_CMDLINE_LINUX_DEFAULT=”intel_iommu=on”
4. to identify device run:
#lspci  | grep HBA
0a:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
search for 0a:00.0 in kvm list by running this:
]# virsh nodedev-list | grep pci
pci_0000_00_00_0
pci_0000_00_01_0
pci_0000_00_03_0
pci_0000_00_04_0

pci_0000_05_00_0
pci_0000_06_02_0
pci_0000_06_04_0
pci_0000_07_00_0
pci_0000_07_00_1
pci_0000_08_00_0
pci_0000_08_00_1
pci_0000_09_00_0
pci_0000_0a_00_0
pci_0000_0b_03_0

to get information of device run the following command:
# virsh nodedev-dumpxml pci_0000_0a_00_0
<device>
<name>pci_0000_0a_00_0</name>
<parent>pci_0000_00_09_0</parent>
<driver>
<name>mpt2sas</name>
</driver>
<capability type=’pci’>
<domain>0</domain>
<bus>10</bus>
<slot>0</slot>
<function>0</function>
<product id=’0x0072′>SAS2008 PCI-Express Fusion-MPT SAS-2 [Falcon]</product>
<vendor id=’0x1000′>LSI Logic / Symbios Logic</vendor>
</capability>
</device>

Above is the HBA card which we need to assign to the virtual host directly .
you can add xml outputs to vm by using ‘virsh edit VMNAME’ or just simply add it by using virt-manger. in information tab of virt-manager just add “pci hardware”,
and search for line which has “0a:00.0” code and add it to your vm’s hardware. now it’s ready to use your HBA in vm’s machine.

howto set PROMISCUOUS MODE and enable it in openvswitch ?

hi. setting on nic card is so simple :

enabling :    # ifconfig ethX promisc

disable :      # ifconfig ethX -promisc

you can add this feature in /etc/network/interfaces like this :

auto ethX
iface ethX inet manual
up ifconfig $IFACE promisc

….

down ifconfig $IFACE -promisc

————————————-

https://raw.githubusercontent.com/openvswitch/ovs/master/FAQ :

Q: Does Open vSwitch support configuring a port in promiscuous mode?

A: Yes.  How you configure it depends on what you mean by "promiscuous
   mode":

      - Conventionally, "promiscuous mode" is a feature of a network
        interface card.  Ordinarily, a NIC passes to the CPU only the
        packets actually destined to its host machine.  It discards
        the rest to avoid wasting memory and CPU cycles.  When
        promiscuous mode is enabled, however, it passes every packet
        to the CPU.  On an old-style shared-media or hub-based
        network, this allows the host to spy on all packets on the
        network.  But in the switched networks that are almost
        everywhere these days, promiscuous mode doesn't have much
        effect, because few packets not destined to a host are
        delivered to the host's NIC.

        This form of promiscuous mode is configured in the guest OS of
        the VMs on your bridge, e.g. with "ifconfig".

      - The VMware vSwitch uses a different definition of "promiscuous
        mode".  When you configure promiscuous mode on a VMware vNIC,
        the vSwitch sends a copy of every packet received by the
        vSwitch to that vNIC.  That has a much bigger effect than just
        enabling promiscuous mode in a guest OS.  Rather than getting
        a few stray packets for which the switch does not yet know the
        correct destination, the vNIC gets every packet.  The effect
        is similar to replacing the vSwitch by a virtual hub.

        This "promiscuous mode" is what switches normally call "port
        mirroring" or "SPAN".  For information on how to configure
        SPAN, see "How do I configure a port as a SPAN port, that is,
        enable mirroring of all traffic to that port?"

BTW : you can run 'netstat -i' to check if PROMISCUOUS MODE is enabled :
$ netstat -i

Look under the last column “Flg” for value “P”. If it’s there, it means promiscuous mode is enabled for that network interface. Is the flag really P and not M? Here’s a quick test. Check existing active flags:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0  2075   0      0      0     1370      0      0      0 BPRU
lo   16436 0  1985    0    0      0     1985      0      0      0 LRU

How to set the target device name for VM to track port in openvswitch ?

hi.
in general, when we add a virtual network interface card to your virtual machine, some generic name will be appear as device port on openvswitch like this :
root@vt127:~# ovs-vsctl show
aa2dd5b1-4706-4f4a-bf65-c8119244e54e
Bridge “ovsbr0”
Port “vnet0”
tag: 36
Interface “vnet0”
Port “ovsbr0”
Interface “ovsbr0”
type: internal
Port “vnet3”
tag: 34
Interface “vnet3”
Port “vlan36”
tag: 36
Interface “vlan36”
type: internal
Port “vnet2”
tag: 36
Interface “vnet2”
Port “vnet4”
Interface “vnet4”
Port “p6p1”
trunks: [24, 35, 36]
Interface “p6p1”
ovs_version: “2.0.1”

so we don’t know which port is assigned to which vm’s nic card (vnet0, vnet1, …). I strongly recommend to set the target device name. This is the name of the network interface seen on the openvswitch. I always start the name with “veth”. The number following is the interface number on the guest. And I add the name of the VM. So veth0-vmtest corresponds to eth0 on the guest vmtest. If you do not set the interface name, they will get vnet. If you have to troubleshoot something on the virtual network, predefined interface names help a lot. do it like this in your xml’s domain :

<interface type=’bridge’>
<virtualport type=’openvswitch’>
</virtualport>
      <target dev=’veth0-vmtest’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x06′ function=’0x0’/>
</interface>

 

howto change virtual box’s uuid hard disk ???

hi.
i tried to copy my .vdi image to some other server, so i got this error :

Failed to open the hard disk /media/vms-file/.vdi.
Cannot register the hard disk ‘/media/vms-file/.vdi’ {3e2ca4ea-fcab-47f9-8b04-fa42131af5a4} because a hard disk ‘/media/vms-file/DDS_2_ubuntuDesktop-14.04/.vdi’ with UUID {3e2ca4ea-fcab-47f9-8b04-fa42131af5a4} already exists.
Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {3b2f08eb-b810-4715-bee0-bb06b9880ad2}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

solution: run this command :
# VBoxManage internalcommands sethduuid mydisk.vdi

howto get access ilo’s “Direct terminal access” via Serial Console

hi

so you’ve got some HP DL’s (like dl380 … ) servers and you’ve setup ilo to get access to terminal.

after you enabled ssh remote access (it is enabled by default) for ilo run this :

# ssh <user>@<ilo-ip-address>

</>hpiLO-> TextCons

maybe your terminal freezzzz . so in os you should add this line in /etc/default/grub :

GRUB_CMDLINE_LINUX_DEFAULT=”vga=normal nomodeset 3″

# update-grub

# reboot

then try again.

BTW : i’ve got some nice tutorial to enable serial console for virtual machines here .