Skip to content

Instantly share code, notes, and snippets.

View makeittotop's full-sized avatar

abhishek pareek makeittotop

  • Canada
  • 23:54 (UTC -07:00)
View GitHub Profile
@makeittotop
makeittotop / gist:f14002677bc7a08b9fdc32d564988737
Created August 10, 2016 10:45
strace pipe stderr into grep
[root@foo block]# strace -f -s2048 -eopen fdisk -l |& grep /sys/dev/block/
open("/sys/dev/block/8:0", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/8:0", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:0", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:0", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:1", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:1", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:2", O_RDONLY|O_CLOEXEC) = 5
open("/sys/dev/block/253:2", O_RDONLY|O_CLOEXEC) = 5
@makeittotop
makeittotop / gist:ca86148d8c0a7009310a11cca39c520d
Created August 10, 2016 10:19
overview of /proc, /sys and /dev - lynda
- Surveying the Linux Kernel, let's look more at /proc, /sys, and device files. Virtual Filesystems that we talked about proc and sysfs that means these virtual filesystems don't store their contents on a disk, more accurately they generate their contents when you ask for it. When you cat a file in proc or sys, there's some corresponding function in the kernel that's called to generate the contents. These are not RAM-based filesystems. RAM filesystems store their contents in RAM.
Virtual filesystems generate their contents when you ask for it, like callback functions. proc got its name from process, and the proc filesystem is normally mounted on /proc. That's done early on in the boot process. proc contains lots of process information, as can be expected, plus lots, lots more. This essentially is information about the state of the kernel. A lot of utilities get information about the kernel from the proc directory.
The ps command, process status, gets its information from the proc directory. A real important
@makeittotop
makeittotop / gist:e0ffa25ff368ae4a5577b7a9020a03dc
Last active August 10, 2016 11:24
dmesg print boot command line info
[root@foo block]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-327.4.4.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8
[root@foo block]# cat /proc/partitions
major minor #blocks name
11 0 1048575 sr0
8 0 976762584 sda
8 1 2097152 sda1
8 2 973832192 sda2
@makeittotop
makeittotop / gist:d83f53c5354f0e12fdc3cc394af9d1c5
Created August 9, 2016 08:41
dnf update fails with epel-release
The issue may have to do with the installed version of libsolv not supporting bzip2 compression. Like me, you may not have the most recent version being installed because setting priorities in the repo config files.
Failed to open: /var/cache/dnf/x86_64/7/x86_64/7/epel/...xml.bz2
See bug report 1258416.
libsolv-0.6.14-1.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.
The libsolv installed from the CentOS base repository is 0.6.11-1.el7, but the one in epel is 0.6.14-1.el7.
yum --showduplicates --disablerepo=base list libsolv
Installed Packages
from __future__ import print_function
import boto3
import json
import logging
from base64 import b64decode
from urllib2 import Request, urlopen, URLError, HTTPError
import json
@makeittotop
makeittotop / gist:da64db8b18b6e860d8aca168015a1744
Created July 27, 2016 10:51
MYSQL-CROSS-REGION-REPLICATION AWS
REMEMBER !!!
TO CONNECT TO A REMOTE HOST IN THE OTHER VPC, WE'D NEED TO OPEN UP THE CORRESPONDING PORT ON THE VPN-TUNNEL SERVER SECURITY GROUP ON THE SAME SIDE AS WELL AS ONLY THEN THE TUNNEL INSTANCE WILL ALLOW THE FLOW OF TRAFFIC TO THE OTHER SIDE. REPEAT THE SAME STEPS FOR THE OTHER SIDE TOO.
MUM - TUNNEL SERVER - sg
TCP 22 0.0.0.0/0
TCP
51
mkfifo /tmp/mysql-pipe
mysql mydb </tmp/mysql-pipe &
(
echo "LOCK TABLES mytable READ ;" 1>&6
echo "Doing something "
echo "UNLOCK tables;" 1>&6
) 6> /tmp/mysql-pipe
@makeittotop
makeittotop / mariadb repl
Last active July 26, 2016 13:13
replication mysql/mariadb
MASTER
MariaDB [(none)]> create user 'replication'@'%'identified by 'password';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant replication slave on *.* to replication
-> ;
Query OK, 0 rows affected (0.00 sec)
1 yum install -y firewalld
2 systemctl enable firewalld
3 systemctl start firewalld
4 systemctl status firewalld
5 firewall-cmd --get-default-zone
6 firewall-cmd --list-zones
7 firewall-cmd --list-zone
8 firewall-cmd list-zone
9 firewall-cmd list-zones
10 firewall-cmd
@makeittotop
makeittotop / gist:a8ce609940ee8611bd59c0296eb5b91f
Created July 21, 2016 08:30
running docker with overlayfs on aws ec2
At the end these are steps you need to have a docker server with OverlayFS as backend storage on AWS/EC2
Fire up an 'ubuntu 14.04' server on AWS/EC2
Upgrade kernel to 3.18
Install Docker on server
Create an EBS volume
Attach new volume to created server
Create a file system on volume:
6.1. Connect to your instance and run lsblk to find available disk devices and their mount points.
6.2. From the result of lsblk command, choose device that is attached, but not been mounted yet (e.g. xvdf, ...). devicename would be the selected device with a /dev/ as a prefix (e.g. /dev/xvdf,...)