Friday, July 29, 2016

mysql-master-slave-replication

Why is MySQL replication needed?
MySQL master slave replication is carried out by many for more reasons than one. They could be:
  • To Speed up your application: One of the biggest points of interest to have master-slave set up in MySQL is to have the ability to utilize master for the inserts, update and delete queries and slave for select queries. This will generally likely to accelerate your website without needing to swooping into optimizing all the queries or purchasing more hardware.
  • To Replicate your Database: Replication is the main innovation that can fulfill the necessities of the most requesting systems, as just replication can give moment access to information and zero information loss.
  • To enable Disaster recovery strategy: A database can get unusable because of a wide assortment of hardware or software washouts. Master slave cloning will automatically create a copy of your primary database and thus you always have latest copy of your database.
  • To keep the backup up to date: Data on the slave server is more likely to be up to date than on a periodical backup which is only performed periodically (eg: daily).  If there is a complete failure of the Master Server, the Slave Server can be made available to take over the functionality, or it can be used to restore data with minimal loss.
What is MySQL master slave replication?
MySQL master slave replication is a configuration made with two MySQL database servers which allows them to easily maintain multiple copies of MySQL data. I have described in the below step wise tutorial on how to set up MySQL master-master replication. This configuration let’s slave database to automatically copy the data from master MySQL database.
What are the advantages of MySQL master slave replication?
This kind of configuration is done for many reasons as it has many advantages including,
  • Automatic database backup ,
  • A way to analyze the database without using the main database,
  • Automatically maintaining clone of the server.
Architecture of the Master Slave configuration:
On Master,
  1. Get the Replication Master Binary Log Coordinates
  2. Create a data snapshot using mysqldump
  3. Transfer the data on Slave
On Slave,
  1. Restore the data snapshot
  2. Set the Slave to start replication
Watch out this space soon to find the step wise process to do the set up for master slave replication.

Tuesday, July 26, 2016

FC port statistics for FlexFabric modules

This screen provides details on Port Information and Port Statistics, and is available only on physical uplink
ports. Detailed statistics are not supported on FC interconnect modules. However, FC-capable ports do support detailed statistics.
To reset the statistics, click Reset Statistics



CLI command Guide

Example:

# show statistics enc10:1:d2

Enc0==Enclosure number
1=IC-Bay1 VC Module
 D2 =downlink port of the VC to cross pond to Device bay 2 (Server port)

#show statistics enc10:1:X1
Enc0==Enclosure number
1=IC-Bay1 VC Module
X1=Uplink port


#reset statistics enc0:1:d2

Saturday, July 23, 2016

Oracle: Tablespace critical threshold message



A DBA's main responsibility also include checking the tablespace space regularly,We can check this space each time with help of some useful views like dba_data_files provided by oracle.But this is tough some time whenever some developer load the data and suddenly you see the space almost occupied.So I decided to use the below script which will send me the alert mail whenever the space becomes 85% filled(critical threshold) which will be very much helpful to make sure the tablespace is having enough space. 

The script is as given below: 

Tablespace critical message when it becomes 85% occupied:
----------------------------------------------------------
 

#!/bin/ksh 

export PATH=/star/app/oracle/product/11.1.0/db_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/star/bin 
export ORACLE_BASE=/star/app/oracle 
export LD_LIBRARY_PATH=/star/app/oracle/product/11.1.0/db_1/lib:/lib:/usr/lib 
export LD_LIBRARY_PATH=/ora11g/app/oracle/product/11.1.0.7/lib:/usr/lib:/usr/ccs/bin:/usr/dt/lib 
export ORACLE_HOME=/star/app/oracle/product/11.1.0/db_1 


MAILLIST=`cat /home/star/scripts/email.lst` 
LOGFILE=/tmp/chk_ts_$1.log 

echo $1 

CHKUP=`ps -ef | grep pmon | grep $1 | wc -l` 

if [ "${CHKUP}" -eq 1 ] 
then 
echo "The Pmon Process is running on host" 
else 
echo " ****************************************************************" >> $LOGFILE 
echo " " `date` " Pmon Proces is not found" >> $LOGFILE 
echo " ****************************************************************" >> $LOGFILE 
exit 0 
fi 

export ORACLE_SID=$1 

sqlplus -s "/ as sysdba" <WHENEVER SQLERROR EXIT SQL.SQLCODE
set echo off
set trimspool on
set trimout on
set verify off
set feedback off
column TABLESPACE_NAME format a18
column "%ocup" format a6
set lines 200
spool /tmp/chk_ts_$1.spl
SELECT total.tablespace_name tablespace_name,
ROUND (tot / 1024 / 1024) total,
ROUND ((tot - tot_l) / 1024 / 1024) occupied,
ROUND (tot_l / 1024 / 1024) remain,
ROUND (max_l / 1024 / 1024) max_extent,
ROUND ((tot - tot_l) * 100 / tot) || '%' AS "%ocup"
FROM (SELECT tablespace_name, SUM (BYTES) tot_l, MAX (BYTES) max_l
FROM dba_free_space
GROUP BY tablespace_name
UNION
SELECT d.tablespace_name,
f.bytes_free + f.bytes_used - NVL (p.bytes_used, 0) tot_l,
0 max_l
FROM SYS.v_\$temp_space_header f,
dba_temp_files d,
SYS.v_\$temp_extent_pool p
WHERE f.tablespace_name(+) = d.tablespace_name AND f.file_id(+) = d.file_id
AND p.file_id(+) = d.file_id) libre,
(SELECT tablespace_name, SUM (BYTES) tot
FROM dba_data_files
GROUP BY tablespace_name
UNION
(SELECT tablespace_name, SUM (BYTES) tot
FROM dba_temp_files
GROUP BY tablespace_name)) total,
dba_tablespaces dba_t
WHERE total.tablespace_name = libre.tablespace_name(+)
AND total.tablespace_name = dba_t.tablespace_name
AND ROUND (tot_l / 1024 / 1024) < 1024
AND ROUND ((tot - tot_l) * 100 / tot) > 85
AND dba_t.tablespace_name NOT IN ('RBS')
ORDER BY ROUND ((tot - tot_l) * 100 / tot) DESC;
spo off
EOF
if [ -s /tmp/chk_ts_$1.spl ]; then
cat /tmp/chk_ts_$1.spl | mailx -s "Critical : ($1 on machinename.abcd.com.sg) Missing free space on tablespace of the database $1 -- Immediate Action" $MAILLIST
echo "---------------------------------------------------------------------------" >> $LOGFILE
echo `date` >> $LOGFILE
cat /tmp/chk_ts_$1.spl >> $LOGFILE
echo "---------------------------------------------------------------------------" >> $LOGFILE
rm -fr /tmp/chk_ts_$1.spl
fi 

Friday, July 22, 2016

How To Fix – NFS Cluster Resource / 14202 Error in Windows Failover Cluster Manager

 The below short article wrote help to fix the 14202 errors in windows failover cluster – Titled “How-To Fix windows Failover cluster 14202 Event ID error”. Issue deals fixing One of the Cluster resources failed to start with this error in FCM (Failover Cluster Manager). It can be NFS / someother fileshare/disk based resource hosted on FCM.
Cluster Resource Failure
Upon looking at the Resources of this Failed Cluster resource, you can see that NFS/resource related to this is in failed state.
Resource Failed -1
To see what’s causing the issue with NFS/related resource failures, you have to go to Cluster events to know more about the error cause.
Cluster Error Logs_Events
Now you see that NFS-HyperV-FS is not dependent on disk resource G:\shares\NFS-FS, so it is failing to get the cluster resource online as there is no dependencies for the NFS share we’ve configured to use for this NFS cluster resource. NFS file share works when it has dependencies/resources allocated to it.
Go to NFS resource properties as below and create dependency on the drive/share as below:
Cluster Dependency missing

Now, click on Empty Resource field and drop down the menu there to select Cluster Disk/Disk presented to the NFS/Cluster resource in FCM (if there is only one filed here in Resource, Add One as required; click Insert to add empty fields). In my case Cluster Disk 3 is the one that is hosting the NFS shares. Click AND property to have the resource dependent on Disk explicitly; this means disk and NFS object name should be online to get the resource working (of course, if CNO (Cluster Name Object) alone is online, no use as share drive is offline:) )
Cluster dependency set
So now we’ve set the Cluster DIsk 3/NFS share disk and HyperV-FS; that is computer object name for accessing the NFS. This should solve the dependency problem and help get the cluster resource online. Now try bringing the NFS resource online again from FCM and this should work now:)
Fixed NFS cluster
Please let me know if you have any questions/trouble fixing this kind of errors. You can always comment if you have issues with Failover Clusters in Windows or VMware.\
Reference : https://chaladi.me/2015/07/29/how-to-fix-nfs-cluster-resource-14202-error-in-windows-failover-cluster-manager/

Thursday, July 21, 2016

What is hostd and vpxa in vmware ?

hostd is an app that runs in the Service Console that is responsible for managing most of the operations on the ESX machine.  It knows about all the VMs that are registered on that host, the luns/vmfs volumes visible by the host, what the VMs are doing, etc.  Most all commands or operations come down from VC through it.  i.e, powering on a VM, VM vMotion, VM creation, etc.
vpxa also runs on the Service Console and talks to VC.  I believe it acts as an intermediary between VC and hostd. I think it also does some housekeeping on the ESX host, but not as much as hostd.
VPXA
It acts as an intermediary between VC and hostd. The vCenter Server Agent, also referred to as vpxa or the vmware-vpxa service, is what allows a vCenter Server to connect to a ESX host. Specifically, vpxa is the communication conduit to the hostd, which in turn communicates to the ESX kernel.
Restart the vpxa service
/etc/init.d/vpxa restart
 
Note:- If you have SSH enabled on your ESXi server these services can also be restarted and even if these are restarted by you then also your SSH session will not be impacted.
VPXD-It is Vcenter Server Service. If this service is stopped then we will not able to connect to Vcenter Server via Vsphere client.
VPXA-It is the agent of Vcenter server. also known as mini vcenter server which is installed on the each esx server which is managed by Vcenter server. What are the management action we are performing on top of the vcenter server. (Like:- Increasing/Decreasing RAM & HDD, Making any type of changes in cluster, doing vmotion. This agent collects all information from the vcenter server and pass this information to the kernal of the esx server.
HOSTD- This is the agent of ESX server, here VPXA pass the information to the HOSTD and hostd pass the information to ESX server.
In ESX, you have only hostd and (if you have vCenter) vpxa.
These are daemon (services) for remote management:
  • hostd is used to remote management using VIC
  • vpxa is used by vCenter (the vpxd part of vCenter) to remote manament
hostd is the daemon for direct VIC connection (when you use Virtual Infra Client (VIC) to connect to your ESX).
Also,
  • vpxa is the VC agent (ESX side)
  • vpxd is the VC daemon (VC side)

Tuesday, July 19, 2016

How to reclaim Space from Datastore ?



In order to reclaim space you need to run unmap command from Vmware server.

Kindly run refer below.

esxcli storage vmfs unmap -l (label name)
or
esxcli storage vmfs unmap -u (UUID)

Thursday, July 14, 2016

HP 3PAR CLI commands




show* -  Show information about resources.

In each case type "help <command>" for detailed help.

        showalert        - show status of system alerts
        showaocfg        - show all Adaptive Optimization configurations
        showauthparam    - show authentication parameters
        showbattery      - show battery status information
        showblock        - show block mapping info for vvs, lds, pds
        showcage         - show disk cage information
        showcert         - show SSL certificate
        showcim          - show the CIM server information
        showclienv       - show CLI environment parameters
        showcpg          - show Common Provisioning Groups (CPGs)
        showdate         - show date and time on all system nodes
        showdomain       - show domains in the system
        showdomainset    - show sets of domains in the system
        showeeprom       - show node eeprom information
        showencryption   - show encryption information
showeventlog     - show event logs
showfirmwaredb   - show current database of firmware levels
showfs           - show information on File Persona cluster
showfsav         - show antivirus properties for file persona
showfsgroup      - show local group information associated with
                  File Persona
showfshare       - show file shares information
        showfsip         - show the network config of a Virtual File Server
        showfsnap        - show file store snapshots
        showfsnapclean   - show details of an on-demand snapshot reclamation task
        showfsndmp       - show details of NDMP properties of a file persona
        showfpg          - show file provisioning groups
        showfsquota      - show filesystem quota information
        showfstore       - show file store information
        showfsuser       - show local user information associated with
                           File Persona
showhost         - show host and host path information
showhostset      - show sets of hosts in the system
        showinventory    - show hardware inventory
        showiscsisession - show iscsi sessions
        showld           - show logical disks (LDs) in the system
        showldch         - show LD to PD chunklet mapping
        showldmap        - show LD to VV mapping
        showlicense      - show installed license key
        shownet          - show network configuration and status
        shownode         - show node and its component information
        shownodeenv      - show node environmental status (voltages,
                           temperatures)
        showpatch        - show what patches have been applied to the system
        showpd           - show physical disks (PDs) in the system
        showpdata        - show preserved data status
        showpdch         - show status of selected chunklets of physical disks
        showpdvv         - show PD to VV mapping
        showport         - show Fibre Channel and iSCSI ports in the system
        showportarp      - show ARP table for ports
        showportdev      - show detailed information about devices on a port
        showportisns     - show iSNS host information for ports
        showportlesb     - show Link Error Status Block information about
                           devices on Fibre Channel port
        showportpel      - show Phy Error Log information about
                           devices on SAS port
        showqos          - show QoS rules in the system
        showrcopy        - show Remote Copy configuration information
        showrctransport  - show information about end-to-end transport for
                           Remote Copy
        showrole         - show information about roles in the system
        showrsv          - show information about reservation and registration
                           of VLUNs connected on a Fibre Channel port
        showsched        - show scheduled tasks in the system
showsnmpmgr      - show SNMP trap managers
showsnmppw       - shows SNMP access passwords
showsnmpuser     - show SNMPv3 users and their authentication and
                           privacy protocols
        showspace        - show estimated free space
        showspare        - show information about spare and relocated chunklets
        showsr           - show System Reporter status
        showsralertcrit  - show System Reporter alert criteria
        showsshbanner    - show the SSH banner
        showsshkey       - show ssh public keys authorized by the current user
        showsys          - show system information (system name, serial number etc.)
        showsysmgr       - show system manager startup state
        showtarget       - show unrecognized targets
        showtask         - show information about tasks
showtemplate     - show templates
showtoc          - show system Table of Contents (TOC) summary
showtocgen       - show system Table of Contents (TOC) generation number
showuser         - show user accounts and SSH keys
showuseracl      - show user access control list
showuserconn     - show user connections
showversion      - show software versions
showvfs          - show Virtual File Server information
showvlun         - show virtual LUNs (VLUNs) in the system
showvv         - show virtual volumes (VVs) in the system
        showvvcpg        - show VV space distribution among CPGs
showvvmap        - show VV to LD mapping
showvvpd         - show VV distribution across PDs
showvvset        - show sets of VVs in the system
showwsapi        - show the Web Services API server information
showwsapisession - show the Web Services API server sessions information
showvasa         - show properties of the VASA web service provider
showvvolvm       - show information about virtual machines (vVol-based)
                           in the system

Use setclienv command to change the table format options.

Sunday, July 3, 2016

Howto Shrink a Thin Provisioned Virtual Disk (VMDK)








Shrink VMDK File

  1. Power off the Virtual Machine, or disconnect the virtual Disk you want to shrink
  2. Connect to the ESXi Host with SSH
  3. Navigate to the Virtual Machine Folder
  4. Verify disk usage with du
  5. Run vmkfstools -K [disk]
  6. Verify disk usage with du
root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
7.9G vma_1-flat.vmdk

root@esx3:/vmfs/volumes/ds1/vma $ vmkfstools -K vma_1.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 25% done.

root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
1.9G vma_1-flat.vmdk