Thursday, March 10, 2016
Wednesday, February 10, 2016
SmartOS: how to clone a KVM machine
Get the disk0 filesystem of the VM to clone.
vmadm get uuid-originvm | json disks
[
{
"path": "/dev/zvol/rdsk/zones/uuid-originvm-disk0",
"boot": true,
"model": "virtio",
"media": "disk",
"image_size": 10240,
"image_uuid": "d8e65ea2-1f3e-11e5-8557-6b43e0a88b38",
"zfs_filesystem": "zones/uuid-originvm-disk0",
"zpool": "zones",
"size": 10240,
"compression": "off",
"refreservation": 10240,
"block_size": 8192
}
]
Create a json in order to add a disk to the new VM.
vi adddisk.json
vmadm get uuid-originvm | json disks
[
{
"path": "/dev/zvol/rdsk/zones/uuid-originvm-disk0",
"boot": true,
"model": "virtio",
"media": "disk",
"image_size": 10240,
"image_uuid": "d8e65ea2-1f3e-11e5-8557-6b43e0a88b38",
"zfs_filesystem": "zones/uuid-originvm-disk0",
"zpool": "zones",
"size": 10240,
"compression": "off",
"refreservation": 10240,
"block_size": 8192
}
]
Take a snapshot
zfs snapshot zones/uuid-originvm-disk0@toclone
Create a json file in order to create the new VM.
vi targetvm.json
Please note: there are no disks.
{
vi targetvm.json
Please note: there are no disks.
{
"alias": "targetvm",
"hostname": "targetvm",
"dns_domain": "mydomain.it",
"brand": "kvm",
"resolvers": [
"192.168.0.2"
],
"ram": "2048",
"vcpus": "2",
"nics": [
{
"nic_tag": "admin",
"ip": "192.168.0.201",
"netmask": "255.255.255.0",
"gateway": "192.168.0.1",
"model": "virtio",
"primary": true
}
]
}
vmadm create -f targetvm.json
Let's clone the filesystem of the origin VM.
zfs clone zones/uuid-originvm-disk0@toclone zones/uuid-targetvm-disk0
zfs clone zones/uuid-originvm-disk0@toclone zones/uuid-targetvm-disk0
Create a json in order to add a disk to the new VM.
vi adddisk.json
{
"add_disks": [
{
"media": "disk",
"model": "virtio",
"boot": true,
"nocreate": true,
"size": 10240,
"path": "/dev/zvol/rdsk/zones/435ca788-4935-ead3-f4e4-94e6eb7dd4b6-disk0"
}
]
}
Let's add the disk to the newly created VM.
vmadm stop uuid-targetvm -F
vmadm stop uuid-targetvm -F
vmadm update uuid-targetvm -f adddisk.json
This is important.
zfs promote zones/uuid-targetvm-disk0
zfs promote zones/uuid-targetvm-disk0
From man zfs:
zfs promote clone-filesystem
Promotes a clone file system to no longer be dependent on its "ori-
gin" snapshot. This makes it possible to destroy the file system
that the clone was created from. The clone parent-child dependency
relationship is reversed, so that the origin file system becomes a
clone of the specified file system.
The snapshot that was cloned, and any snapshots previous to this
snapshot, are now owned by the promoted clone. The space they use
moves from the origin file system to the promoted clone, so enough
space must be available to accommodate these snapshots. No new
space is consumed by this operation, but the space accounting is
adjusted. The promoted clone must not have any conflicting snapshot
names of its own. The rename subcommand can be used to rename any
conflicting snapshots.
Tuesday, January 19, 2016
mod_jk apache 2.4 smartos zone
If, compiling mod_jk, you get
/usr/bin/bash: ../build/libtool: No such file or directory
Then
cd native/
./configure --with-apxs=/opt/local/bin/apxs
mkdir build
cp libtool build/
make
cp ./apache-2.0/mod_jk.so /opt/local/lib/httpd/
/usr/bin/bash: ../build/libtool: No such file or directory
cd native/
./configure --with-apxs=/opt/local/bin/apxs
mkdir build
cp libtool build/
make
cp ./apache-2.0/mod_jk.so /opt/local/lib/httpd/
Friday, January 15, 2016
tomcat sloooow to start, smartos, kvm: urandom?
A fresh installation of CentOS 7 in a SmartOS KVM virtual machine using a dataset ( image_uuid: d8e65ea2-1f3e-11e5-8557-6b43e0a88b38).
CentOS updated just after the installation.
(like CATALINA_OPTS="$CATALINA_OPTS -Djava.security.egd=file:/dev/./urandom").
CentOS updated just after the installation.
- apache-tomcat-7.0.64
- Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
I noticed that Tomcat, at startup was very very very, help me, very slow to start.
I used strace to look at what was happening (even if I don't understand anything).
I got a lot of
[pid 1279] futex(0x7f5a880a7154, FUTEX_WAIT_BITSET_PRIVATE, 1, {348, 455527976}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
[pid 1279] futex(0x7f5a880a7128, FUTEX_WAKE_PRIVATE, 1) = 0
Just googled around. I found something similar.
So the solution is: to add the following option to java in the tomcat startup script
-Djava.security.egd=file:/dev/urandom
(like CATALINA_OPTS="$CATALINA_OPTS -Djava.security.egd=file:/dev/./urandom").
Who knows?
Wednesday, September 23, 2015
elasticsearch, reindex using logstash
Well, I'm not an elasticsearch expert, not at all. And, as usual, my english sucks.
Let's say that you have indexed a bunch of stuff, and now you need to change an index type.
For instance, in my case, I've seen that a filed named "hostname" was splitted if it was containing a dash, like "tc-pi.pacs.mydomain" was splitted in two parts when creating graphs using kibana.
The solution, in order to avoid this hostname splitting, is to define "index" : "not_analyzed" in logstash mapping.
Well, reading around it is not possible to change mappings once the document were indexed.
So a solution, a workaround, thanks to this post is the following.
"Download" the old index
curl -XGET 'http://127.0.0.1:9200/dcmaudit/_mappings/'
Copy the result in a text editor for your convenience, then change the mapping, like
...
"hostname":{"type":"string", "index" : "not_analyzed"}
...
Create a new index:
curl -XPOST http://localhost:9200/dcmaudit2 -d '{"mappings":{"logs":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"@version":{"type":"string"},"ParticipantObjectIdentification2.ParticipantObjectTypeCode.displayName":{"type":"string", "index" : "not_analyzed"},"hostname":{"type":"string", "index" : "not_analyzed"},"message":{"type":"string"},"tags":{"type":"string"},"timestamp":{"type":"date","format":"dateOptionalTime"}}}}}'
Now let's create a logstash configuration file like this:
input {
# We read from the "old" index
elasticsearch {
hosts => [ "localhost" ]
port => "9200"
index => "dcmaudit"
size => 500
scroll => "5m"
docinfo => true
}
}
filter {
mutate {
remove_field => [ "@timestamp", "@version" ]
}
}
output {
elasticsearch {
host => "localhost"
port => "9200"
protocol => "http"
index => "dcmaudit2"
index_type => "%{[@metadata][_type]}"
document_id => "%{[@metadata][_id]}"
}
stdout {
codec => rubydebug
}
}
Launch logstash
./bin/logstash -f conf.json
Now all the stuff from one index (dcmaudit) will be copied to the new one (dcmaudit2).
At this point you can delete the old index.
curl -XDELETE localhost:9200/dcmaudit
If you want, and if you need it, you can run this task again, recreating the old index name (dcmaudit) but whit the new mapping, and then repeat the logstash task changing the input and the output index accordingly.
Let's say that you have indexed a bunch of stuff, and now you need to change an index type.
For instance, in my case, I've seen that a filed named "hostname" was splitted if it was containing a dash, like "tc-pi.pacs.mydomain" was splitted in two parts when creating graphs using kibana.
The solution, in order to avoid this hostname splitting, is to define "index" : "not_analyzed" in logstash mapping.
Well, reading around it is not possible to change mappings once the document were indexed.
So a solution, a workaround, thanks to this post is the following.
"Download" the old index
curl -XGET 'http://127.0.0.1:9200/dcmaudit/_mappings/'
Copy the result in a text editor for your convenience, then change the mapping, like
...
"hostname":{"type":"string", "index" : "not_analyzed"}
...
Create a new index:
curl -XPOST http://localhost:9200/dcmaudit2 -d '{"mappings":{"logs":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"@version":{"type":"string"},"ParticipantObjectIdentification2.ParticipantObjectTypeCode.displayName":{"type":"string", "index" : "not_analyzed"},"hostname":{"type":"string", "index" : "not_analyzed"},"message":{"type":"string"},"tags":{"type":"string"},"timestamp":{"type":"date","format":"dateOptionalTime"}}}}}'
Now let's create a logstash configuration file like this:
input {
# We read from the "old" index
elasticsearch {
hosts => [ "localhost" ]
port => "9200"
index => "dcmaudit"
size => 500
scroll => "5m"
docinfo => true
}
}
filter {
mutate {
remove_field => [ "@timestamp", "@version" ]
}
}
output {
elasticsearch {
host => "localhost"
port => "9200"
protocol => "http"
index => "dcmaudit2"
index_type => "%{[@metadata][_type]}"
document_id => "%{[@metadata][_id]}"
}
stdout {
codec => rubydebug
}
}
Launch logstash
./bin/logstash -f conf.json
Now all the stuff from one index (dcmaudit) will be copied to the new one (dcmaudit2).
At this point you can delete the old index.
curl -XDELETE localhost:9200/dcmaudit
If you want, and if you need it, you can run this task again, recreating the old index name (dcmaudit) but whit the new mapping, and then repeat the logstash task changing the input and the output index accordingly.
Wednesday, August 26, 2015
Oracle Java, SmartOS Centos 6 LX branded zone: error while loading shared libraries libjli.so
SmartOS 20150820T062742Z
centos-6 lx-dataset image_uuid b1e082f6-460d-11e5-991a-0bc7df451392 (version 20150819)
I don't know if this happens in other versions or linux distributions.
I've installed Java (using the tar.gz archive downloaded from Oracle). Java 6 and Java 7: same issue.
/usr/java/latest/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
centos-6 lx-dataset image_uuid b1e082f6-460d-11e5-991a-0bc7df451392 (version 20150819)
I don't know if this happens in other versions or linux distributions.
I've installed Java (using the tar.gz archive downloaded from Oracle). Java 6 and Java 7: same issue.
/usr/java/latest/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
Weird:
# ldd /usr/java/latest/bin/java
lx_vdso.so.1 => (0x00007fffff0b0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffffee00000)
libjli.so => /usr/java/latest/bin/../lib/amd64/jli/libjli.so (0x00007ffffecf5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ffffea00000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffffe600000)
/lib64/ld-linux-x86-64.so.2 (0x00007fffff200000)
Solution:
Create the file /etc/ld.so.conf.d/java.conf and put the following line in it
/usr/java/latest/lib/amd64/jli/
Then run the /sbin/ldconfig command.
# /usr/java/latest/bin/java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b32)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04, mixed mode)
# ldd /usr/java/latest/bin/java
lx_vdso.so.1 => (0x00007fffff0b0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffffee00000)
libjli.so => /usr/java/latest/bin/../lib/amd64/jli/libjli.so (0x00007ffffecf5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ffffea00000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffffe600000)
/lib64/ld-linux-x86-64.so.2 (0x00007fffff200000)
Thursday, August 20, 2015
How to expand GLPI entity tree sons by default
vi ajax/entitytreesons.php
...
83 $path['state'] = 'open';
...
119 $path['state'] = 'open';
...
83 $path['state'] = 'open';
...
119 $path['state'] = 'open';
...
Subscribe to:
Posts (Atom)