Copy GTP partiotion table between disks

When configuring RAID it’s quite important to have the same partition tables on every disk. I’v done this many times on msdos partition tables like this: sfdisk -d /dev/sda | sfdisk /dev/sdb but it’s not working any more on GPT partition tables. Hopefully it still can be done but with different toolstack 😄 Install gdisk: apt-get install -y gdisk Then use sgdisk like this: sgdisk -R /dev/sd_dest /dev/sd_src sgdisk -G /dev/sd_dest First command will copy partition from /dev/sd_src to /dev/sd_dest....

2014-07-28 · 1 min · timor

Changing default php.ini file for PHP-CLI on CentOS

On Debian in default installation you have different configuration files for PHP in Apache, FPM, CLI, etc. But on CentOS you have only one php.ini for all of them. In case I have, I need to have different configuration file for scripts running in CLI mode (more memory, etc). I could run it like this: php -c /etc/php-cli.ini script.php But this a little burdensome. So I do it like this:...

2014-05-08 · 1 min · timor

Command to change root password

Everybody knows passwd command but it’s useless when you need to change ex. root password from command line without waiting for input. In such case oneliner below could help: echo "root:new_password" | chpasswd

2014-05-08 · 1 min · timor

Rebuild yum/rpm database

When I was trying to update packages on one host I’ve stuck with yum hung on update. I run strace and see: strace -p 43734 Process 43734 attached - interrupt to quit futex(0x807c938, FUTEX_WAIT, 1, NULL <unfinished ...> Process 43734 detached It looks like yum database was corrupted, to repair this run: rm -f /var/lib/rpm/__db* rpm --rebuilddb yum clean all yum update Instead rm on db-files you could use gzip to have backup of these files....

2014-04-04 · 1 min · timor

Nagios - run checks as root with NRPE

I’ve few Nagios checks that require root privileges but running nrpe as root user is not acceptable. I prefer to use sudo for only these few commands. Run visudo and coment out this line: #Defaults requiretty This change is crucial to get scripts working. Then add at the end of file: %nrpe ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/ I’ve used nrpe group, but you have to add exactly group that your nrpe process uses....

2014-03-29 · 1 min · timor

Checking memcached status

I need to check memory usage of memcached server so I used: echo stats | nc 127.0.0.1 11211 STAT pid 2743 STAT uptime 263 STAT time 1395438951 STAT version 1.4.13 STAT pointer_size 64 STAT rusage_user 0.482926 STAT rusage_system 2.675593 STAT curr_items 8667 STAT total_items 10742 STAT bytes 23802513 STAT curr_connections 296 STAT total_connections 399 STAT connection_structures 297 STAT cmd_flush 0 STAT cmd_get 52578 STAT cmd_set 10792 STAT get_hits 28692 STAT get_misses 23886 STAT evictions 0 STAT bytes_read 35984361 STAT bytes_written 192647437 STAT limit_maxbytes 536870912 STAT threads 2 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT replication MASTER STAT repcached_qi_free 8189 STAT repcached_wdata 0 STAT repcached_wsize 1026048 END For me, bytes value was important but you could find more about all statistics here  external link ....

2014-03-21 · 1 min · timor

Postfix - automatically drop outbound mail

I have development server with postfix - I wanted to allow outbound traffic to one domain but cut off all the rest. I definitely do not want that test mail or any debug info goes to service users. I have to add something like that to /etc/postfix/transport: allowed.domain.com : * discard: Then run: postmap /etc/postfix/transport At end, add these to /etc/postfix/main.cf: transport_maps = hash:/etc/postfix/transport Reload postfix: postfix reload Test if it works:...

2014-03-18 · 1 min · timor

Ansible - ssh pipelining

In recent Ansible update to 1.5 version there is really nice feature ssh pipelining. This option is serious alternative to accelerated mode. Just add to you config file (ex. ~/.ansible.cfg): [ssh_connection] pipelining=True Now run any playbook - you will see the difference 😄 Source (and extended info about): http://blog.ansibleworks.com/2014/01/15/ssh-connection-upgrades-coming-in-ansible-1-5/  external link

2014-03-04 · 1 min · timor

Comparing two lists in bash

I had quite simple task - compare two lists of hosts and check if hosts from first one are also on the second one. I started with diff: diff -u biglist.txt hosts_to_check.txt | grep -E "^\+" It was fine but output needs some filtering to get what I want. I’ve found another example with grep: grep -Fxv -f biglist.txt hosts_to_check.txt | sort -n This will search for all lines in hosts_to_check....

2014-02-18 · 1 min · timor

Debian - Upgrade MySQL to MariaDB

After reading some good opinions about MariaDB I wanted to give it a try. Upgrade looks quite straight forward but I found some issues a little tricky. Installation Add repo and key: cat > /etc/apt/sources.list <<SRC deb http://mirrors.supportex.net/mariadb/repo/5.5/debian wheezy main deb-src http://mirrors.supportex.net/mariadb/repo/5.5/debian wheezy main SRC (find more repositories here  external link ) Now install MariaDB: sudo apt-get update sudo apt-get install mariadb-server It could be better to install mariadb-server-5.5 and mariadb-client-5....

2014-01-24 · 1 min · timor