Monday, September 24, 2012

VM “Device eth0 does not seem to be present”

Need to remove this file from the folder
mv  /etc/udev/rules.d/70-persistent-net.rules  ~/

Saturday, September 22, 2012

Patch ESXi 5

1, download patch from VMware.com, mine is ESXi500-201207001.zip

2, Enable ESXi 5 ssh

3, scp ESXi500-201207001.zip to ESXi

4, make sure file is not broken
This file size is:
~ # ls /vmfs/volumes/datastore1/ -l
-rw-r--r--    1 root     root          594036729 Sep 23 01:54 ESXi500-201207001.zip

5, do update
~ # esxcli software vib install -d /vmfs/volumes/datastore1/ESXi500-201207001.zip

If you see the error like:
Could not download from depot at zip:/vmfs/volumes/datastore1/ESXi500-201207001.zip?index.xml, skipping (('zip::/vmfs/volumes/datastore1/ESXi500-201207001.zip?index.xml', '', "Error extracting index.xml from ::/vmfs/volumes/datastore1/ESXi500-201207001.zip: [Errno 2] No such file or directory: :/vmfs/volumes/datastore1/ESXi500-201207001.zip?index.xml'"))
url = zip:
:/vmfs/volumes/datastore1/ESXi500-201207001.zip?index.xml
Please refer to the log file for more details.

This means this zip file has some issue:
1, not exist
or 2, broken

Wednesday, July 25, 2012

curl send file with filename

Put filename in the header
curl -H "Content-type: application/octet-stream"  -H "Filename: install.log"  -X POST http://127.0.0.1:5000/messages --data-binary @install.log

Friday, June 22, 2012

first qpid ruby example

Step 1: Add Exchange, Queue, and bind them.

[root@localhost qpidclient]# qpid-config -a guest/guest@localhost add exchange topic mytopic  --durable
[root@localhost qpidclient]# qpid-config -a guest/guest@localhost add queue myqueue
[root@localhost qpidclient]# qpid-config -a guest/guest@localhost bind mytopic myqueue

Using qpid-tool to check if add exchange and queue  successfully.


[root@localhost qpidclient]# qpid-tool
qpid: list exchange
Objects of type org.apache.qpid.broker:exchange
    ID   Created   Destroyed  Index
    ===============================================
    104  13:17:03  -          103.
    111  14:36:44  -          103.mytopic
 qpid: list queue
Objects of type org.apache.qpid.broker:queue
    ID   Created   Destroyed  Index
    ==============================================================
    117  14:38:50  -          103.myqueue


Step 2: Ruby Qpid producer code / server
[root@localhost qpidclient]# vim producer.rb
#!/usr/bin/env ruby

require "rubygems"
require "qpid"
require "socket"

conn = Qpid::Connection.new(TCPSocket.new("localhost", 5672),
                                         :username => "guest",
                                         :password => "guest")
conn.start(10)

ssn = conn.session("qpid_producer")

# create a queue
ssn.queue_declare("myqueue")
ssn.exchange_declare("mytopic", :type => "topic")

dp = ssn.delivery_properties(:routing_key => "myqueue")
mp = ssn.message_properties(:content_type => "text/plain")

ssn.message_transfer(:message => Qpid::Message.new(dp, mp, "hi5"))
while line = gets.strip
  break if line =~ /^(bye)$/i
  ssn.message_transfer(:message => Qpid::Message.new(dp, mp, line.strip))
end
ssn.message_transfer(:message => Qpid::Message.new(dp, mp, "exit"))
ssn.sync

ssn.close()
conn.close()




Step 3 QPID consumer code:


[root@localhost qpidclient]# vim consumer.rb
#!/usr/bin/env ruby

require "rubygems"
require "qpid"
require "socket"

conn = Qpid::Connection.new(TCPSocket.new("localhost", 5672),
                                         :username => "guest",
                                         :password => "guest")
conn.start(10)

ssn = conn.session("qpid_consumer")

incoming = ssn.incoming("messages")
ssn.message_subscribe(
  :destination => "messages",
  :queue => "myqueue",
  :accept_mode => ssn.message_accept_mode.none
)

# start incoming message flow
incoming.start()

while true
 body = incoming.get().body
 puts body
 break if body == "bye"
end

ssn.close()
conn.close()

Step 4: run producer and consumer
[root@localhost qpidclient]# ./producer.rb
hi
hello


[root@localhost qpidclient]# ./consumer.rb
hi
hello



Thursday, June 14, 2012

mysql change root password

mysql change root password

1, To setup root password for first time, use mysqladmin command at shell prompt as follows:
$ mysqladmin -u root password NEW_PASSWORD

2, update a root password,

$mysqladmin -u root -p'oldpassword' password newpass

For example,change old password 123 to 456
$ mysqladmin -u root -p123 password '456'

Monday, June 11, 2012

centos install git - use yum install

1,  Add the EPEL repository, then install it using yum.

  wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
 
2, Install DAG's GPG key and Verify the package you have downloaded
    rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
    rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm

3, Install it
 rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm

4, install git using yum
  yum install git