Archive

Author Archive

resolved – perl get only package/file names and not including package version number

May 9th, 2013 No comments

I got a list of packages installed on my centos linux box via:

rpm -qa|sort|uniq|sort

The result is like:

acl-2.2.39-8.el5
acpid-1.0.4-12.el5
alacarte-0.10.0-1.fc6
alsa-lib-1.0.17-1.el5
alsa-lib-devel-1.0.17-1.el5
amtu-1.0.6-2.el5
anacron-2.3-45.el5.centos
apr-1.2.7-11.el5_6.5
apr-util-1.2.7-11.el5_5.2

But now I only want the package names without version number, that is like:

acl
acpid
alacarte
alsa-lib
alsa-lib-devel
amtu
anacron
apr
apr-util

Here’s the perl script to fulfill this:

#!/usr/bin/perl
open($temp1,”<”,”/doxer/test/package-names.txt”) or die(“error opening”);
while(<$temp1>){
if($_ =~ /([a-zA-Z].*?)\-[0-9]{1,}\.[0-9]{1,}.*/){
print $1.”\n”;
}
}

Categories: Perl, Programming Tags:

difference between paused and suspended

May 2nd, 2013 No comments

Note: this is from book <Oracle VM Implementation and Administration Guide>

  • Paused

This state preserves the machine’s current settings and application
states without releasing system resources, allowing the machine to resume
this state with a short load period. In this state, the virtual machine
consumes memory and disk resources but very little CPU resources. When
in the paused state, you can unpause the virtual machine.

  • Suspended

In this state, the machine’s current settings and application

states are preserved by saving them to respective files and essentially
turning off the virtual machine, releasing system resources and allowing
the machine to resume the same settings, applications, and processes upon
leaving the state. In this state, the virtual machine only consumes disk
resources. From the suspended state, you can resume the virtual machine.

  • Summary

Both the paused and suspended states offer the ability to stop the virtual machine
in its exact current operating state and to return the machine to that state upon
resuming. The difference between the two states is the manner in which the
machine’s settings are preserved and how the resources that the virtual machine
uses are affected.
Putting a virtual machine into the paused state simply stops the execution of
further commands momentarily, much like a Windows desktop enters Sleep mode.
In the paused state, the machine’s applications and settings are left in the state that
they were in when the paused state was entered—simply stopped. The settings and
application states are not saved to files that are then used upon resuming; they are
simply stopped as they are. This allows for a fairly short load period upon resuming,
but the virtual machine also continues to utilize (some of) the machine’s resources.
If the desire is to simply halt execution of the virtual machine for a short period
of time and to restart it quickly, then you should choose to pause. This option
provides a fast restart but will hold system resources. If the VM Server were to fail,
the paused system will be lost and require recovery if applicable.
Suspending a virtual machine essentially turns the machine off while preserving
its current settings. Application states, data, and other settings are copied to their
respective files and any resources used by the virtual machine are released. Upon
resuming a suspended virtual machine, after an initial load period, during which the
machine retrieves its settings and application states from these saved files and resumes
use of the server resources, all applications resume the same state they were in.
Suspending a system is a good option if you want to stop the system at a
particular point in time and keep it in that state for an extended period of time.
However, if you want to not use the system for a while, simply shutting it down
might be a better option.

Categories: Clouding Tags:

xen netfront netback

May 2nd, 2013 No comments

Note: this is from http://zhigang.org/blog/xen-dom0-networking/

Xen hypervisor itself doesn’t has any networking support (in fact, no any other device drivers except the console). All the networking infrastructure is done in dom0.

Dom0 and domU use the split network driver to communicate. Dom0 will create vif. using netback, and connect it with the virtual interface in domU, which is initialed by netfront.

Dom0 also has vif0.0, vif0.1, etc and veth0, veth1, etc. But it’s absolutely different things, and nothing to do with netback/netfront. They are created by the net loopback driver, mainly for dom0 to communicate with the bridged networking. The net loopback driver is obsolete in xen 3.2+ (dom0 will use the bridge directly).

The net loopback driver usually compiled to the kernel. To prevent it from creating the looped vifs, by passing “netloop.nloopbacks=0″ to the kernel command line.

You can attach virtual network interface to Dom0, just as for domU:

# xm network-attach 0

By default, the newly attached vif will named vif0.0. So the name will fail duo to conflicting with the loopback vifs. To make it work, either prevent the net loopback driver from creating these vifs, or specify a different vif name when attaching:

# xm network-attach 0 vifname=<uniq-vif-name>

Even after netback create the vif, then netfront driver in Dom0 still cannot initial it. See the codes in drivers/xen/netfront/netfront.c:netif_init:

if (is_initial_xendomain())
    return 0;

PS:

You can find more details on http://www.oracle.com/technetwork/articles/servers-storage-admin/networking-ovm-x86-1873548.html (about Oracle VM, but applicable to XEN)

Categories: Clouding Tags:

xen domu to dom0 interaction – PV channel and QEMU-DM

May 2nd, 2013 No comments

Note: This is from book <Oracle VM Implementation and Administration Guide>.

Because of the interaction between domU and dom0, several communication channels are created between the two.

  • In a PV environment, a communication channel is created between dom0 and each domU, and a shared memory channel is created for each domU that is used for the backend drivers.
  • In an HVM environment, the Qemu-DM handles the interception of system calls that are made. Each domU has a Qemu-DM daemon, which allows for the use of network and I/Os from the virtual machine.
Categories: Clouding, Oracle Cloud Tags:

Resolved – ORA-00001: unique constraint (OVS.OVS_OS_RESOURCE_PK) violated

May 2nd, 2013 No comments

If you met error “Resolved – ORA-00001: unique constraint (OVS.OVS_OS_RESOURCE_PK) violated” during starting up OVM oc4j, you can try the following workaround:

  • log on OVM vm and connect to oracle XE

[oracle@test-host ~]$ ps -ef|grep LISTENER
oracle 1726 1 0 Apr28 ? 00:00:00 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/tnslsnr LISTENER -inherit
oracle 24737 24712 0 03:53 pts/0 00:00:00 grep LISTENER
[oracle@test-host ~]$
[oracle@test-host ~]$ export ORACLE_SID=XE

[oracle@test-host ~]$export ORACLE_HOME=’/usr/lib/oracle/xe/app/oracle/product/10.2.0/server’

[oracle@test-host ~]$ $ORACLE_HOME/bin/sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 – Production on Thu May 2 03:54:22 2013

Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 – Production

SQL>

  • Now backup OVS.OVS_OS_RESOURCE table

SQL> create table OVS.OVS_OS_RESOURCE_backup as select * from OVS.OVS_OS_RESOURCE;

  • Now we can truncate the table OVS.OVS_OS_RESOURCE

SQL> delete from OVS.OVS_OS_RESOURCE;
SQL> commit;

  • Now you can redo the oc4j restart, the error message should gone
  • After oc4j is up, you should now recover OVS.OVS_OS_RESOURCE to its original state

SQL> select OWNER,TABLE_NAME from dba_all_tables t where t.TABLE_NAME like ‘OVS_OS_RESOURCE%’;

OWNER TABLE_NAME
—————————— ——————————
OVS OVS_OS_RESOURCE
OVS OVS_OS_RESOURCE_BACKUP
insert into OVS.OVS_OS_RESOURCE select * from OVS.OVS_OS_RESOURCE_BACKUP;

 

Categories: Clouding, Oracle Cloud Tags:

perl script for getting sun zfs head project and share usage info

April 26th, 2013 No comments

Sometimes you would like to know on sun zfs head, which project occupies most of the space, and which shares of that occupies most space of that project.

Here’s a perl script to fulfill this(it’s a little cumbersome, but it works anyway)

#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;
use List::Util qw/sum/;
my $host = ‘test-zfs-host’;
my $user = ‘root’;
my $password = ‘password’;

my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user,$password);
my ($stdout,$stderr,$exit) = $ssh->cmd(“shares show”);
my @std_arr=split(/:/,$stdout);
my @projects_arr = split(/\n/, $std_arr[2]);

foreach(@projects_arr){
$_ =~ s/^\s+|\s+$//g;
}
shift @projects_arr;
pop @projects_arr;
pop @projects_arr;

my @space_projects;
foreach(@projects_arr){
my ($stdout2,$stderr2,$exit2) = $ssh->cmd(“shares select $_ get”);
my @stdout_arr=split(/\n/,$stdout2);
my $space_temp=join(“\n”,grep(/space_total/,@stdout_arr));
my @space_total_project = “project “.$_.$space_temp;
push(@space_projects,@space_total_project);
}
my @space_projects3;
foreach(@projects_arr){
my ($stdout3,$stderr3,$exit3) = $ssh->cmd(“shares select $_ ls”);
my @stdout_arr3=split(/\n/,$stdout3);
my @space_temp3=grep(/\/export\//,@stdout_arr3);
my @space_temp4=grep(!/mountpoint/,@space_temp3);
push(@space_projects3,@space_temp4);
}
open(my $temp1,’>’,'/var/tmp/temp1′) or die(“cannot open file temp1″);
open(my $temp2,’>’,'/var/tmp/temp2′) or die(“cannot open file temp2″);
open(my $temp3,’>’,'/var/tmp/temp3′) or die(“cannot open file temp3″);
open(my $temp4,’>’,'/var/tmp/temp4′) or die(“cannot open file temp4″);
my @var_T;
my @var_G;
my @var_M;
my @var_K;

foreach(@space_projects){
if($_ =~ /.+space_total\s+(.*)K/){
push(@var_K,$_);
}
elsif($_ =~ /.+space_total\s+(.*)M/){
push(@var_M,$_);
}
elsif($_ =~ /.+space_total\s+(.*)G/){
push(@var_G,$_);
}
elsif($_ =~ /.+space_total\s+(.*)T/){
push(@var_T,$_);
}
}

select $temp1;
foreach(@var_T){
print $_.”\n”;
}
close $temp1;

select $temp2;
foreach(@var_G){
print $_.”\n”;
}
close $temp2;
select $temp3;
foreach(@var_M){
print $_.”\n”;
}
close $temp3;
select $temp4;
foreach(@var_K){
print $_.”\n”;
}
close $temp4;

system(“echo \”======zfs project usage info(Descending)======\”");
system(“sort -r -n -k 5 /var/tmp/temp1;sort -r -n -k 5 /var/tmp/temp2;sort -r -n -k 5 /var/tmp/temp3;sort -r -n -k 5 /var/tmp/temp4″);
open(my $temp5,’>’,'/var/tmp/temp5′) or die(“cannot open file temp5″);
open(my $temp6,’>’,'/var/tmp/temp6′) or die(“cannot open file temp6″);
open(my $temp7,’>’,'/var/tmp/temp7′) or die(“cannot open file temp7″);
open(my $temp8,’>’,'/var/tmp/temp8′) or die(“cannot open file temp8″);
my @var_T_2;
my @var_G_2;
my @var_M_2;
my @var_K_2;

foreach(@space_projects3){
if($_ =~ /\s+.*K\s+.*/){
push(@var_K_2,$_);
}
elsif($_ =~ /\s+.*M\s+.*/){
push(@var_M_2,$_);
}
elsif($_ =~ /\s+.*G\s+.*/){
push(@var_G_2,$_);
}
elsif($_ =~ /\s+.*T\s+.*/){
push(@var_T_2,$_);
}
}

select $temp5;
foreach(@var_T_2){
print $_.”\n”;
}
close $temp5;

select $temp6;
foreach(@var_G_2){
print $_.”\n”;
}
close $temp6;
select $temp7;
foreach(@var_M_2){
print $_.”\n”;
}
close $temp7;
select $temp8;
foreach(@var_K_2){
print $_.”\n”;
}
close $temp8;

system(“echo \”\n\n\n======zfs share usage info(Descending)======\”");
system(“sort -r -n -k 2 /var/tmp/temp5;sort -r -n -k 2 /var/tmp/temp6;sort -r -n -k 2 /var/tmp/temp7;sort -r -n -k 2 /var/tmp/temp8″);

The output would be like:

======zfs project usage info(Descending)======
project DC2_DMZ space_total = 7.68T
project dc2_c9testga space_total = 1.10T
project fa_trialadcf space_total = 277G
project fa_rehydration space_total = 266G
project common space_total = 10.0G
project NODE_8 space_total = 93K
project default space_total = 31K

 

======zfs share usage info(Descending)======
Service_Mid-2 1.44T /export/DC2_DMZ/Service_Mid-2
Service_Web 1.22T /export/DC2_DMZ/Service_Web
dc2_shared_idm 743G /export/DC2_DMZ/dc2_shared_idm
Infra_Web 400G /export/DC2_DMZ/Infra_Web
nuviaq_local02 988M /export/DC2_DMZ/nuviaq_local02
sftp_staging 127M /export/DC2_DMZ/sftp_staging
sftp_local03 14.8M /export/DC2_DMZ/sftp_local03
sftp_manager_local01 85K /export/DC2_DMZ/sftp_manager_local01

Categories: Perl Tags: , ,