root@hostname.example:/root# megacli -PDList -aALL
Enclosure Device ID: 32
Slot Number: 23
Device Id: 23
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 5
Last Predictive Failure Event Seq Number: 20030
PD Type: SAS
Raw Size: 1.090 TB [0x8bba0cb0 Sectors]
Non Coerced Size: 1.090 TB [0x8baa0cb0 Sectors]
Coerced Size: 1.090 TB [0x8ba80000 Sectors]
Firmware state: Online
SAS Address(0): 0x5000c5006c2a5101
SAS Address(1): 0x0
Connected Port Number: 0(path0)
Inquiry Data: SEAGATE ST1200MM0007 IS04S3L04V8L
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Hard Disk Device
root@hostname.example:/root# /opt/dell/srvadmin/bin/omreport storage pdisk controller=0
root@hostname.example:/root# /opt/dell/srvadmin/bin/omreport storage pdisk vdisk=22 controller=0
List of Physical Disks belonging to disc22
Controller PERC H710P Mini (Embedded)
ID : 0:1:23
Status : Non-Critical
Name : Physical Disk 0:1:23
State : Online
Power Status : Spun Up
Bus Protocol : SAS
Media : HDD
Part of Cache Pool : Not Applicable
Remaining Rated Write Endurance : Not Applicable
Failure Predicted : Yes
Revision : IS04
Driver Version : Not Applicable
Model Number : Not Applicable
T10 PI Capable : No
Certified : Yes
Encryption Capable : No
Encrypted : Not Applicable
Progress : Not Applicable
Mirror Set ID : Not Applicable
Capacity : 1,117.25 GB (1199638052864 bytes)
Used RAID Disk Space : 1,117.25 GB (1199638052864 bytes)
Available RAID Disk Space : 0.00 GB (0 bytes)
Hot Spare : No
Vendor ID : DELL(tm)
Product ID : ST1200MM0007
Serial No. : S3L04V8L
Part Number : CN0RMCP3726223AV00TBA00
Negotiated Speed : 6.00 Gbps
Capable Speed : 6.00 Gbps
PCIe Negotiated Link Width : Not Applicable
PCIe Maximum Link Width : Not Applicable
Sector Size : 512B
Device Write Cache : Not Applicable
Manufacture Day : 06
Manufacture Week : 44
Manufacture Year : 2013
SAS Address : 5000C5006C2A5101
Non-RAID Disk Cache Policy : Not Applicable
Disk Cache Policy : Not Applicable
Form Factor : Not Available
Sub Vendor : Not Available
root@hostname.example:/root# /opt/dell/srvadmin/bin/omreport storage pdisk vdisk=0 controller=0
List of Physical Disks belonging to Virtual Disk 0
Controller PERC H710P Mini (Embedded)
ID : 0:1:0
Status : Ok
Name : Physical Disk 0:1:0
State : Online
Power Status : Spun Up
Bus Protocol : SAS
Media : HDD
Part of Cache Pool : Not Applicable
Remaining Rated Write Endurance : Not Applicable
Failure Predicted : No
Revision : FS64
Driver Version : Not Applicable
Model Number : Not Applicable
T10 PI Capable : No
Certified : Yes
Encryption Capable : No
Encrypted : Not Applicable
Progress : Not Applicable
Mirror Set ID : Not Applicable
Capacity : 278.88 GB (299439751168 bytes)
Used RAID Disk Space : 278.88 GB (299439751168 bytes)
Available RAID Disk Space : 0.00 GB (0 bytes)
Hot Spare : No
Vendor ID : DELL(tm)
Product ID : ST9300603SS
Serial No. : 6SE4AZS3
Part Number : CN0T871K7262216L0777A01
Negotiated Speed : 6.00 Gbps
Capable Speed : 6.00 Gbps
PCIe Negotiated Link Width : Not Applicable
PCIe Maximum Link Width : Not Applicable
Sector Size : 512B
Device Write Cache : Not Applicable
Manufacture Day : 05
Manufacture Week : 25
Manufacture Year : 2011
SAS Address : 5000C5003B728681
Non-RAID Disk Cache Policy : Not Applicable
Disk Cache Policy : Not Applicable
Form Factor : Not Available
Sub Vendor : Not Available
ID : 0:1:1
Status : Ok
Name : Physical Disk 0:1:1
State : Online
Power Status : Spun Up
Bus Protocol : SAS
Media : HDD
Part of Cache Pool : Not Applicable
Remaining Rated Write Endurance : Not Applicable
Failure Predicted : No
Revision : FS64
Driver Version : Not Applicable
Model Number : Not Applicable
T10 PI Capable : No
Certified : Yes
Encryption Capable : No
Encrypted : Not Applicable
Progress : Not Applicable
Mirror Set ID : Not Applicable
Capacity : 278.88 GB (299439751168 bytes)
Used RAID Disk Space : 278.88 GB (299439751168 bytes)
Available RAID Disk Space : 0.00 GB (0 bytes)
Hot Spare : No
Vendor ID : DELL(tm)
Product ID : ST9300603SS
Serial No. : 6SE4DZYJ
Part Number : CN0T871K7262216L0274A01
Negotiated Speed : 6.00 Gbps
Capable Speed : 6.00 Gbps
PCIe Negotiated Link Width : Not Applicable
PCIe Maximum Link Width : Not Applicable
Sector Size : 512B
Device Write Cache : Not Applicable
Manufacture Day : 05
Manufacture Week : 25
Manufacture Year : 2011
SAS Address : 5000C5003B7100B9
Non-RAID Disk Cache Policy : Not Applicable
Disk Cache Policy : Not Applicable
Form Factor : Not Available
Sub Vendor : Not Available
sobota, 9 kwietnia 2016
wtorek, 28 lipca 2015
MongoDB replication with arbiter
One of my projects assumed to have database replication.
I'd used standard replication master-slave until last failure.
My master (PRIMARY) went down and slave (SECONDARY) became master (PRIMARY).
When "old" master went back it'd overtaken master from "new" one.
It was unacceptable for me because I ran everything on new master and it contains new data.
Solution was simple - use an arbiter.
It cost one more machine with mongo but with no data on board.
How to set up
1) Create configuration file on first node (master/PRIMARY) with replica set
root@mongo1:~# cat /etc/mongodb1.conf
dbpath=/var/lib/mongodb1
logpath=/var/log/mongodb/mongodb1.log
logappend=true
bind_ip = mongo1
port = 17017
journal=true
replSet = replication_test
In my case configuration will be almost the same on the other host( except bind_ip and port).
2) Start mongodb on first node.
root@mongo1:# mongod -f /etc/mongodb1.conf &
3) Log into mongo database and initialize replica.
root@mongo1:~# mongo --port 17017
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:17017/test
> rs.config()
null
> rs.status()
{
"startupStatus" : 3,
"info" : "run rs.initiate(...) if not yet done for the set",
"errmsg" : "can't get local.system.replset config from self or any seed (EMPTYCONFIG)",
"ok" : 0
}
> rs.initiate();
{
"info2" : "no configuration explicitly specified -- making one",
"me" : "mongo1:17017",
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:30:34Z"),
"myState" : 2,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"optime" : {
"t" : 1438007418000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:30:18Z"),
"self" : true
}
],
"ok" : 1
}
SECONDARY> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:31:01Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007418000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:30:18Z"),
"self" : true
}
],
"ok" : 1
}
PRIMARY> rs.config()
{
"_id" : "replication_test",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "mongo1:17017"
}
]
}
4) Log into second node and start mongod:
root@mongo2:~# mongod -f /etc/mongodb2.conf &
cat /var/log/mongodb/mongodb2.log
Mon Jul 27 14:32:55 [initandlisten] MongoDB starting : pid=2650 port=27017 dbpath=/var/lib/mongodb2 64-bit host=mongo
Mon Jul 27 14:32:55 [initandlisten]
Mon Jul 27 14:32:55 [initandlisten] ** WARNING: You are running on a NUMA machine.
Mon Jul 27 14:32:55 [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
Mon Jul 27 14:32:55 [initandlisten] ** numactl --interleave=all mongod [other options]
Mon Jul 27 14:32:55 [initandlisten]
Mon Jul 27 14:32:55 [initandlisten] db version v2.0.6, pdfile version 4.5
Mon Jul 27 14:32:55 [initandlisten] git version: nogitversion
Mon Jul 27 14:32:55 [initandlisten] build info: Linux z6 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 BOOST_LIB_VERSION=1_49
Mon Jul 27 14:32:55 [initandlisten] options: { bind_ip: "mongo", config: "/etc/mongodb2.conf", dbpath: "/var/lib/mongodb2", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb2.log", port: 27017, replSet: "replication_test" }
Mon Jul 27 14:32:55 [initandlisten] journal dir=/var/lib/mongodb2/journal
Mon Jul 27 14:32:55 [initandlisten] recover : no journal files present, no recovery needed
Mon Jul 27 14:32:55 [initandlisten] waiting for connections on port 27017
Mon Jul 27 14:32:55 [websvr] admin web console waiting for connections on port 28017
Mon Jul 27 14:32:55 [initandlisten] connection accepted from 10.0.0.3:42241 #1
Mon Jul 27 14:32:55 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Mon Jul 27 14:32:55 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
5) On first node ( PRIMARY) add secondary node:
PRIMARY> rs.add("mongo2:27017")
{ "ok" : 1 }
PRIMARY> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:35:31Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007724000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:35:24Z"),
"self" : true
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 7,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:35:30Z"),
"pingMs" : 21545440,
"errmsg" : "initial sync need a member to be primary or secondary to do our initial sync"
}
],
"ok" : 1
}
PRIMARY> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:36:32Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007724000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:35:24Z"),
"self" : true
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 68,
"optime" : {
"t" : 1438007724000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:35:24Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:36:30Z"),
"pingMs" : 26670
}
],
"ok" : 1
}
6) Run arbiter on the third node and add it to exist infrastructure using PRIMARY node:
root@mongo3:~# mongod -f /etc/mongodb3.conf &
root@mongo1:~# mongo --port 17017
PRIMARY> rs.addArb("mongo3:37017");
{ "ok" : 1 }
PRIMARY> rs.status();
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:39:09Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"self" : true
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 225,
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:39:08Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "mongo3:37017",
"health" : 1,
"state" : 5,
"stateStr" : "STARTUP2",
"uptime" : 12,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:39:07Z"),
"pingMs" : 0
}
],
"ok" : 1
}
PRIMARY> rs.status();
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:39:14Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"self" : true
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 230,
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:39:12Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "mongo3:37017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 17,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:39:13Z"),
"pingMs" : 0
}
],
"ok" : 1
}
PRIMARY> rs.config()
{
"_id" : "replication_test",
"version" : 3,
"members" : [
{
"_id" : 0,
"host" : "mongo1:17017"
},
{
"_id" : 1,
"host" : "mongo2:27017"
},
{
"_id" : 2,
"host" : "mongo3:37017",
"arbiterOnly" : true
}
]
}
Let's see what happen if I kill PRIMARY:
root@mongo2:~# mongo --port 27017
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:27017/test
PRIMARY> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:41:33Z"),
"myState" : 1,
"syncingTo" : "mongo1:17017",
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:41:13Z"),
"pingMs" : 0,
"errmsg" : "socket exception"
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"self" : true
},
{
"_id" : 2,
"name" : "mongo3:37017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 154,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:41:33Z"),
"pingMs" : 0
}
],
"ok" : 1
}
As we assumed SECONDARY becomes PRIMARY.
And if I start old PRIMARY again ?
root@mongo1:~# mongod -f /etc/mongodb1.conf &
Yes, it'll be SECONDARY.
root@mongo2:~# mongo --port 27017
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:27017/test
PRIMARY> rs.status();
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:42:53Z"),
"myState" : 1,
"syncingTo" : "mongo1:17017",
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 6,
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:42:53Z"),
"pingMs" : 0
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"self" : true
},
{
"_id" : 2,
"name" : "mongo3:37017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 234,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:42:53Z"),
"pingMs" : 0
}
],
"ok" : 1
}
Of course I can turn my SECONDARY into PRIMARY using "rs" command:
root@mongo2:~# mongo --port 27017
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:27017/test
PRIMARY> rs.stepDown(120)
Mon Jul 27 14:46:12 DBClientCursor::init call() failed
Mon Jul 27 14:46:12 query failed : admin.$cmd { replSetStepDown: 120.0 } to: 127.0.0.1:27017
Mon Jul 27 14:46:12 Error: error doing query: failed shell/collection.js:151
Mon Jul 27 14:46:12 trying reconnect to 127.0.0.1:27017
Mon Jul 27 14:46:12 reconnect 127.0.0.1:27017 ok
SECONDARY> rs.status()
{
"set" : "replication_test",
"date" : ISODate("2015-07-27T14:46:30Z"),
"myState" : 2,
"syncingTo" : "mongo1:17017",
"members" : [
{
"_id" : 0,
"name" : "mongo1:17017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 15,
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:46:29Z"),
"pingMs" : 0
},
{
"_id" : 1,
"name" : "mongo2:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"optime" : {
"t" : 1438007937000,
"i" : 1
},
"optimeDate" : ISODate("2015-07-27T14:38:57Z"),
"self" : true
},
{
"_id" : 2,
"name" : "mongo3:37017",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 15,
"optime" : {
"t" : 0,
"i" : 0
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2015-07-27T14:46:29Z"),
"pingMs" : 0
}
],
"ok" : 1
}
środa, 6 maja 2015
Packt celebrates International Day Against DRM, May 6th 2015
Packt Publishing firmly believes that you should be able to read and interact with your content when you want, where you want, and how you want – to that end they have been advocates of DRM-free content since their very first eBook was published back in 2004.
This year, to demonstrate their continuing support for Day Against DRM, Packt is offering all its DRM-free content at $10 for 24 hours only on May 6th – with more than 3000 eBooks and 100 Videos available across the publisher’s website www.packtpub.com, there’s plenty to discover, whatever you’re interested in.
“Our top priority at Packt has always been to meet the evolving needs of developers in the most practical way possible, while at the same time protecting the hard work of our authors. DRM-free content continues to be instrumental in making that happen, providing the flexibility and freedom that is essential for an efficient and enhanced learning experience. That’s why we’ve been DRM-free from the beginning – we’ll never put limits on the innovation of our users.”
– Dave Maclean, CEO
Advocates of Day Against DRM are invited to spread the word and celebrate on May 6th by exploring the full range of DRM-free content at www.packtpub.com - all eBooks and Videos will be $10 for 24 hours, including the latest hot titles.
wtorek, 23 grudnia 2014
$5 EBOOK BONANZA – EVERY TITLE, EVERY TOPIC
With all $5 products available in a range of formats and DRM-free, customers will find great value content delivered exactly how they want it across Packt’s website this Christmas and New Year. From Thursday 18th December, every eBook and video will be available on the publisher’s website for just $5 until 6th January.
More info : http://bit.ly/1uW4pQG
czwartek, 7 sierpnia 2014
Apache stats for bots
Last time my server got overload due to heavy queries from bots.
I needed to know which bot is so malicious.
I wrote simple script to parse apache logs to search boot.
#!/usr/bin/perl
use File::Basename;
use Time::Piece;
use Term::ANSIColor qw(:constants);
if (-T $plik){
open(PLIK,"$plik")||die "nie mozna otwoprzyc pliku: $plik!!!\n";
}
elsif(-B $plik){
open(PLIK,"zcat $plik |")||die "nie mozna otwoprzyc pliku: $plik!!!\n";
}
else {
print "Pliku: $plik nie mozna otworzyc\n";
exit;
}
while(defined($log=)){
my ($host,$date,$reqtype,$url,$proto,$status,$size,$referrer,$agent) = $log =~
m/^(\S+) - - \[(\S+ [\-|\+]\d{4})\] "(GET|POST)\s(.+)\sHTTP\/(\d.\d)" (\d{3}) (\d+|-) "(.*?)" "([^"]+)"$/;
if ($status eq "200" && $reqtype eq "GET" && $agent =~ m/bot/i){
my $dt = Time::Piece->strptime($date, '%d/%b/%Y:%H:%M:%S %z');
$date= $dt->strftime('%Y-%m-%d');
$slugnumber{$agent}{$date}{$host}++;
$bot{$agent}++;
}
}
close(PLIK);
foreach $klucz (sort keys %slugnumber){
print "\n================================================\n";
print BOLD,BLUE,"\n $klucz \n",RESET;
foreach $data (keys %{ $slugnumber{$klucz} }){
print BOLD,BLUE,"\n $data \n",RESET;
foreach $ipek (keys %{ $slugnumber{$klucz}{$data} }){
print "$klucz $data [$ipek] : $slugnumber{$klucz}{$data}{$ipek}\n"
}
}
}
Below is output:
testing> perl ipstats.pl /var/log/apache/access.log
================================================
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/)
2014-08-05
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/) 2014-08-05 [125.209.211.199] : 1
2014-08-04
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/) 2014-08-04 [125.209.211.199] : 1
================================================
msnbot/2.0b (+http://search.msn.com/msnbot.htm)
2014-08-05
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.247] : 10
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.243] : 4
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.242] : 2
środa, 25 czerwca 2014
Grep - get first and last line
Last time I had to search my logs for certain message. I needed to connect this with user login/logout time.
I needed estimated time of "start" and "end " occurences in logs ( logs which contains huge messages with different time and same message).
I used sed and grep to this:
root@testing:~# for i in `ls /var/log/syslog/syslog*`;do zgrep 'port 1099' $i | sed -n '1p;$p'; done;
Jun 25 08:18:01 testing sshd[33286]: error: connect_to x.y.z.c port 1099: failed.
Jun 25 11:30:52 testing sshd[45831]: error: connect_to x.y.z.d port 1099: failed.
Jun 24 07:55:04 testing sshd[64527]: error: connect_to x.y.z.d port 1099: failed.
Jun 24 11:53:13 testing sshd[64527]: error: connect_to x.y.z.c port 1099: failed.
Jun 23 08:59:52 testing sshd[34130]: error: connect_to x.y.z.c port 1099: failed.
Jun 23 15:28:38 testing sshd[34130]: error: connect_to x.y.z.d port 1099: failed.
Jun 20 08:24:51 testing sshd[64526]: error: connect_to x.y.z.c port 1099: failed.
Jun 20 10:55:46 testing sshd[7805]: error: connect_to x.y.z.c port 1099: failed.
poniedziałek, 16 czerwca 2014
czwartek, 12 czerwca 2014
Check SSL expiration date
Recently I needed to check out my domains due to SSL expiration date.
I used script below - it frees up time.
How does it work ?
I need file which contains domeins in form : address:port
In loop I check every domain with parameter "-enddate" (certificate expiration date) using openssl.
I change dates to timestamp and subtract expiration date from date "now+30days".
If result timestamp is lower than daystimestamp (which is number of days in seconds) it warnings me that certificate will expire soon.
shamrock@alucard:~$ cat check_ssl_expiration.sh
days=30
daystimestamp=`expr $days \* 86400`
for domain in `cat domeny.txt`
do
expire=`echo | openssl s_client -connect $domain 2>/dev/null | openssl x509 -noout -enddate | awk -F \= '{print $2}'`
out=`date -d "$expire" "+%s"`
in=`date --date="$days days" "+%s"`
res=`expr $out - $in`
if [ $res -lt 0 ]; then
echo "ALARM !!! DOMAIN $domain EXPIRED ON $expire"
elif [ $res -lt $daystimestamp ]; then
echo "ALARM !!! DOMAIN $domain WILL EXPIRE ON $expire"
else
echo "$domain WILL EXPIRE ON $expire"
fi
done
Usage:
shamrock@alucard:~$ bash check_ssl_expiration.sh
poczta.onet.pl:443 WILL EXPIRE ON Oct 14 06:10:33 2014 GMT
ALARM !!! DOMAIN some.kind.of.mons.tr:443 EXPIRE ON Jul 3 13:19:18 2013 GMT
File contains domains:
shamrock@alucard:~$ cat domeny.txt
poczta.onet.pl:443
some.kind.of.mons.tr:443
Etykiety:
bash,
expiration date,
openssl,
openssl verify,
script,
ssl,
validation ssl certificate
poniedziałek, 5 maja 2014
wtorek, 22 kwietnia 2014
SSL certificate: DER, PEM and error 20
I had an SSL certificate in a https server, but whenever I connected to this my site, I saw certificate error.
First I check that my certificate is in DER form which is not accepted by my server.
I have to convert it to PEM :
root@prod:~/cert# openssl x509 -in my_cert.cer -out my_cert.pem -inform DER -outform PEM
Than I saw that I have stil problems with certificate
root@prod:~/cert# openssl verify my_cert.pem: [details removed]
error 20 at 0 depth lookup:unable to get local issuer certificate
I googled and found that I should get issuer certificate and combine it with my certificate.
I downloaded issuer certificate in DER format and converted it to PEM.
root@prod:~/cert# openssl x509 -in l4.cer -out l4.pem -inform DER -outform PEM
Than I checked if everything is OK:
root@prod:~/cert# openssl verify -CAfile l4.pem my_cert.pem: OK
Final step was combined my_cert.pem with l4.pem :
root@prod:~/cert# cat my_cert.pem l4.pem >> my_cert.crt
I copied my_cert.crt and my_cert.key to /etc/ssl/ and configured my nginx to use it.
No more certificate error.
Etykiety:
CAfile,
certificate error,
convert der to pem,
der,
issuer certificate,
openssl,
openssl verify,
pem,
ssl,
verify
piątek, 11 kwietnia 2014
Solr configure logging to file
First download solr and commons-logging:
root@testing:# wget http://ftp.ps.pl/pub/apache/lucene/solr/4.7.1/solr-4.7.1.tgz
root@testing:# wget http://ftp.piotrkosoft.net/pub/mirrors/ftp.apache.org//commons/logging/binaries/commons-logging-1.1.3-bin.tar.gz
Unpack both.
root@testing:# tar -zxf solr-4.7.1.tgz
root@testing:# tar -zxf commons-logging-1.1.3-bin.tar.gz
Copy solr-4.7.1.war to temp directory i.e:
root@testing:# mkdir tmp
root@testing:# cd tmp
root@testing:tmp# cp ../solr-4.7.1/dist/solr-4.7.1.war .
Unpack solr*.war
root@testing:tmp# jar -xf solr-4.7.1.war
Copy from solr-4.7.1 log4j*.jar and slf4j*.jar to WEB-INF/lib/
root@testing:tmp# cp ../solr-4.7.1/example/lib/ext/{log4j-1.2.16.jar,slf4j*} WEB-INF/lib/
Copy from commons-logging commons-logging*.jar :
root@testing:tmp# cp ../commons-logging-1.1.3/commons-logging-1.1.3.jar WEB-INF/lib/
Create directory classess in WEB-INF/
root@testing:tmp# mkdir WEB-INF/classes
Copy from solr*/example/resources/ log4j.properties to WEB-INF/classes
root@testing:tmp# cp ../solr-4.7.1/example/resources/log4j.properties WEB-INF/classes/
root@testing:tmp# cat WEB-INF/classes/log4j.properties
# Logging level
solr.log=/var/log/solr
log4j.rootLogger=INFO, file, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x \u2013 %m%n
#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9
#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n
log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN
# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF
Create log directory which configured in log4j.properties and change owner to user which running tomcat
root@testing:tmp# mkdir /var/log/solr
root@testing:tmp# chown tomcat7:tomcat7 /var/log/solr
Pack everything back to solr*.war
root@testing:tmp# jar -cf solr-4.7.1.war META-INF WEB-INF admin.html css favicon.ico img js tpl
If everything is OK you should enjoy logs in log directory:
root@testing:tmp# cat /var/log/solr/solr.log
INFO - 2014-04-11 12:23:58.890; org.apache.solr.servlet.SolrDispatchFilter; SolrDispatchFilter.init()
INFO - 2014-04-11 12:23:58.916; org.apache.solr.core.SolrResourceLoader; Using JNDI solr.home: /srv/solr
INFO - 2014-04-11 12:23:58.919; org.apache.solr.core.SolrResourceLoader; new SolrResourceLoader for directory: '/srv/solr/'
INFO - 2014-04-11 12:23:59.145; org.apache.solr.core.ConfigSolr; Loading container configuration from /srv/solr/solr.xml
INFO - 2014-04-11 12:23:59.358; org.apache.solr.core.CorePropertiesLocator; Config-defined core root directory: /srv/solr
INFO - 2014-04-11 12:23:59.372; org.apache.solr.core.CoreContainer; New CoreContainer 1409622974
INFO - 2014-04-11 12:23:59.372; org.apache.solr.core.CoreContainer; Loading cores into CoreContainer [instanceDir=/srv/solr/]
INFO - 2014-04-11 12:23:59.398; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting socketTimeout to: 0
INFO - 2014-04-11 12:23:59.398; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting urlScheme to: null
INFO - 2014-04-11 12:23:59.406; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting connTimeout to: 0
INFO - 2014-04-11 12:23:59.406; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting maxConnectionsPerHost to: 20
INFO - 2014-04-11 12:23:59.406; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting corePoolSize to: 0
INFO - 2014-04-11 12:23:59.407; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting maximumPoolSize to: 2147483647
INFO - 2014-04-11 12:23:59.407; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting maxThreadIdleTime to: 5
INFO - 2014-04-11 12:23:59.407; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting sizeOfQueue to: -1
INFO - 2014-04-11 12:23:59.407; org.apache.solr.handler.component.HttpShardHandlerFactory; Setting fairnessPolicy to: false
INFO - 2014-04-11 12:23:59.588; org.apache.solr.logging.LogWatcher; SLF4J impl is org.slf4j.impl.Log4jLoggerFactory
INFO - 2014-04-11 12:23:59.589; org.apache.solr.logging.LogWatcher; Registering Log Listener [Log4j (org.slf4j.impl.Log4jLoggerFactory)]
INFO - 2014-04-11 12:23:59.591; org.apache.solr.core.CoreContainer; Host Name:
INFO - 2014-04-11 12:23:59.677; org.apache.solr.core.CorePropertiesLocator; Looking for core definitions underneath /srv/solr
INFO - 2014-04-11 12:23:59.678; org.apache.solr.core.CorePropertiesLocator; Found 0 core definitions
INFO - 2014-04-11 12:23:59.680; org.apache.solr.servlet.SolrDispatchFilter; user.dir=/var/lib/tomcat7
INFO - 2014-04-11 12:23:59.680; org.apache.solr.servlet.SolrDispatchFilter; SolrDispatchFilter.init() done
INFO - 2014-04-11 12:24:15.866; org.apache.solr.servlet.SolrDispatchFilter; [admin] webapp=null path=/admin/cores params={indexInfo=false&_=1397211686406&wt=json} status=0 QTime=69
INFO - 2014-04-11 12:24:15.941; org.apache.solr.servlet.SolrDispatchFilter; [admin] webapp=null path=/admin/info/system params={_=1397211686554&wt=json} status=0 QTime=16
INFO - 2014-04-11 12:24:20.785; org.apache.solr.servlet.SolrDispatchFilter; [admin] webapp=null path=/admin/info/logging params={_=1397211691410&since=0&wt=json} status=0 QTime=2
INFO - 2014-04-11 12:24:22.578; org.apache.solr.servlet.SolrDispatchFilter; [admin] webapp=null path=/admin/cores params={_=1397211693200&wt=json} status=0 QTime=0
INFO - 2014-04-11 12:24:24.230; org.apache.solr.servlet.SolrDispatchFilter; [admin] webapp=null path=/admin/info/properties params={_=1397211694858&wt=json} status=0 QTime=1
piątek, 21 marca 2014
Packt’s amazing Buy One, Get One Free
Check out #Packt’s amazing Buy One, Get One Free offer #Packt2k
piątek, 17 stycznia 2014
Secure web directory with exclude
Last time I needed to secure on of my websites.
I set password, used htaccess and ...I got error on my main page.
The reason was simple - main page invoked to file in my secure directory.
I needed to exclude this file from my secure directory.
Below is solution.
# password protection allowing multiple resources
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null
Require valid-user
# allow public access to the following resources
SetEnvIf Request_URI "(path/to/directory_01/)$" allow
SetEnvIf Request_URI "(path/to/directory_02/)$" allow
SetEnvIf Request_URI "(path/to/file\.php)$" allow
SetEnvIf Request_URI "(path/to/file\.html)$" allow
SetEnvIf Request_URI "(path/to/another/resource/)$" allow
SetEnvIf Request_URI "(path/to/yet/another/resource/)$" allow
Order allow,deny
Allow from env=allow
Satisfy any
Of course you can also use "Allow from " to limiting access to secure directory.
niedziela, 29 grudnia 2013
środa, 20 listopada 2013
mdadm "lost" discs
A few days ago I had to stop my systems.
One of them had different kind of storage like: luns, nfs and software raids.
After turned on system I realized that I had had no software raid.
I checked if everything was connected and checked if discs exists.
mdadm --examine /dev/sd[b-t]
/dev/sdc:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : da8f3a5d:10f75bee:f074ba7e:f0494c09
Update Time : Tue Dec 11 13:59:58 2012
Checksum : d24bdccc - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 7
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdd:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : c4d19ddc:f5dc1884:c6ef0844:3abe1c66
Update Time : Tue Dec 11 13:59:58 2012
Checksum : 98af3bd - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 8
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sde:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 51e205a2:40aa348f:3f2041a9:872d3e1f
Update Time : Tue Dec 11 13:59:58 2012
Checksum : f868715b - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 9
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdf:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 1832c689:2cb35bfc:d2c97cf5:d84c985d
Update Time : Tue Dec 11 13:59:58 2012
Checksum : d7e592ea - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 0
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdg:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 5a9a6781:53904dfc:0f5789c9:e0df60e8
Update Time : Tue Dec 11 13:59:58 2012
Checksum : 2e4df89a - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 1
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdh:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : afa5008b:efc248ab:5ab3bce0:2def6ad1
Update Time : Tue Dec 11 13:59:58 2012
Checksum : e71fa223 - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 2
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdi:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : c8e16d74:a1940d4c:5a802c6a:5173a94c
Update Time : Tue Dec 11 13:59:58 2012
Checksum : 76000112 - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 3
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdj:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 53051171:604d9634:a7f5c2b6:14c2bddd
Update Time : Tue Dec 11 13:59:58 2012
Checksum : 38d6a16e - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 4
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdk:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : fc3706df:d1f2df92:f50a37a7:55fd1845
Update Time : Tue Dec 11 13:59:58 2012
Checksum : 5ce4ca18 - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 5
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
/dev/sdl:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 2632f0c3:b113d4e9:056228c1:d30a6ab0
Name : synat2:0 (local to host synat2)
Creation Time : Tue Dec 11 13:59:58 2012
Raid Level : raid0
Raid Devices : 10
Avail Dev Size : 47997696 (22.89 GiB 24.57 GB)
Data Offset : 2048 sectors
Super Offset : 8 sectors
State : clean
Device UUID : 6ae2fd1e:30297e6c:4a26a015:2edcfe2c
Update Time : Tue Dec 11 13:59:58 2012
Checksum : ccc9a512 - correct
Events : 0
Chunk Size : 512K
Device Role : Active device 6
Array State : AAAAAAAAAA ('A' == active, '.' == missing)
Than I realized that in my mdadm.conf were entries with /dev/dm-*.
It means that something was wrong because in /dev I had only 4 entries contained dm*.
It turned out that my multipath configuration blocked other dm-* devices to be discovered.
I switched dm to disk/by-id.
root@testing:~# cat /etc/mdadm/mdadm.conf | grep -v ^#
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST
MAILADDR root
DEVICE /dev/disk/by-id/scsi-SATA_MARVELL_*
Did:
root@testing:~# mdadm --assemble --scan
and
root@testing:~# mount -a
Now everything works as it should.
wtorek, 29 października 2013
FreeBSD access via Xen console
To allow access via xen console you need to change /etc/ttys:
-ttyu0 /usr/libexec/getty std.9600 dialup off secure +ttyu0 /usr/libexec/getty std.9600 dialup on secure
Than add few lines into /boot/loader.conf :
boot_multicons="YES" boot_serial="YES" comconsole_speed=9600 console="comconsole,vidconsole"
Now you can restart server.
Now you can access to FreeBSD console via xen:
[root@xenserver1 ~]# xl console "FreeBSD 9.2" FreeBSD/amd64 (tanatos) (ttyu0) login:
piątek, 25 października 2013
Xen add new virtual disc
Once I need to attach new disk on my VM machine.
To do this I need make steps below :
2) Create virtual disc:
3) Check virtual machine UUID for whom virtual disc should be attched:
In my case it was FreeBSD 9.2 (uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b)
5) Create virtual disc attached to VM:
6) Optionally if you have Xen tools on board you can plug virtual disc live.
If everything goes right you should have new discs attached and working on virtual machine.
On system:
On Xen:
1) Get storage UUID:
[root@xenserver1 ~]# xe sr-list
uuid ( RO) : 4e98e18e-1215-4fdb-baec-924bbef2a67e
name-label ( RW): Remote ISO Library on: /mnt/iso_import
name-description ( RW):
host ( RO): xenserver1
type ( RO): iso
content-type ( RO): iso
uuid ( RO) : f30a1ead-37f2-0e3c-9583-073c176fc111
name-label ( RW): Removable storage
name-description ( RW):
host ( RO): xenserver1
type ( RO): udev
content-type ( RO): disk
uuid ( RO) : 419c98d3-1d98-3049-c579-439c31b33fd4
name-label ( RW): XenServer Tools
name-description ( RW): XenServer Tools ISOs
host ( RO): xenserver1
type ( RO): iso
content-type ( RO): iso
uuid ( RO) : a9329bfa-e13e-2edd-8414-5920f03f27e5
name-label ( RW): ISOS
name-description ( RW):
host ( RO): xenserver1
type ( RO): iso
content-type ( RO): iso
uuid ( RO) : cb128245-3dcb-9de6-319d-681cede9553f
name-label ( RW): DVD drives
name-description ( RW): Physical DVD drives
host ( RO): xenserver1
type ( RO): udev
content-type ( RO): iso
uuid ( RO) : f6375e1e-0ab7-b11c-e9dd-677da4436e15
name-label ( RW): Local storage
name-description ( RW):
host ( RO): xenserver1
type ( RO): lvm
content-type ( RO): user
[root@xenserver1 ~]# xe vdi-create name-label="zfs1" sr-uuid=f6375e1e-0ab7-b11c-e9dd-677da4436e15 type=user sm-config:type=raw virtual-size=10GiB
34a899b3-b3dd-4531-aee9-1fafb57517ca
[root@xenserver1 ~]# xe vdi-create name-label="zfs2" sr-uuid=f6375e1e-0ab7-b11c-e9dd-677da4436e15 type=user sm-config:type=raw virtual-size=10GiB
20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
[root@xenserver1 ~]# xe vdi-list name-label=zfs1
uuid ( RO) : 34a899b3-b3dd-4531-aee9-1fafb57517ca
name-label ( RW): zfs1
name-description ( RW):
sr-uuid ( RO): f6375e1e-0ab7-b11c-e9dd-677da4436e15
virtual-size ( RO): 10737418240
sharable ( RO): false
read-only ( RO): false
[root@xenserver1 ~]# xe vdi-list name-label=zfs2
uuid ( RO) : 20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
name-label ( RW): zfs2
name-description ( RW):
sr-uuid ( RO): f6375e1e-0ab7-b11c-e9dd-677da4436e15
virtual-size ( RO): 10737418240
sharable ( RO): false
read-only ( RO): false
[root@xenserver1 ~]# xe vm-list
uuid ( RO) : 68ce65a4-01ec-4a23-9016-011aa20e59cf
name-label ( RW): Control domain on host: xenserver1
power-state ( RO): running
uuid ( RO) : 66a6fcc2-b5b9-1eb9-cd26-c26d8df1e204
name-label ( RW): Hadoop-master
power-state ( RO): running
uuid ( RO) : a79bc6f8-54d7-a562-ba14-4f50db2efc9b
name-label ( RW): FreeBSD 9.2
power-state ( RO): running
uuid ( RO) : 8ac1c052-8448-6d9b-0a55-6e91e5be406c
name-label ( RW): FreeBSD10
power-state ( RO): halted
uuid ( RO) : 03070e1e-2b04-5e4b-87f9-5db7d69131bb
name-label ( RW): Hadoop-slave2
power-state ( RO): running
uuid ( RO) : d122b3bf-e914-83b0-5761-1430f205fa9c
name-label ( RW): Hadoop-slave1
power-state ( RO): running
4) Get allowed numbers for VBD devices:
[root@xenserver1 ~]# xe vm-param-get uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b param-name=allowed-VBD-devices 1; 2
[root@xenserver1 ~]# xe vbd-create device=1 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b vdi-uuid=34a899b3-b3dd-4531-aee9-1fafb57517ca bootable=false mode=RW type=Disk f43711c3-be1e-a869-8888-408d94a70656 [root@xenserver1 ~]# xe vbd-create device=2 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b vdi-uuid=20c384f6-0504-4c7f-a3cf-08d28c6c0dc6 bootable=false mode=RW type=Disk 5dcf7ad9-f4ec-b3e3-ea0c-8edd0d35d53d
[root@xenserver1 ~]# xe vbd-plug uuid=f43711c3-be1e-a869-8888-408d94a70656
shamrock@tanatos:~ % dmesg | grep xbd xbd0: 30720MBat device/vbd/768 on xenbusb_front0 xbd0: attaching as ada0 xbd1: 10240MB at device/vbd/5632 on xenbusb_front0 xbd1: attaching as ada2 xbd2: 10240MB at device/vbd/832 on xenbusb_front0 xbd2: attaching as ada1
[root@xenserver1 ~]# xe vbd-list vm-name-label=FreeBSD\ 9.2
uuid ( RO) : 5dcf7ad9-f4ec-b3e3-ea0c-8edd0d35d53d
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
vm-name-label ( RO): FreeBSD 9.2
vdi-uuid ( RO): 20c384f6-0504-4c7f-a3cf-08d28c6c0dc6
empty ( RO): false
device ( RO): hdc
uuid ( RO) : f43711c3-be1e-a869-8888-408d94a70656
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
vm-name-label ( RO): FreeBSD 9.2
vdi-uuid ( RO): 34a899b3-b3dd-4531-aee9-1fafb57517ca
empty ( RO): false
device ( RO): hdb
uuid ( RO) : 17d014d8-0d28-76e9-b6dc-f8944a0c0244
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
vm-name-label ( RO): FreeBSD 9.2
vdi-uuid ( RO): a74f372f-2fcd-4121-a241-bd1e960a069c
empty ( RO): false
device ( RO): hda
środa, 23 października 2013
Create local ISO repository
Create with lvcreate place for repository:
Make proper file system:
Add lines to /ec/rc.local
Result:
[root@xenserver1 ~]# lvcreate -L 30G -n ISO2 VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15
[root@xenserver1 ~]# mkfs.ext3 /dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2
[root@xenserver1 ~]# vi /etc/rc.local
ISO=/dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2
lvchange -ay $ISO
mount $ISO /mnt/iso_import
It's very important not to change /etc/fstab !!!
Last thing is to mount everything without restart:
[root@xenserver1 ~]# ISO=/dev/VG_XenStorage-f6375e1e-0ab7-b11c-e9dd-677da4436e15/ISO2 [root@xenserver1 ~]# lvchange -ay $ISO [root@xenserver1 ~]# mount $ISO /mnt/iso_import [root@xenserver1 ~]# xe-mount-iso-sr /mnt/iso_import -o bind
[root@xenserver1 ~]# xe sr-list
uuid ( RO) : 4e98e18e-1215-4fdb-baec-924bbef2a67e
name-label ( RW): Remote ISO Library on: /mnt/iso_import
name-description ( RW):
host ( RO): xenserver1
type ( RO): iso
content-type ( RO): iso
uuid ( RO) : f30a1ead-37f2-0e3c-9583-073c176fc111
name-label ( RW): Removable storage
name-description ( RW):
host ( RO): xenserver1
type ( RO): udev
content-type ( RO): disk
uuid ( RO) : 419c98d3-1d98-3049-c579-439c31b33fd4
name-label ( RW): XenServer Tools
name-description ( RW): XenServer Tools ISOs
host ( RO): xenserver1
type ( RO): iso
content-type ( RO): iso
uuid ( RO) : cb128245-3dcb-9de6-319d-681cede9553f
name-label ( RW): DVD drives
name-description ( RW): Physical DVD drives
host ( RO): xenserver1
type ( RO): udev
content-type ( RO): iso
uuid ( RO) : f6375e1e-0ab7-b11c-e9dd-677da4436e15
name-label ( RW): Local storage
name-description ( RW):
host ( RO): xenserver1
type ( RO): lvm
content-type ( RO): user
How to add network interface to VM on Citrix Xen via console
Check interfaces:
Create internal interface - not bounded to any physical interface :
Create tagged network interface bounded to physical NIC:
Example pif-list after adding new interface
Check VM to attach new interface:
we need to know number of devices and vm-uuid.
Attach interface to VM:
Result:
Depends of configuration probably you'll need to shutdown your machine and start it again thus system could determine network interface.
[root@xenserver1 ~]# xe pif-list
uuid ( RO) : cc9937fa-0435-7664-a73a-c9bfa803e50e
device ( RO): eth3
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): e7a75876-ee65-950e-7975-6751eca3795b
uuid ( RO) : 3a5ef383-650a-ded9-d636-4c86a6831443
device ( RO): eth1
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): bd91ea1e-6184-4f7b-6360-0134f39b9751
uuid ( RO) : 4c04ef06-9707-67ac-1859-6e6617d507a7
device ( RO): eth2
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 8d829397-e8d1-fdc2-b62d-8b23cf6da7dd
uuid ( RO) : 41b55f45-91ff-90e1-0a13-dbb680e744e9
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 78613a9f-aede-edc6-39f4-40c4c5883de2
uuid ( RO) : 72ff5545-3d4b-5038-aa15-dc93998b8dab
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): 21
network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
[root@xenserver1 ~]# xe network-create name-label="anylan" name-description="anylan for testing" 919b5b1c-201f-fed2-c39d-21946f278bdc
[root@xenserver1 ~]# xe network-create name-label="vlan402" name-description="VLAN 402" d5b6969c-eff4-79b2-0088-7740f8a9b492 [root@xenserver1 ~]# xe vlan-create network-uuid=d5b6969c-eff4-79b2-0088-7740f8a9b492 pif-uuid=41b55f45-91ff-90e1-0a13-dbb680e744e9 vlan=402 7dadd3ec-b8a2-5b40-0855-0ef365dc9f00
[root@xenserver1 ~]# xe pif-list
uuid ( RO) : 7dadd3ec-b8a2-5b40-0855-0ef365dc9f00
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): 402
network-uuid ( RO): d5b6969c-eff4-79b2-0088-7740f8a9b492
uuid ( RO) : cc9937fa-0435-7664-a73a-c9bfa803e50e
device ( RO): eth3
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): e7a75876-ee65-950e-7975-6751eca3795b
uuid ( RO) : 3a5ef383-650a-ded9-d636-4c86a6831443
device ( RO): eth1
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): bd91ea1e-6184-4f7b-6360-0134f39b9751
uuid ( RO) : 4c04ef06-9707-67ac-1859-6e6617d507a7
device ( RO): eth2
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 8d829397-e8d1-fdc2-b62d-8b23cf6da7dd
uuid ( RO) : 41b55f45-91ff-90e1-0a13-dbb680e744e9
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 78613a9f-aede-edc6-39f4-40c4c5883de2
uuid ( RO) : 72ff5545-3d4b-5038-aa15-dc93998b8dab
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): 21
network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
[root@xenserver1 ~]# xe vm-list
uuid ( RO) : 68ce65a4-01ec-4a23-9016-011aa20e59cf
name-label ( RW): Control domain on host: xenserver1
power-state ( RO): running
uuid ( RO) : 66a6fcc2-b5b9-1eb9-cd26-c26d8df1e204
name-label ( RW): Hadoop-master
power-state ( RO): running
uuid ( RO) : a79bc6f8-54d7-a562-ba14-4f50db2efc9b
name-label ( RW): FreeBSD 9.2
power-state ( RO): running
uuid ( RO) : 8ac1c052-8448-6d9b-0a55-6e91e5be406c
name-label ( RW): FreeBSD10
power-state ( RO): halted
uuid ( RO) : 03070e1e-2b04-5e4b-87f9-5db7d69131bb
name-label ( RW): Hadoop-slave2
power-state ( RO): running
uuid ( RO) : d122b3bf-e914-83b0-5761-1430f205fa9c
name-label ( RW): Hadoop-slave1
power-state ( RO): running
[root@xenserver1 ~]# xe vif-list vm-name-label=FreeBSD\ 9.2
uuid ( RO) : 49a107e2-0e81-a9dd-0595-218c07fe1af8
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 2
network-uuid ( RO): 56d7fd62-ba47-c12c-e371-bc7908739ad1
uuid ( RO) : 03932dbf-d7e4-ed7d-d649-ac431a97d962
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 1
network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
[root@xenserver1 ~]# xe vif-create network-uuid=d5b6969c-eff4-79b2-0088-7740f8a9b492 vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b device=3 mac=random 758cf24a-2904-f3aa-8ed4-17d6ffebf032 [root@xenserver1 ~]# xe vif-create network-uuid=919b5b1c-201f-fed2-c39d-21946f278bdc vm-uuid=a79bc6f8-54d7-a562-ba14-4f50db2efc9b device=4 mac=random 3504d19f-2413-e066-6d30-1878adfbd117
[root@xenserver1 ~]# xe vif-list vm-name-label=FreeBSD\ 9.2
uuid ( RO) : 49a107e2-0e81-a9dd-0595-218c07fe1af8
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 2
network-uuid ( RO): 56d7fd62-ba47-c12c-e371-bc7908739ad1
uuid ( RO) : 758cf24a-2904-f3aa-8ed4-17d6ffebf032
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 3
network-uuid ( RO): d5b6969c-eff4-79b2-0088-7740f8a9b492
uuid ( RO) : 03932dbf-d7e4-ed7d-d649-ac431a97d962
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 1
network-uuid ( RO): 8310ea88-dad4-c989-19db-5c5fdb8d3edc
uuid ( RO) : 3504d19f-2413-e066-6d30-1878adfbd117
vm-uuid ( RO): a79bc6f8-54d7-a562-ba14-4f50db2efc9b
device ( RO): 4
network-uuid ( RO): 919b5b1c-201f-fed2-c39d-21946f278bdc
Etykiety:
citrix,
cli,
command line,
virtual interface,
vlan,
vm,
xen
wtorek, 22 października 2013
FreeBSD 9.2 XEN xenbusb_nop_confighook_cb
Recently I tried run FreeBSD 9.2 on my Citrix Xen machine with HVM support.
After booting I got error:
xenbusb_nop_confighook_cb
This error got me confused. I'd searched awhile and found solution :
http://web.archiveorange.com/archive/v/jbzpKsnhTPhFFEuQuYTP
root@pruebas:/root # diff -u /usr/src/sys/kern/subr_autoconf.c-defecto /usr/src/sys/kern/subr_autoconf.c
--- /usr/src/sys/kern/subr_autoconf.c-defecto 2012-10-10 13:51:27.000000000 +0200
+++ /usr/src/sys/kern/subr_autoconf.c 2012-10-10 18:21:51.000000000 +0200
@@ -133,16 +133,17 @@
/* Block boot processing until all hooks are disestablished. */
mtx_lock(&intr_config_hook_lock);
warned = 0;
- while (!TAILQ_EMPTY(&intr_config_hook_list)) {
+ /* while (!TAILQ_EMPTY(&intr_config_hook_list)) { */
if (msleep(&intr_config_hook_list, &intr_config_hook_lock,
0, "conifhk", WARNING_INTERVAL_SECS * hz) ==
EWOULDBLOCK) {
+ printf("\n\n SARENET Individual lock name antes de unlock es : %s", intr_config_hook_lock.lock_object.lo_name);
mtx_unlock(&intr_config_hook_lock);
warned++;
run_interrupt_driven_config_hooks_warning(warned);
mtx_lock(&intr_config_hook_lock);
}
- }
+ /* } */
mtx_unlock(&intr_config_hook_lock);
}TAILQ_EMPTY is at queue.h :
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
Etykiety:
citrix,
freebsd 9.2,
vm,
xen,
xenbusb_nop_confighook_cb
Subskrybuj:
Posty (Atom)



