Extends Storage – Performing an online resize

RedhatThis is a dangerous & thrilling step because we do it on production server directly. I presumed you have read the following posts : LVM Subject  so we are focusing on How to Extends our Linux Storage – Performing an online resize (on the fly). It means without disturbing our traffic or other realtime activities.

STEP 1 : Check logical volume information after check filesystems disk space to ensure  which partition that we have to extends.
#####################################
root@svr-2:~# lvs
File descriptor 3 (pipe:[1244115786]) leaked on lvs invocation. Parent PID 16940: -bash
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
root ubuntu -wi-ao 398.75g
swap_1 ubuntu -wi-ao 1.00g

STEP 2 : Get the information about newly added hard drive using fdisk -l command
#####################################
Disk /dev/sdd: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdd doesn’t contain a valid partition table

STEP 3 : Continue to create the partition on the newly added harddrive, type n , p (primary), 1 (partition number), t (filesystems type), 8e (for Linux LVM), w (write changes), then the partition table will be altered
#####################################
root@svr-2:/# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x3d67c672.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

STEP 4 : identify the already mounted lvm filesystems type (ext4 will be global filesystems we used)
#####################################
root@svr-2:/# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root ext4 412097132 316081888 75145552 81% /
udev devtmpfs 8208612 4 8208608 1% /dev
tmpfs tmpfs 1643540 300 1643240 1% /run
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 8217700 0 8217700 0% /run/shm
/dev/sda1 ext2 233191 27519 193231 13% /boot

Continue reading

Advertisements

Tips and Tricks AWK – Sed (Stream editor)

One day, we want to remove specific line or row from our files such as .txt, .csv, or even it has come from .sql files. Just using these params :
~# sed -e ‘5,10d;12d’ <your_files> #delete lines 5 through 10 and 12 temporarily ( options -e or permanently with -i )
In another case of awk, we want to parse data or word between delimiter of double quote which is containing two commas like : “hary”,”hary,harysmatta”,”nda”
Just use these params. Simply the best :

awk -vFPAT='([^,]*)|(“[^”]+”)’ -vOFS=, ‘{print $2}’

SSLS Procedure

In order to utilize the service from ssls for their certificate, first you have to make sure that the order status is in progress. It means that domain type, either you have order single or multiple domain are ready to use.
Next you have to choose activation method for domain. Manually upload by putting of comodo activation file *.txt to <DOCUMENT_ROOT>/.well-known/pki-validation/ then access it.
OR you contact the support to activated by email. They will sent you archive as requirement ssl like these : AddTrustExternalCARoot.crt , COMODORSAAddTrustCA.crt , COMODORSADomainValidationSecureServerCA.crt , and STAR_<domain_name>.crt .

Next just put it on these web service config :
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/<domain_directory>/STAR_<domain_name>.crt
SSLCertificateKeyFile /etc/apache2/ssl/<domain_directory>/<domain_name>.key
SSLProtocol All -SSLv2 -SSLv3

But do not forget to initiate <domain_name>.key first with these params:
openssl genrsa -des3 -out myupointid.key 2048
And generate first *.csr code on your server with this params:
openssl req -new -newkey rsa:2048 -nodes -keyout example.key -out example.csr <==== put it on SSLS.com dashboard activation

Done

 

Noted :

Create a self-signed (wildcard) SSL certificate

mkdir /usr/share/ssl/certs/hostname.domain.com
cd /usr/share/ssl/certs/hostname.domain.com
(umask 077 && touch host.key host.cert host.info host.pem)
openssl genrsa 2048 > host.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key host.key > host.cert
…[enter *.domain.com for the Common Name]…
openssl x509 -noout -fingerprint -text < host.cert > host.info
cat host.cert host.key > host.pem
chmod 400 host.key host.pem

Create a self-signed (wildcard) SSL certificate
1) If you received and uploaded the intermediate and root certificates separately, please use this method:

cat your_domain.crt intermediate.crt root.crt >> ssl-bundle.crt

For example, this particular command is applicable for PositiveSSL certificate:

cat example_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt >> ssl-bundle.crt

2) If you received the intermediate certificates in one bundle file or downloaded the certificate files in your account with us, you can use this command:

cat example_com.crt bundle.crt >> ssl-bundle.crt

Check Domain Issue on Nagios – Solved

If we got result like these lines :
/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_domain -d <blabla>.id
UNKNOWN – WHOIS exited with error <whatever number 😀 >

do not waste your time to add following codes on number 215 after setup_whois:

if [ -z $server ]
then
if echo “$domain” | grep -q -e “.com$” -e “.net$” -e “.edu$”
then
server=”whois.verisign-grs.com”
fi
fi

Just add this param and specifiy your whois server referring domain that you are using: /usr/local/nagios/libexec/check_domain -d <your_domain> -s <whois_server>

In case you want to look for expired status from domain .id , just put on whois.id after options -s (source) . Another whois server like whois.verisign-grs.com are allowed to search expire status for .com .net .edu .org . Then what do we do for .tv etc ?  this is not that sort of things. You have to search another whois server for .tv etc 🙂

Regards

Flavours of Windows

Don’t get me wrong. This note could be reference for me and for you also 🙂

1. How to shrink a partition on C:
Right click on My PC then choose manage. Expand the storage and choose disk management. Right click on partition C: that you want to shrink. Right click choose shrink volume > Format > done.

2. Can’t see second partition after shrink it
enter diskpart on shortcut command by right click then choose administrator.  Type list volume then enter. Type select volume <number> shrink that you’ve made. And then type assign letter <number or name of partition letter>.

3. Problem GPT partition style after installing GNU/ Linux Distribution
Method #1:
1. Boot up to installation DVD/CD.
2. Click install but don’t follow through.
3. Press SHIFT-F10 to bring up console.
4. Type “diskpart”
5. Once inside diskpart type:
-> list disk (find the one you want to convert)
-> select disk 0 (select the one you want from the list)
-> convert mbr (should take a second or two)
-> quit
6. Continue with install

Method #2:
1. Boot up to installation DVD/CD.
2. Click install but don’t follow through.
3. Press SHIFT-F10 to bring up console.
4. Type “diskpart”
5. Once inside diskpart type:
-> list disk (find the one you want to convert)
-> select disk 0 (select the one you want from the list)
-> clean (wait an hour or so until its done)
-> quit
6. Continue with install

4. Disable Windows 10 Update Assistant
Subkey: HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate
DWORD value: DisableOSUpgrade = 1

 

Many thanks

Expect on GNU/ Linux

There’s no hope for me if i didn’t expect on linux. How can we get the output from the outside into socket or something else without loged in. Herewith the option that we can use with expect :
– send : to send the strings to the process (like send_user etc)
– expect : wait for the specific string from the process
– spawn : to start the command

Here is the example for you. Making the expect with .sh

#!/usr/bin/expect
#
# Hary HarysMatta
#

set timeout 10
set ip [lindex $argv 0]
set port [lindex $argv 1]

spawn telnet $ip $port
set timeout 5
#expect “Escape character is ‘^]’.”
#send “^]\n”;
#send “q\n”;

expect {
“Escape character is ‘^]’.”
{
send “^]\n”;
send “q\n”;
send_user “OK – Telnet success : x.x.x.x 1234\n”
exit 0
}
“host: Connection refused”
{
send_user “CRITICAL – telnet Kibana Refused!\n”
exit 2
}
}

Google Analytics Masterclass

Semoga bermanfaat..