You can check total records in a table by query information_schema, will help lot when you have lot’s of records in your table. You can query table directly to get total records (using select count(*) from table;) but this query will take some time to get the results depends upon total number of records in Read More…
Check total records in table using information_schema
March 6th, 2013 by Manoj Chauhan View Comments »Connection distribution host and db wise in Mysql
February 14th, 2013 by Manoj Chauhan View Comments »We can check connection distribution host and db wise in Mysql server using blow query, which will give full view of all connections coming to Mysql server. mysql> SELECT SUBSTRING(HOST,1,13) SOURCE_HOST,DB,COUNT(*) FROM PROCESSLIST GROUP BY SOURCE_HOST,DB; +—————+———————+———-+ | SOURCE_HOST | DB | COUNT(*) | +—————+———————+———-+ | | NULL | 2 | | 192.168.1.12 | mysql Read More…
Setup MongoDB master/slave replication
February 5th, 2013 by Manoj Chauhan View Comments »You can setup MongoDB master/slave replication after installing mongo DB server using the my previous post mongo DB. I tested with 1 master and 2 Slaves. Login to Master Server vim /etc/mongod.conf #where to log logpath=/var/log/mongo/mongod.log logappend=true # fork and run in background fork = true port = 27017 dbpath=/var/lib/mongo # location of pidfile pidfilepath Read More…
Installing MongoDB in CentOS
February 5th, 2013 by Manoj Chauhan View Comments »I setup mongo DB server using 10gen 64 bit repository by doing following steps Configure Package Management System (YUM) Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository. If you are running a 64-bit system (recommended,) place the following configuration in /etc/yum.repos.d/10gen.repo file: [10gen] name=10gen Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 gpgcheck=0 enabled=1 Installing Packages yum install mongo-10gen Read More…
Nagios monitor for Nginx
February 4th, 2013 by Manoj Chauhan View Comments »We have TCP monitors in our production which checks for service up/down using check_http or check_tcp Nagios plugin but not giving full details like how many connections are handled by the Nginx etc… We enable stub_status options in Nginx, it will provide information about the current state of the Nginx server. Stub status* Provide server Read More…
Nginx log rotation
February 2nd, 2013 by Manoj Chauhan View Comments »I wanted to start cycling my previous nginx log files, as logs were getting a little large. NGINX doesn’t have built in support for log rotation, there is a system level linux command called logrotate that handles this. I have setup Nginx log rotation using below cron which will run every 2 hours 1. Setup Read More…
How to change collation for Specific databases in Prod Mysql Server
January 28th, 2013 by Manoj Chauhan View Comments »To update all the databases in server We recently learnt that if you do not want MySQL to read å as an a or ö as an o, you need to use the uft8_bin collation. Some of our customers are in Norway and Finland and they require these “non-English” characters to be ordered correctly. Migration Read More…
Objective C Coding standard and formatting…
January 21st, 2013 by subrat View Comments »To get some coding standards for the Objective C I am mentioning some coding standard which I use . 1)Member Variables Should Be @private: Member variables should be declared @private. 2)Don’t initialize variables to 0 or nil in the init method; it’s redundant. All memory for a newly allocated object is initialized to 0 (except Read More…
Mass killing of MySQL Connections
November 17th, 2012 by Manoj Chauhan View Comments »Most of time I run into situation when I need to kill a lot of connections (running quries) on MySQL server – for example hundreds of instances of some bad query is running making server unusable. You can achieve this by performing below action. 1. [root@Mysql ~]# mysql -u user -Bse “show processlist” | grep Read More…
Defragmentation of multiple databases in Mysql
May 13th, 2012 by Manoj Chauhan View Comments »What does table fragmentation mean? This means that there is free data taking up space within each of these tables. This can eventually lead to storage and performance issues. As our database keep growing, we recognized that the database was getting slower and slower, so we decided to defrag all the tables in all databases. Read More…
How to scalable your application using nosql
May 10th, 2012 by Manoj Chauhan View Comments »How to scalable your application Most of the scalable application on web use MYSQL+memcached+varnish cache as the back end for their applications. Recently some of them shifted to NOSQL for one of the biggest reason ‘performance’. Certainly, NOSQL performs better than MYSQL for simple queries and primary key look-ups. Most of the database queries of Read More…
Scheduling Algorithms used by the Load Balancer
May 6th, 2012 by Manoj Chauhan View Comments »Following scheduling algorithms listed below: Round-Robin Scheduling: Distributes each request sequentially around the pool of real servers. Using this algorithm, all the real servers are treated as equals without regard to capacity or load. Weighted Round-Robin Scheduling: Distributes each request sequentially around the pool of real servers but gives more jobs to servers with greater Read More…
Rotating mysql slow query log
May 2nd, 2012 by Manoj Chauhan View Comments »The best practice is to rotate this file daily. In addition you should both analyze the log file producing a top 5 or top 10 list of slow SQL queries each day. You can rotate logs using below script. #/bin/bash SLOW_LOGS_PATH=/var/logs/logs/log-slow-queries.log echo “Rotating slow logs, please wait….” cp ${SLOW_LOGS_PATH} ${SLOW_LOGS_PATH}.`date +%d-%m-%Y-%H:%M:%S`; > ${SLOW_LOGS_PATH} Thanks Manoj
Slave: received end packet from server, apparent master shutdown
April 21st, 2012 by Manoj Chauhan View Comments »I was seeing this message continuously in mysql logs. It is a master-master with one slave setup in which one node had inconsistent tables. I tried to patch this by running a dump on the known-good server and importing that to the broken server + starting slave thread. Below was the result: [root@db-server tmp]# tail Read More…
How to take backup of selective tables in Mysql?
April 14th, 2012 by Manoj Chauhan View Comments »We can take the backup of selective tables using mysqldump command in mysql. It will help when we have big database like 400G and we want to do quick backup of some tables for i in `mysql -h 192.168.1.1 -u manoj -pmanoj testdb -e ‘show tables’ ` do echo $i; mysqldump -t -u manoj -pmanoj Read More…