Friday, December 16, 2011

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable),How to fix (Solved)

As a administer, newbie UNIX/Linux user ,or developer/programmer  , you face a problem like this in your shell/bash  in Ubuntu/Debian when any package is broken or due to any reason  your get lock /var/lib/dpkg/lock. or like below you face problem

root@pythongeek:~# apt-get update
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

you can fix this problem in few steps without rebooting !!

1) type this in bash

    sudo dpkg --configure -a

2) type in bash

    sudo killall apt-get apt aptitude adept synaptic

your output like this

root@pythongeek:~# sudo killall apt-get apt aptitude adept synaptic
apt-get: no process found
apt: no process found
aptitude: no process found
adept: no process found
synaptic: no process foun

Note:if you face problem during installation of any software/package

don't forget accept EULA ,or accepting licensee of user agreement while you have pop-up during installation
3) this is final if you failed last to attempt to unlock
Close all running packages, and open a Konsole window.

type in bash

sudo rm /var/lib/dpkg/lock

then again type this bash

sudo dpkg --configure -a

for reinstallation type like this in bash

sudo apt-get  install -f  package  name here



LHS as a source of information – and a source of inspiration – I hope you’ll choose to act right now.enjoy keep learning.

Sunday, December 11, 2011

Installing openstack on Ubuntu using Devstack with ease in 15 min only (Cloud computing part 2)

Devstack script is a useful tools and good tutorial for us.

It help me know how to install openstack(nova, glance, keystone and so on) from git. And teach us how to config them and make them work fine together. Now using devstack script is very easy if you just want to set up an openstack environment for learning.

Remember you need not install mysql and anything else in advance it will automatically installed from script   

Make sure your system is 11.10 Ubuntu server
you can test it in your really machine or in your vmware or virtualbox desktop machine.

Make sure you open your virtualization switch in your BIOS setting.
you need have to two interfaces, ie eth0 and eth1
$ sudo apt-get install bridge-utils     # install birdge
$ vi /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

auto br100
iface br100 inet static
bridge_ports eth2
bridge_stp off
bridge_maxwait 0
bridge_fd 0

in this file, eth0 is your public network, you need it to connect to internet. eth2(maybe in your system is eth1) is another network interface used as a bridge(br100), is your private ip, it is not need connect to any other network in our test.just choose a private network like and remember.

$ sudo apt-get install git
$ git clone git://
$ cd devstack
$ vi localrc
add these info into localrc


$ ./stack

it will ask for some password, remeber don't use special characters like $*_.! and so on. you can simply set password like 123456
then it will begin install , how much it take depends on your network bandwidth. If it failed since of network or some reason. look at error log carefully, delete /opt/stack/devstack and run ./stack again.

At last, you will see successful information, and then you can type your IP in your browser. Enjoy your open-stack time and it is a good thing you need learning more and more. finally you are here .

Looking for Help/ Technical support  !

Feel free to mail me



LHS as a source of information – and a source of inspiration – I hope you’ll choose to act right now.enjoy keep learning.

Creating a Private Cloud using Openstack in Ubuntu Maually (Cloud Computing Part 1)

This article dedicated to developer ,project leaders , Cloud architects . I am gonna explain how to setup a cloud using command line .This useful for newbies to cloud and UNIX both !

I am using a Ubuntu 11.10 (64 bit server ), so lets play with shell !!

for setting up a prefect cloud you need minimum two network NIC on your hardware , a lot of public Ip . :)

But i am setting it on one network  it on one NIC hardware , with One IP (students and tester can with way those have less resources ) :)

We are setting up it with open-stack .
Official website of this document is below:

ubuntu 11.10 environment deployment, select the network mode FLATDHCP

public interface: eth0 used to connect to the user
private interface: eth1 do bridge br100, used, and other nodes, keystone, glance, volume and other connections

Minimum installed Ubuntu

Remember to open-ssh installed, where we have established a common user open-stack

Giving it the NOPASSWD sudo privileges, so easy to operate behind

$ Sudo apt-get update          //  (apt update about the tree)
$ Sudo apt-get install bridge-utils     //   (  installed bridge components )

Configure the network
$ vi / etc / network / interfaces      //(gksudo also can be used instead of vi for GUI Fans )

auto eth0
iface eth0 inet static

auto br100
iface br100 inet static
bridge_ports eth1
bridge_stp off
bridge_maxwait 0
bridge_fd 0

$ Sudo / etc / init.d / networking restart

Initial preparatory work to do, the next step is to install on nova, glance and other components

$ Sudo apt-get install-y rabbitmq-server  // (install the MQ message components )
$ Sudo apt-get install-y python-greenlet python-mysqldb     // (install Python dependencies )

Next, install the various nova components and dependencies

$ Sudo apt-get install nova-volume nova-vncproxy nova-api nova-ajax-console-proxy
$ Sudo apt-get install nova-doc nova-scheduler nova-objectstore
$ Sudo apt-get install nova-network nova-compute
$ Sudo apt-get install glance

Installation euca2ools and unzip
$ Sudo apt-get install-y euca2ools unzip

Next we install the database, I chose MYSQL, PostgreSQL actually personally feel better
$ Sudo su - to root user to change
# MYSQL_PASS = nova nova set mysql database password and the password
# NOVA_PASS = notnova here nova and notnova modified according to their definitions
# Cat <<MYSQL_PRESEED | debconf-set-selections
> Mysql-server-5.1 mysql-server/root_password password $ MYSQL_PASS
> Mysql-server-5.1 mysql-server/root_password_again password $ MYSQL_PASS
> Mysql-server-5.1 mysql-server/start_on_boot boolean true
# Apt-get install-y mysql-server
# Exit exit root environment

$ Sudo sed-i 's/' / etc / mysql / my.cnf modify my.cnf configuration file
$ Sudo service mysql restart

$ MYSQL_PASS = nova in the general user environment variable to the password once again set about
$ NOVA_PASS = notnova
$ Sudo mysql-uroot-p $ MYSQL_PASS-e 'CREATE DATABASE nova;'

// (to create a name for the ova of the database, I recommend that new users nova's name, if here for another name, then the configuration file in the nova which also need to change )
$ Sudo mysql-uroot-p $ MYSQL_PASS-e "GRANT ALL PRIVILEGES ON *.* TO
$ Sudo mysql-uroot-p $ MYSQL_PASS-e "SET PASSWORD FOR 'nova'@'%' =

This point. nova, glance of the installation completed, next is the configuration

nova configuration
$ Sudo vi / etc / nova / nova.conf
- Dhcpbridge_flagfile = / etc / nova / nova.conf
- Dhcpbridge = / usr / bin / nova-dhcpbridge
- Logdir = / var / log / nova
- State_path = / data / openstack / nova here / data / openstack / nova is a new volume and directory, make sure you have this, and the user should belong to nova
- Instances_path = / data / openstack / nova / instances to modify the default storage of instances where
- Lock_path = / var / lock / nova
- Force_dhcp_release = True
- Use_deprecated_auth
- Iscsi_helper = tgtadm
- Verbose
- Scheduler_driver = nova.scheduler.simple.SimpleScheduler
- Network_manager =
- My_ip = This is my ip address within the network
- Public_interface = eth0
# - Vlan_interface = eth0
- Sql_connection = mysql: / / nova: notnova @ localhost / nova
- Libvirt_type = kvm
# - Osapi_extensions_path = / opt / nova / bin / openstackx / extensions
# - Vncproxy_url =
# - Vncproxy_wwwroot = / data / stack / noVNC /
- Api_paste_config = / etc / nova / api-paste.ini
- Image_service = nova.image.glance.GlanceImageService
- Ec2_dmz_host =
- Ec2_url =
- Rabbit_host = localhost
- Glance_api_servers =
- Flat_network_bridge = br100
- Flat_interface = eth1
- Flat_network_dhcp_start = specified instances allocated from the beginning from the 51, but looks like this option does not work
- Fixed_range = This option specifies the instances of the network segment
- Flat_injected = False
- Multi_host = 1 using multi_host
- Libvirt_use_virtio_for_bridges instances using virtio network card model do
# - Start_guests_on_host_boot = true
# - Resume_guests_state_on_host_boot = true
- Use_ipv6 = false

$ Sudo vi / etc / glance / glance-api.conf
// (In this file without using keystone of the present case, according to your needs, modify filesystem_store_datadir parameter to specify the directory you need to store images, Dangran are the main users have Gaicheng glance )
$ Sudo vi / etc / glance / glance-registry.conf
// (This file can be selected to modify sql_connection parameter to specify your database. Of course you can not change.
If you want to modify, use mysql which database to ensure that the mysql which established a corresponding database )

sql_connection = mysql: / / nova: notnova @ localhost / glance this is my configuration, I created a glance in the mysql database

$ Sudo chown-R root: nova / etc / nova to change / etc / nova's owner
$ Sudo chmod 640 / etc / nova / nova.conf

Restart all services
$ Sudo restart libvirt-bin
$ Sudo restart nova-network
$ Sudo restart nova-compute
$ Sudo restart nova-api
$ Sudo restart nova-objectstore
$ Sudo restart nova-scheduler
$ Sudo restart glance-registry
$ Sudo restart glance-api
Note: We do not have from the nova-volume, because although we installed the volume, but the volume needs to use a separate vg, we have not configure the volume, so get up.

There may be network services and can not compute it, do not worry about being first

Next, we do configure the operating environment of the nova
$ Sudo nova-manage db sync
nova-manage user admin <user_name> where we can create a user, such as
$ Sudo nova-manage user admin test, create a successful return on the screen like:
export EC2_ACCESS_KEY = d6aa7747-4324-4abc-9604-4f7d6a2f8f3f
export EC2_SECRET_KEY = 2b204b75-da2d-47b8-ba7a-611d71f0ecbf

nova-manage project create <project_name> <user_name> create a project, we built that are just users, such as:
$ Sudo nova-manage project create test-proj test
nova-manage network create - help create an instance of the network, such as:
$ Sudo nova-manage network create - label = test-net - fixed_range_v4 = - num_network = 1 - network_size = 256

Services have failed to start again
$ Sudo start nova-network
$ Sudo start nova-compute
$ Sudo start nova-scheduler
In addition, since each service, the best look at the log, such as sudo tail-f / var / log / nova / nova-network to determine there is no error, you can also use the ps aux | grep [n] ova-network to confirm the service is not open. If the starting service fails, you confirm that a good reason to modify a good future, need to use sudo start to play instead of sudo restart

Well. This computing environment, we deployed the. We can look at the state command
$ Sudo nova-manage service list
$ Sudo nova-manage network list

Next, create a certificate, to facilitate the tool we use euca
$ Cd
$ Mkdir creds
$ Sudo nova-manage project zipfile test-proj test creds /
$ Unzip creds / creds /
$ Source creds / novarc

OK, done, we can use the tool to look at
$ Euca-describe-availability-zones verbose
VAILABILITYZONE nova available
AVAILABILITYZONE | | - Nova-network enabled :-) 2011-10-17 04:45:44
AVAILABILITYZONE | | - Nova-compute enabled :-) 2011-10-17 04:45:45
AVAILABILITYZONE | | - Nova-scheduler enabled :-) 2011-10-17 04:45:46

So far, successfully enabled services. When you find that service is not working, use ps aux | grep nova check services are not open, and the need for detailed observations / var / log / nova / directory log files for each service, in order to obtain further information.

Then we can use kvm to create a mirror image

$ Sudo apt-get install kvm-pxe installation about this, otherwise there will be time to run kvm warning
$ Kvm-img create-f raw server.img 5G
$ Sudo kvm-m 1024-cdrom rhel5.iso-drive file = server.img, if = virtio, index = 0-boot d-net nic-net user-nographic-vnc: 0

Here we use rhel5(Redhat) the iso, after running this command, you can use vnc to connect the machine to connect to your server: ssvncviewer 0
Open vnc you can see the installation interface After the installation, the following paragraph written rhel mirror / etc / rc.local the beginning of the
modprobe acpiphp

# Simple attempt to get the user ssh key using the meta-data service
mkdir-p / root / .ssh
echo>> / root / .ssh / authorized_keys
curl-m 10-s | grep 'ssh-rsa'>> / root / .ssh / authorized_keys
echo "************************"
cat / root / .ssh / authorized_keys
echo "************************"
Save and exit, so that image on the well

Upload images using glance
$ Glance - verbose add name = "rhel5" disk_format = raw is_public = true <server.img
You should also observe the / var / log / glance / registry and the log api
$ Glance index to see a list of mirrors

Start your instance
$ Euca-describe-images
You can now view the image, output similar to the
IMAGE ami-00000003 server.img
Remember this image here ami-000000003 No.
$ Euca-run-instances-t m1.tiny ami-00000003 start an instance of ami-00000003 image
-T specifies the type of instance, provides the type of cpu, memory, disk size, etc..
Watch / var / log / nova / nova-api.log nova-scheduler.log, nova-compute, nova-network.log of output, but you can also use vnc to connect serverip: 0 look at the console instance
With the command $ euca-describe-instances to see your current instance of the first instance will be relatively slow start because of the need to copy the image from a glance under the instance directory to the nova

Conclusion As the nova is currently growing fast, diablo release version of the function of some of the requirements to be completed daily. But the development version of the nova can be better combined with keystone, novaclient, dashboard and some other projects. Makes openstack more robust. Friends who are interested, you can use in a production environment repo's installation, test development versions of the test environment. Since I use in a production environment install git development version. Therefore, a more complete integration of follow-up, I will develop versions of the form. Of course, using the development version, then there will be more trouble, but also have more fun and hands-on practice, to further understand the mechanism of its working principle.

Looking for help /technical support  !

Feel free to mail me



LHS as a source of information – and a source of inspiration – I hope you’ll choose to act right now.enjoy keep learning.