Vrak
Some ops commands reminder.
Put a password on your private key:
$ ssh-keygen -p -f .ssh/id_rsa |
Bash colored prompt (Gentoo style) and history with dates:
# History with date and red prompt
export HISTTIMEFORMAT="%Y/%m/%d - %H:%M:%S "
export PS1='\[\033[01;31m\]\u@\h\[\033[01;34m\] \w #\[\033[00m\] '
Then edit /etc/bash.bashrc with the following (red prompt root and green prompt for normal users):
if [[ ${EUID} == 0 ]] ; then |
MOTD OpenStack (/etc/update-motd.d/92-nova
)
|
MOTD Ceph (/etc/update-motd.d/92-ceph
)
|
Repair FS on boot, same behavior as e2fsck -p
$ sudo sed -i "s/^FSCKFIX=no$/FSCKFIX=yes/" /etc/default/rcS |
e2fsck -p man page:
-p Automatically repair ("preen") the file system. This option will cause e2fsck to automatically fix any filesystem problems that can be safely fixed without human intervention. If e2fsck discovers a problem which may
require the system administrator to take additional corrective action, e2fsck will print a description of the problem and then exit with the value 4 logically or'ed into the exit code. (See the EXIT CODE section.)
This option is normally used by the system's boot scripts. It may not be specified at the same time as the -n or -y options.
Add a VLAN manually:
$ sudo vconfig add blue 3020 |
Make this persistant in /etc/network/interfaces, if you don’t want to put an ip on the device because pacemaker does it for you use the setting below:
auto blue.3020
iface blue.3020 inet static
vlan_raw_device blue
pre-up ifconfig $IFACE up
post-down ifconfig $IFACE down
SMNPD logging:
# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-LS0-5d -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
Delete an IPtable rules based on row number:
$ sudo iptables -L -vnx --line-numbers |
Add a POSTROUTING rule:
$ sudo iptables -I POSTROUTING -t nat -j MASQUERADE -s <ip-range-source> -d <ip-range-dest> -o <nic> |
Quickly check which directory uses most of the space + total:
root@misc01 ~ # du -csh /var/* |
Verifying that a Private Key Matches a Certificate.
Fix a broken MySQL replication (bad transaction):
STOP SLAVE; SET GLOBAL sql_slave_skip_counter = 1; START SLAVE; |
Get a core dump:
$ sudo ulimit -c unlimited |
Show header HTTP with tcpdump
$ tcpdump -s 1024 -l -A src 192.168.9.56 or dst 192.168.9.56 |
Bringing up and down a bond without restart the server, interfaces
conf:
auto eth0
allow-lebond eth0
iface eth0 inet manual
bond-master lebond
auto eth1
allow-lebond eth1
iface eth1 inet manual
bond-master lebond
auto lebond
iface lebond inet manual
bond-slaves none
bond-mode active-backup
bond-miimon 100
Then issue:
$ sudo ifdown eth0 eth1 lebond && sudo ifup eth0 eth1 lebond |
Stupid MySQL error:
Unable to use slave's temporary directory /tmp - Can't create/write to file '/tmp/SQL_LOAD-' (Errcode: 17)
Solved by:
$ sudo rm /tmp/SQL_LOAD- |
Flush MASTER BIN LOGS:
mysql> FLUSH LOGS; |
LVS status:
$ sudo ipvsadm -Ln -t <Public IP>:80 |
ext4 without reservation for root:
$ sudo mkfs.ext4 -m0 |
Online extend an LV:
$ sudo lvextend -L +50G -r /dev/mapper/rootvg-seb |
MySQL must not swap. This can be managed via /proc/sys/vm/swappiness, this value determines how aggressive is the system in term of swapping. Default is 60, for MySQL server 0 is recommended. Setting 0 does not mean that you never swap, the system will only swap to prevent out of memory.
$ sudo sysctl -w vm.swappiness=0 |
Nice output of device structure, filesystem, device mapper:
$ sudo lsblk -f |
Comments