RSS

Category Archives: Documents

How to check out public IP on Linux

We are able to check at our Public address as following ways:

 

[root@zmail axon]# dig +short myip.opendns.com @resolver1.opendns.com
111.93.119.34
[root@zmail axon]# curl ifconfig.co
111.93.119.34
[root@zmail axon]# curl ifconfig.me
111.93.119.34

 
Leave a comment

Posted by on August 23, 2018 in DNS, Documents, Linux

 

Installation missing of php-devel php-mbstring on Redhat 7

Installation missing of php-devel php-mbstring on Redhat 7

# yum install php-devel php-mbstring

No package php-devel available.
No package php-mbstring available.

Solution:-

# subscription-manager repos –enable=rhel-7-server-optional-rpms

[root@mail /]# yum install php-devel php-mbstring
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
Resolving Dependencies
–> Running transaction check
—> Package php-devel.x86_64 0:5.4.16-45.el7 will be installed
–> Processing Dependency: pcre-devel(x86-64) for package: php-devel-5.4.16-45.el7.x86_64
—> Package php-mbstring.x86_64 0:5.4.16-45.el7 will be installed
–> Running transaction check
—> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

==============================================================================
Package Arch Version Repository Size
==============================================================================
Installing:
php-devel x86_64 5.4.16-45.el7 rhel-7-server-optional-rpms 602 k
php-mbstring x86_64 5.4.16-45.el7 rhel-7-server-optional-rpms 505 k
Installing for dependencies:
pcre-devel x86_64 8.32-17.el7 rhel-7-server-rpms 480 k

Transaction Summary
==============================================================================
Install 2 Packages (+1 Dependent package)

Total download size: 1.5 M
Installed size: 6.7 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): php-mbstring-5.4.16-45.el7.x86_64.rpm | 505 kB 00:06
(2/3): php-devel-5.4.16-45.el7.x86_64.rpm | 602 kB 00:07
(3/3): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:07
——————————————————————————
Total 216 kB/s | 1.5 MB 00:07
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pcre-devel-8.32-17.el7.x86_64 1/3
Installing : php-devel-5.4.16-45.el7.x86_64 2/3
Installing : php-mbstring-5.4.16-45.el7.x86_64 3/3
Verifying : php-mbstring-5.4.16-45.el7.x86_64 1/3
Verifying : php-devel-5.4.16-45.el7.x86_64 2/3
Verifying : pcre-devel-8.32-17.el7.x86_64 3/3

Installed:
php-devel.x86_64 0:5.4.16-45.el7 php-mbstring.x86_64 0:5.4.16-45.el7

Dependency Installed:
pcre-devel.x86_64 0:8.32-17.el7

Complete!
[root@mail /]#

 
Leave a comment

Posted by on August 20, 2018 in Documents, Linux, PostgreSQL, Zabbix

 

How to add swap space using file

============================================================================

In case if there is no free space left on disk to create new partition, we can also use file as swap. To do so, use dd command to create a file of required size.

1. Before you can check with your root partition space.

[root@mail ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 28G 11G 17G 40% /
devtmpfs 985M 0 985M 0% /dev
tmpfs 1001M 0 1001M 0% /dev/shm
/dev/sda1 473M 161M 313M 34% /boot
tmpfs 201M 0 201M 0% /run/user/991

2. To create a file for swap of required size.

[root@mail ~]# dd if=/dev/zero of=/root/swapfile01 bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 7.99505 s, 134 MB/s

[root@mail ~]# df -h
/dev/mapper/cl-root 28G 11G 16G 44% /
devtmpfs 985M 0 985M 0% /dev
tmpfs 1001M 0 1001M 0% /dev/shm
/dev/sda1 473M 161M 313M 34% /boot
tmpfs 201M 0 201M 0% /run/user/991

3. To make is more secure apply appropriate permissions to the file.

[root@mail ~]# chmod 644 /root/swapfile01

4. To run the mkswap command to convert the file to swap file

[root@mail ~]# mkswap -L swap01 /root/swapfile01
Setting up swapspace version 1, size = 1048572 KiB
LABEL=swap01, UUID=1c641239-2a57-49d0-ac5f-cc840548977d

5. To check the current usage of swap with priority

[root@mail ~]# swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 1952764 1364440 -1

[root@mail ~]# free -m
total used free shared buff/cache available
Mem: 2000 1513 184 54 303 263
Swap: 1906 1332 574

6. Just add the following entiry for swap file

[root@mail ~]# vi /etc/fstab

/root/swapfile01 swap swap defaults 0 0

7. To check the current usage of swap with priority

[root@mail ~]# swapon -a
swapon: /root/swapfile01: insecure permissions 0644, 0600 suggested.

[root@mail ~]# swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 1952764 1364188 -1
/root/swapfile01 file 1048572 0 -2

[root@mail ~]# free -m
total used free shared buff/cache available
Mem: 2000 1514 180 54 305 262
Swap: 2930 1332 1598

To Removing Swap:

# swapoff -a ### this will remove all swap(s) mentioned in /etc/fstab
# swapoff /dev/sdc1 ### to remove individual swap

 
Leave a comment

Posted by on July 29, 2018 in Documents, Linux, Storage

 

How to configure Network File System (NFS) on Linux

How to configure Network File System on Linux

NFS (Network File System) is one way of sharing files across a network.

1. To installing NFS
# yum -y install nfs-utils nfs-utils-lib rsync

2. To configure NFS    2.1  To create a directory for sharing to our client end
# mkdir /public
2.2  To create a files for testing
# cd /public
# touch file1 file2 file3
2.3 To edit the exports file  vi /etc/exports
2.4 To add following line to exports
# /public *(ro,sync)

3. To start the nfs server service
# /etc/init.d/nfs start

4. To enable nfs service
# chkconfig nfs on

5. Enable the export immediately with the command exportfs -v and export with the command showmount -e.

6. To configuring the NFS Client end
# yum -y install nfs-utils nfs-utils-lib rsync

7. To make directory for mount from server
# mkdir Sharing
# mount serverip:/public Sharing
# cd /Sharing
# ls file1 file2 file3

 
Leave a comment

Posted by on July 10, 2018 in Documents, Linux

 

To Install LEMP (Nginx, MySQL, PHP) On Centos for WordPress

To Install LEMP (Nginx, MySQL, PHP) On Centos
1. Installing EPEL in CentOS 

# yum install epel-release
2. To install php

# install php-fpm php-mysql

# vi /etc/php.ini

;cgi.fix_pathinfo=1 -> change to ;cgi.fix_pathinfo=0

# vi /etc/php-fpm.d/www.conf

[www]
listen = /var/run/php-www.socket
user = www-data
group = www-data

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/blogcms_log
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 400
listen.backlog = -1
pm.status_path = /status

request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited

catch_workers_output = yes

php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_admin_value[error_log] = /var/log/php-fpm/www-error_log
php_admin_flag[log_errors] = on
3. Install and Configure PHP-APC

# yum install php-pecl-apc

# vi /etc/php.d/apc.ini

extension = apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128M
apc.num_files_hint=1024
apc.user_entries_hint=4096
apc.ttl=7200
apc.use_request_time=1
apc.user_ttl=7200
apc.gc_ttl=3600
apc.cache_by_default=1
apc.filters
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.file_update_protection=2
apc.enable_cli=0
apc.max_file_size=1M
apc.stat=1
apc.stat_ctime=0
apc.canonicalize=0
apc.write_lock=1
apc.report_autofilter=0
apc.rfc1867=0
apc.rfc1867_prefix =upload_
apc.rfc1867_name=APC_UPLOAD_PROGRESS
apc.rfc1867_freq=0
apc.rfc1867_ttl=3600
apc.include_once_override=0
apc.lazy_classes=0
apc.lazy_functions=0
apc.coredump_unmap=0
apc.file_md5=0
apc.preload_path

# /etc/init.d/php-fpm start
# chkconfig php-fpm on

4. Installing and Configuring NGINX

# yum install nginx

# /etc/init.d/nginx start

# chkconfig nginx on

# mkdir /var/www/wordpress/public_html -p
# mkdir /var/www/wordpress/logs -p
# chown -R nginx:nginx /srv/www/wordpress

# mkdir /etc/nginx/sites-available -p
# mkdir /etc/nginx/sites-enabled -p

# cd /tmp
# wget http://wordpress.org/latest.tar.gz

# tar -xvf latest.tar.gz -C /var/www/wordpress/public_html/ –strip-components=1

# vi /etc/nginx/nginx.conf

include /etc/nginx/sites-enabled/*;          # to add this line at end

5. To create a file as following

# cd /etc/nginx/sites-available/

# cat lqs.co.in.conf
server {
server_name lqs.co.in;

access_log /var/www/wordpress/logs/access.log;
error_log /var/www/wordpress/logs/error.log;
root /var/www/wordpress/public_html;

location / {
index index.php;
}
# Disable favicon.ico logging
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Allow robots and disable logging
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Enable permalink structures
if (!-e $request_filename) {
rewrite . /index.php last;
}
# Handle php requests
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/wordpress/public_html$fastcgi_script_name;
}
# Disable static content logging and set cache time to max
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
# Deny access to htaccess and htpasswd files
location ~ /\.ht {
deny all;
}
}

# cd ../sites-enabled/
# ln -s /etc/nginx/sites-available/lqs.co.in.conf

6. Installing and Configuring MySQL

yum install mysql-server

service mysqld start

mysql_secure_installation

[root@localhost public_html]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER wordpressuser@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> SET PASSWORD FOR wordpressuser@localhost= PASSWORD(“nginx@123”);
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

Edit the /etc/my.cf file to match the following, limiting the server only to listen to local connections:

# cat /etc/my.cnf
[mysqld]
bind-address = 127.0.0.1 # server listen to locally
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# /etc/init.d/mysqld restart

# chkconfig mysqld on

7. Finally go to browser and check as follow:

http://localhost or IP-address

 

 
Leave a comment

Posted by on September 20, 2017 in Documents, Linux, Web Service

 

How to add entry Grub 2 on CentOS 7 for Dual Boot Loader

How to add entry Grub 2 on CentOS 7 for Dual Boot Loader

1. To check fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 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 label type: dos
Disk identifier: 0x00000080

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 137091071 68442112 7 HPFS/NTFS/exFAT
/dev/sda3 137091072 556929023 209918976 7 HPFS/NTFS/exFAT
/dev/sda4 556929024 976771071 209921024 f W95 Ext’d (LBA)
/dev/sda5 556931072 768124927 105596928 7 HPFS/NTFS/exFAT
/dev/sda6 768126976 768946175 409600 83 Linux
/dev/sda7 768948224 976771071 103911424 8e Linux LVM

Disk /dev/mapper/vg_dilli-LogVol01: 102.2 GB, 102206799872 bytes, 199622656 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 /dev/mapper/vg_dilli-LogVol00: 4194 MB, 4194304000 bytes, 8192000 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

2. To add boot loader for Windows 7

root@ dilli]# cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the ‘exec tail’ line above.

menuentry “Windows 7” {
set root=(hd0,1)
chainloader +1
}

3. To run the following command for updating to boot loader

[root@ dilli]#  grub2-mkconfig –output=/boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-c833c6b0eb7b44bc9cc074241dd98ed7
Found initrd image: /boot/initramfs-0-rescue-c833c6b0eb7b44bc9cc074241dd98ed7.img
done

4. Finally Reboot it, That’s it.

 
Leave a comment

Posted by on September 19, 2017 in Documents, Linux, Windows

 

How to create central YUM Repository server on CentOS step by step

How to create central YUM Repository server on CentOS

Step 1. To Install Createrepo on server

[root@repo ~]# yum -y install httpd xinetd syslinux vsftpd dhcp

Complete!

Step 2. To Create repository directory and add packages on directory

[root@repo ~]# mkdir /repos/CentOS/6.8/ -p

[root@repo ~]# createrepo –update /repos/CentOS/6.8/
Could not find valid repo at: /repos/CentOS/6.8/

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

Step 3. To Mirror using Local ISO

[root@repo /]# mount -o loop /media/sr0/ /mnt/
[root@repo /]# cp -arv /mnt/* /repos/CentOS/6.8/

Step 4. To Mirror using Online Repository

[root@repo /]# rsync -rz –progress rsync://download.nus.edu.sg/centos/6.8/

Step 5. To publish our local repository via apache

[root@repo /]# yum install httpd

[root@repo /]# ln -s /repos/CentOS/ /var/www/html/CentOS

[root@repo ]# /etc/init.d/httpd start
Starting httpd: [ OK ]

Step 6. If you need File sharing using FTP

[root@repo /]# yum install vsftpd

[root@repo /]# ln -s /repos/CentOS/ /var/ftp/pub/CentOS_ftp

[root@email CentOS]# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd: [ OK ]

Step 7. To create local.repo on client systems

cd /etc/yum.repo.d/

vi local.repo

Add as follow:

[mylocalrepo]
name=Local CentOS Repo
baseurl=http://my-repo-server/CentOS/6.8
gpgcheck=0

 
Leave a comment

Posted by on August 22, 2017 in Documents, Linux

 

Diff. b/w RAMFS and TMPFS Mount

Diffent b/w RAMFS and TMPFS

Both can allocate part of the physical memory to be used as a partition. Once you mount the partition and start writing and reading files to the RAM, it should be faster.

1. How to mount Tmpfs

# mount -t tmpfs -o size=512M tmpfs /opt/zimbra/data/amavisd/tmp
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_email-LogVol01
18G 5.6G 12G 33% /
tmpfs 936M 72K 936M 1% /dev/shm
/dev/sda1 291M 49M 227M 18% /boot
tmpfs 512M 0 512M 0% /opt/zimbra/data/amavisd/tmp

2. How to mount Ramfs

# mount -t ramfs -o size=512M ramfs /opt/zimbra/data/amavisd/tmp
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_email-LogVol01
18G 5.6G 12G 33% /
tmpfs 936M 72K 936M 1% /dev/shm
/dev/sda1 291M 49M 227M 18% /boot
tmpfs 512M 0 512M 0% /opt/zimbra/data/amavisd/tmp

# mount
/dev/mapper/vg_email-LogVol01 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
tmpfs on /opt/zimbra/data/amavisd/tmp type tmpfs (rw,size=512M)

3. Ramfs vs Tmpfs

Ramfs will grow dynamically / Tmpfs will not grow dynamically
Ramfs does not use swap / Tmpfs uses swap

4. Disadvandages

Since both ramfs and tmpfs is writing to the system RAM, it would get deleted once the system gets rebooted, or crashed. So it will not help in the time of system crash.

 
Leave a comment

Posted by on August 15, 2017 in Documents, Linux, Zimbra

 

Diff. b/w Stateful / Stateless Services for HA

What is different between stateful and stateless services for High Availability Technologies.

Stateful:

  • An action typically comprises multiple requests
  • Data needs to be replicated and synchronized between redundant services (to preserve state and consistency)
  • For example on Openstack services for stateful  MySQL, RabbitMQ, Cinder Volume, Ceilometer center agent, Neutron L3, DHCP agents, etc.

Stateless:

  • There is no dependency between requests
  • No need for data replication/synchronization. Failed request may need to be restarted on a different node.
  • For example on Openstack for stateless services  Nova-api, nova-conductor, glance-api, keystone-api, neutron-api, nova-scheduler, Apache web server, Cinder Scheduler, etc.
 

How to install your Windows 10 System for Python

Step 1 :  Visit http://www.python.org and navigate to Downloads > Windows and click Python 2.7.9.

Step 2 : Wait for the Python installer to download, and then double click on it. The Python Windows Installer will launch.

Step 3 : In the Python Setup screen, select Install for all users and click Next >, Once the installation completes, choose Finish.

Step 4 : Now we need to add Python to the environment variables. This means when you type “python” into the Windows Command Prompt window, it will start Python. Right click the Start Menu in the bottom left and select System to load the System menu.

Step 5 : In the System menu, click on Advanced system settings. In the System Properties window, select the Advanced tab and click Environment Variables…

Step 6 : Under System variables, find the variable with the name Path. Click it and choose Edit…

Step 7 : Being careful to leave the existing values intact, navigate to the end of the Variable value text box. Then append “;C:\Python27\” to the end (without quotes). The semicolon is used to separate the variables. Then click OK to save the update.

Step 8 : Now left click the start menu again and choose Command Prompt to load a new Command Prompt window. Now enter “python” into the window and hit Enter.

Step 9 : If you type print “hello world” it should output “Hello World” on the screen. Python has been successfully installed.

 
Leave a comment

Posted by on May 23, 2017 in Documents