Openstack – new volume

I have managed to create my first server in an openstack enviroment here at university of Bergen.

I can see my instance in the Dashboard:


Next thing was to add a volume:

Project -> Compute -> Volumes: Create Volume

After creating it, I had to go to “Manage Attachments”, and in Manage Volumen Attachments, I selected my “diverse” instance.

I had to use fdisk to format the new volume:

fdisk -l
fdisk /dev/vdb

Hint: m for help, n for new partition, w for write table to disk.

Finally, format and mount:

mkfs.xfs /dev/vdb
mount /dev/vdb /data

[root@diverse lib]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 8.1G 1.9G 81% /
devtmpfs 900M 0 900M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 17M 904M 2% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/1000
/dev/vdb 50G 33M 50G 1% /data


Mysql / Mariadb performance test

I have to different Linux servers, and wanted to test if one where faster than the other. I   used mysqlslap together with the “time” command in a bash shell.

# time mysqlslap –user=root –password=cat /root/mysql –host=localhost concurrency=50 –iterations=100 –number-int-cols=5 –number-char-cols=20 –auto-generate-sql –verbose

In this way I could get out different values from the server which I could compare.

Average number of seconds to run all queries: 0.007 seconds
Minimum number of seconds to run all queries: 0.006 seconds
Maximum number of seconds to run all queries: 0.024 seconds
Number of clients running queries: 1
Average number of queries per client: 0

real 0m9.390s
user 0m0.085s
sys 0m0.165s



How to remove carriage-return character in multiple files

I was trying to move several PHP files from and old REDHAT5 server to new REDHAT7 server. What we saw was that in every file a ^M character was present.

This was ok on the old server, but everything crashed on the new server.

This is how I removed this carriage-return character from every file:

First find all php files:

find . -type f -name '*.php'

then use sed to replace each character:

sed -i 's/\x0d/\n/g'

All put together:

for i in find . -type f -name '*.php' | sed 's/\.\///g'; do echo "sed -i 's/\x0d/\n/g' " $i; done

The command above will print out the necessary commands that you can run directly:

sed -i 's/\x0d/\n/g' finnfeleskrin.php
sed -i 's/\x0d/\n/g' search_oeld.php
sed -i 's/\x0d/\n/g' litt_test.php
sed -i 's/\x0d/\n/g' finnfele.php
sed -i 's/\x0d/\n/g' manager/bibliografi.php
sed -i 's/\x0d/\n/g' manager/list.php
sed -i 's/\x0d/\n/g' manager/linklist.php

or send them to a bash script. For instance:

for i in find . -type f -name '*.php' | sed 's/\.\///g'; do echo "sed -i 's/\x0d/\n/g' " $i; done >; ./