-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Both InnoDB and PostgreSQL - as well as many other databases - use a technique called multi-version concurrency control (MVCC) to provide transaction isolation: transactions should not see the work of other, uncommitted transactions. MVCC means that, when a row is updated, the database stores both the old and new versions of the row.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thursday, January 3, 2013

Kernel Panic - Fallback to Old Kernel


Few days back, i was testing a kernel module, unfortunately it didn't work and instantly after reboot, kernel Panic occurs. Well i was clueless what goes wrong, but now i can not select the older kernel version to boot. But, there is a way out, if we choose these first before reboot (off course after installing new kernel), and this is inbuilt in GRUB. This mechanism is called Grub Fall-back. In this case you can set your older/tested kernel as the Fallback kernel in case new kernel panics. And here is how you do it:All you have to do is to open your /boot/grub/grub.conf and add a few lines in it like this

Saturday, August 18, 2012

Citrix XenServer – iSCSI LUN



Hi all, here is my new Mini-Howto for Citrix XenServer – Storage Repository Over Software iSCSI LUN



Topic contains:
How to Create NFS and iSCSI LUN on Linux (I will CentOS)
How to mount them on Citrix Xen Server using Command line and GUI (that includes Screen Shots)

Monday, May 21, 2012

commands

  1. rkhunter --check --rwo --summary > /tmp/rkhunter_final.log
  2. cat /tmp/archival_system/delJS_downtime.log | grep "^[0-9]" | awk '{sum=sum+$1} END{print sum}'
  3. grep "proxy\:" /var/log/apache_front_error_log | awk '{print $NF}' |grep -v resid | sort | uniq -c | sort -n
  4. for i in `ls -lrt | awk '{print $7"\t"$9}' | grep ^31 | awk '{print $2}'`; do cat $i  | tai64nlocal | grep "m.jannath\_perthous100\@yahoo.com"; cat $i  | tai64nlocal | grep "mahesh_f_b@yahoo.co.in"; cat $i  | tai64nlocal | grep "annaisai1986@yahoo.co.in"; cat $i  | tai64nlocal | grep "anfaz_m@hotmail.com"; cat $i  | tai64nlocal | grep "sujitha2012@gmail.com"; cat $i  | tai64nlocal | grep "desiginer@gmail.com"; done
  5.  for i in `ls -lrt | awk '{print $7"\t"$9}' | grep ^31 | awk '{print $2}'`; do cat $i  | tai64nlocal | grep "m.jannath\_perthous100\@yahoo
  6. cat /tmp/list | awk '{print $5}' | xargs -i egrep "adityaseth09@gmail.com|kvenk111@yahoo.co.in|knvs.prasad@gmail.com" /home/qmail-logs/2010/{}
  7. ls -ltra | awk '{print $5," ",$9}' | awk '$1 < 3000' | awk '/gif|png|jpg/ {print $2}' | xargs -I % cp -rp % /web/R/images/ 
  8. to massively clean lines containing x’s in front some css declarations in a group of files                          ls | awk '/.css$/' | xargs sed -i.bk -e '/^ *x.*$/d'    next...            find . -type f -exec grep -i '^ *x' /dev/null {} + | awk '!/svn|htdocs/' | cut -c 3- | awk '!/^#/' | awk -F ':' '{print $1}' | awk '/.css$/'| xargs sed -i.bk -e '/^ *x.*$/d\'
  9. seq -w 1 30 | xargs -i -t zcat in_Feb2011/in_Employer-{}Feb2011.gz | egrep 'resume.html?resid=3304847|resume.html?resid=30780899|resume.html?resid=31313778|resume.html?resid=31628106'

sar - Collect, report, or save system activity information.
      -b :Report I/O and transfer rate statistics.
      -B :Report paging statistics
      -d :Report activity for each block device (kernels 2.4 and newer only)
      -q :Report queue length and load averages
      -r :Report memory and swap space utilization statistics
      -u :Report CPU utilization.

iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
       -d : device utilization report
       -c : CPU usage report
       -x : Display  extended  statistics
 
iostat

    * rrqm/s : The number of read requests merged per second that were queued to the hard disk
    * wrqm/s : The number of write requests merged per second that were queued to the hard disk
    * r/s : The number of read requests per second
    * w/s : The number of write requests per second
    * rsec/s : The number of sectors read from the hard disk per second
    * wsec/s : The number of sectors written to the hard disk per second
    * avgrq-sz : The average size (in sectors) of the requests that were issued to the device.
    * avgqu-sz : The average queue length of the requests that were issued to the device
    * await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
    * svctm : The average service time (in milliseconds) for I/O requests that were issued to the device
    * %util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.

  
Device:     rrqm/s     wrqm/s     r/s     w/s     rsec/s       wsec/s     rkB/s         wkB/s         avgrq-sz     avgqu-sz     await     svctm     %util
cciss/c0d0     2269.60 132.60     296.20     77.60     20521.60  1681.60     10260.80     840.80         59.40         4.15         11.18     2.65     99.20



Citrix Xen VM:
Open properties of VM,, select "Startup Options", change "OS Boot Parameters" to "rw init=/bin/bash", graphical utf8reboot, you get  # prompt... if want to edit some files...graphical utf8

graphical utf8

run this command:
# mount -w -o remount / 
# now edit files you want... and reboot... 

#### mysql query to backup table contents into a file.
mysql#> select id,user,subject,content,status,sentdate,last_update from tickets where type='PRODUCT' into outfile '/tmp/product_ticket' fields terminated by '~' lines terminated by '|~|';

 

Mysql check
mysqlcheck -u root -p --auto-repair -c  -o -A

Repair Mysql MYISAM files..
/myisamchk --force --sort_buffer_size=64M --key_buffer_size=16M --read_buffer_size=8M --write_buffer_size=8M ../data/phplists/phplist_linktrack.MYI


mysql INNODB related
mysql> #SELECT TABLE_SCHEMA, TABLE_NAME, CONCAT(ROUND(data_length / ( 1024 * 1024 ), 2), 'MB') DATA, CONCAT(ROUND(data_free / ( 1024 * 1024 ), 2), 'MB')FREE from information_schema.TABLES where TABLE_SCHEMA='man' and table_name='result10' and Data_free > 0;
mysql> select TABLE_SCHEMA, TABLE_NAME  from information_schema.TABLES where TABLE_SCHEMA='man';


 ALTER TABLE `pass11` ENGINE = InnoDB   (this will also refragment innodb table)


ext4 disable journal

At one high loaded web project I needed a very fast file system. I decided to use Ext4 with disabled journal (As a google:))).

# Create ext4 fs on /dev/sda10 disk
mkfs.ext4 /dev/sda10

# Enable writeback mode. This mode will typically provide the best ext4 performance.
tune2fs -o journal_data_writeback /dev/sda10

# Delete has_journal option
tune2fs -O ^has_journal /dev/sda10

# Required fsck
e2fsck -f /dev/sda10

# Check fs options
dumpe2fs /dev/sda10 |more

For more performance add fstab opions: data=writeback,noatime,nodiratime
i.e:
/dev/sda10 /opt ext4 defaults,data=writeback,noatime,nodiratime 0 0

Tested at non-boot partition ;)


Redirect port request internally using IPTABLES
# iptables -I PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
 
# rpm -q --provides openssl 
 
 
To check which users are connected to ftp servers, make the below entrt in vsftpd.conf
setproctitle_enable=YES

restart vsftpd  and run command
# ps -fe | grep ftp


to restrict users to time based login in system and ftp server

edit /etc/pam.d/vsftpd and add below line just after ending auth section

session    optional     pam_keyinit.so    force revoke
auth       required    pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
auth       required    pam_shells.so
auth       include    system-auth
account    required     pam_time.so
account    include    system-auth
session    include    system-auth
session    required     pam_loginuid.so


now edit /etc/security/time.conf and add below line at end.

vsftpd;*;mayankg;!Al1000-1900


Done
 

Tuesday, March 13, 2012

STORE SSH KEYS IN LDAP


We need password less ssh login, so here i have tried to make the keys centralized by storing them in LDAP


LDAP Server Setup


[root@ldap]#  yum install openldap{,-clients,-devel,} nss_ldap


make entry in /etc/hosts

192.168.1.3    directory.domain.com

Thursday, March 1, 2012

DNS QUERY TIMEOUT ON LINUX CLIENT

Hi all, here i have come with a situation, when we have multiple DNS, basically Nameserver entry in resolve.conf at client, and sometimes we also face dam slow resolves in queries, this is may also due to DNS server issue, may be DNS has gone away or some other issues that is making it slow to resolve queries.By default, linux client attempts 3 times to Nameserver for queries. Here it make the process slow.
So what we can do, is to set timeout in resolve.conf, this will help client to choose another Nameserver for AnswersHere we go:

Friday, December 23, 2011

Multiple Purpose Expect Script

DISK ALERT - Expect ScriptHi All, here's I have bring a expect script, that this we can Run command on Remote Linux Servers, copy file using SSHSo here it is:
[root@virtual-vm ~]#  yum install expect  (if expect package is not installed)

Monday, November 14, 2011

MPM-Apache-settings

Worker based


StartServers             5
ServerLimit             16
ThreadLimit             35
MaxClients             560
MinSpareThreads         25
MaxSpareThreads         75
ThreadsPerChild         35
MaxRequestsPerChild  25000


Prefork Based:



StartServers          15
MinSpareServers       15
MaxSpareServers       35
MaxClients           100
MaxRequestsPerChild 2500




StartServers         2
MaxClients         150
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0


# perchild MPM
# NumServers: constant number of server processes
# StartThreads: initial number of worker threads in each server process
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# MaxThreadsPerChild: maximum number of worker threads in each server process
# MaxRequestsPerChild: maximum number of connections per server process

NumServers           5
StartThreads         5
MinSpareThreads      5
MaxSpareThreads     10
MaxThreadsPerChild  20
MaxRequestsPerChild  0


# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum  number of requests a server process serves

ThreadsPerChild 250
MaxRequestsPerChild  0


# BeOS MPM
# StartThreads: how many threads do we initially spawn?
# MaxClients:   max number of threads we can have (1 thread == 1 client)
# MaxRequestsPerThread: maximum number of requests each thread will process

StartThreads               10
MaxClients                 50
MaxRequestsPerThread       10000


# NetWare MPM
# ThreadStackSize: Stack size allocated for each worker thread
# StartThreads: Number of worker threads launched at server startup
# MinSpareThreads: Minimum number of idle threads, to handle request spikes
# MaxSpareThreads: Maximum number of idle threads
# MaxThreads: Maximum number of worker threads alive at the same time
# MaxRequestsPerChild: Maximum  number of requests a thread serves. It is
#                      recommended that the default value of 0 be set for this
#                      directive on NetWare.  This will allow the thread to
#                      continue to service requests indefinitely.                        

ThreadStackSize      65536
StartThreads           250
MinSpareThreads         25
MaxSpareThreads        250
MaxThreads            1000
MaxRequestsPerChild      0
MaxMemFree             100


# OS/2 MPM
# StartServers: Number of server processes to maintain
# MinSpareThreads: Minimum number of idle threads per process,
#                  to handle request spikes
# MaxSpareThreads: Maximum number of idle threads per process
# MaxRequestsPerChild: Maximum number of connections per server process

StartServers           2
MinSpareThreads        5
MaxSpareThreads       10
MaxRequestsPerChild    0

Thursday, November 10, 2011

URL Rewriting - Examples



Apache Rewrite Rules can be used to transform a pretty ugly looking URL into a beautiful, SEO-friendly and meaningful URL. I would like to list a couple of real-world examples below to explain how Rewrite Rules can be set up and how they work. Rewrite Rules use Regular Expressions, so this article is closely related to my Regular Expressions article.

Tuesday, November 1, 2011

Load Balance Mysql Slaves Using MySQLProxy

I am sure you all have read about MySQL replication, like Master-Master, Single Master - Multiple Slaves and their topologies.
Here I am going to describe how you can load balance several MySQL Slaves and query logging.

Friday, August 12, 2011

Report Developer's About Error/Warning in Codes from Apache Logs

This is just a scenario i got it in mind, Reporting Warning/Error  to Developer(s), using a PERL script, this you can also be done using SHELL Script.

Tuesday, March 15, 2011

Monitor PostgreSQL with Queries

(Not All written by me.... )Some time just monitoring a DB servers from monitoring tools is just not enough, in that case we need some tool that let us know, what is DB is holding, processing, parameters etc..

Tuesday, February 22, 2011

Some Useful Quotes


Block Size:
The block size specifies size, that the file system, will use to Read and Write data. Larger block sizes will help improve disk I/O performance when using large files, such as Databases.
Mostly of size 1024, need to be 4096 for bigger file support like in database server case.

Block Size: Different Terms
1: Hardware Block Size = Sector Size
2: File System Block Size = Block Size
3: Kernel Buffer Block Size = Block Size
4: Partition Table Block Size = Cylinder Size
----------------------------------------------------------------------------------------------

MyISAM tables support concurrent inserts. If a MyISAM table has no holes in the middle resulting from deleted or updated records, inserts always take place at the end of the table and can be performed while other clients are reading the table. Concurrent inserts can take place even for a table that has been read-locked explicitly if the locking client acquired a READ LOCAL lock rather than a regular READ lock. If a table does have holes, concurrent inserts cannot be performed. However, you can remove the holes by using OPTIMIZE TABLE to defragment the table.
----------------------------------------------------------------------------------------------

Clustered Index: Clustered index physically rearrange the data that users inserts in your tables. It is nothing but a dictionary type data where actual data remains.
Non-Clustered Index: It Non-Clustered Index contains pointers to the data that is stored in the data page. It is a kind of index backside of the book where you see only the reference of a kind of data.
----------------------------------------------------------------------------------------------

To change the default size limit for MyISAM tables, set the myisam_data_pointer_size, which sets the number of bytes used for internal row pointers. The value is used to set the pointer size for new tables if you do not specify the MAX_ROWS option. The value of myisam_data_pointer_size can be from 2 to 7. A value of 4 permits tables up to 4GB; a value of 6 permits tables up to 256TB.

You can check the maximum data and index sizes by using this statement:

SHOW TABLE STATUS FROM db_name LIKE 'tbl_name';
----------------------------------------------------------------------------------------------

Both InnoDB and PostgreSQL - as well as many other databases - use a technique called multi-version concurrency control (MVCC) to provide transaction isolation: transactions should not see the work of other, uncommitted transactions.  MVCC means that, when a row is updated, the database stores both the old and new versions of the row.
----------------------------------------------------------------------------------------------

Tuesday, February 8, 2011

todays quote

Block Size:
The block size specifies size, that the file system, will use to Read and Write data. Larger block sizes will help improve disk I/O performance when using large files, such as Databases.
Mostly of size 1024, need to be 4096 for bigger file support like in database server case.

Block Size: Different Terms
1: Hardware Block Size = Sector Size
2: File System Block Size = Block Size
3: Kernel Buffer Block Size = Block Size
4: Partition Table Block Size = Cylinder Size
----------------------------------------------------------------------------------------------------------------------------------------------------
MyISAM tables support concurrent inserts. If a MyISAM table has no holes in the middle resulting from deleted or updated records, inserts always take place at the end of the table and can be performed while other clients are reading the table. Concurrent inserts can take place even for a table that has been read-locked explicitly if the locking client acquired a READ LOCAL lock rather than a regular READ lock. If a table does have holes, concurrent inserts cannot be performed. However, you can remove the holes by using OPTIMIZE TABLE to defragment the table.
----------------------------------------------------------------------------------------------------------------------------------------------------
Clustered Index: Clustered index physically rearrange the data that users inserts in your tables. It is nothing but a dictionary type data where actual data remains.
Non-Clustered Index: It Non-Clustered Index contains pointers to the data that is stored in the data page. It is a kind of index backside of the book where you see only the reference of a kind of data.
----------------------------------------------------------------------------------------------------------------------------------------------------

To change the default size limit for MyISAM tables, set the myisam_data_pointer_size, which sets the number of bytes used for internal row pointers. The value is used to set the pointer size for new tables if you do not specify the MAX_ROWS option. The value of myisam_data_pointer_size can be from 2 to 7. A value of 4 permits tables up to 4GB; a value of 6 permits tables up to 256TB.

You can check the maximum data and index sizes by using this statement:

SHOW TABLE STATUS FROM db_name LIKE 'tbl_name';
----------------------------------------------------------------------------------------------------------------------------------------------------

Both InnoDB and PostgreSQL - as well as many other databases - use a technique called multi-version concurrency control (MVCC) to provide transaction isolation: transactions should not see the work of other, uncommitted transactions.  MVCC means that, when a row is updated, the database stores both the old and new versions of the row.
----------------------------------------------------------------------------------------------------------------------------------------------------

Monday, January 24, 2011

Purge Bin_Logs, Save Disk Space - Mysql



Purge Bin_Logs Save Disk Space


Oftenly i meet with a question in mysql that, "How can I remove old mysql-bin log file in log directory?"

So here is the way... sort, good and practically proved.

Friday, January 21, 2011

Block Proxied IPs From Apache

Few days back i was fighting with a issue.. some one leached our website and showing my website contents on his domain.
Now my seniors start worrying about their product, and it was obvious.
I started digging out some methods.. and started playing with some settings.. like
some apache directives..