background preloader

Data_mining

Facebook Twitter

Eliminating Duplicate Records From MySQL Tables. Any­one who works with data­base dri­ven devel­op­ment to any extent, will occa­sion­ally run into a sit­u­a­tion where dupli­cate infor­ma­tion is added to their data­base. I have per­son­ally run into such a prob­lem on many occa­sions since I started work­ing with data­base dri­ven software. Being able to quickly undo data cor­rup­tion is extremely impor­tant in pro­duc­tion data­bases. As much as we like to have a per­fect pro­duc­tion envi­ron­ment; it is often very dif­fi­cult to do ded­i­cate the time and resources nec­es­sary to avoid all mistakes.

The fol­low­ing exam­ple is a great way to remove dupli­cates, based upon a set of fields. Let’s say you have the fol­low­ing table: In this exam­ple, the fields which you do not want dupli­cated are as follows: In remove dupli­cates on those three fields, to where there is only one record in the data­base with the same val­ues for each of those three fields, you would do the following: Locating Duplicate Entries in a MySQL Table. If you don’t have unique indexes on your table, it is likely that you will occa­sion­ally have entries that are dupli­cated. This can often hap­pen because of a soft­ware bug or pos­si­bly a user error. Some appli­ca­tions even choose not to have unique indexes for per­for­mance rea­sons; though this hap­pens at the cost of data integrity.

The best I know of, to demon­strate how to locate the dupli­cate entries, is to use an exam­ple. So let’s say you have the fol­low­ing table: In this exam­ple, let’s say you want the fol­low­ing field set to have a unique com­bi­na­tion of val­ues. Well, let’s say that you are con­cerned about hav­ing dupli­cate val­ues in your data. In the exam­ple you group by the list of fields that you want to use as your com­pos­ite key and select the fields you want to see in your out­put. What we have in this exam­ple is four of each of these records which are sup­posed to be unique.

Copying Yesterday’s Exceptions with Stack Traces from Logs, Then. When you have a java appli­ca­tion server which gen­er­ates a great deal of logs, it can be tricky to find the most impor­tant infor­ma­tion, espe­cially if you have detailed log­ging. For­tu­nately grep is capa­ble of doing this very well. The fol­low­ing com­mand will gather all WARN , ERROR , FATAL , and Excep­tion stack traces . This com­mand can be very use­ful for Java log mon­i­tor­ing scripts. cat /jboss-4.0.2/server/default/log/server.log | grep "ERROR\|FATAL\|Exception\|at.*\.java\:.

*" Under­stand­ing this expression In this expres­sion ‘\|’ is used as an OR oper­a­tor to look for dif­fer­ent pat­terns. Fil­ter­ing by Date: Yesterday’s Logs If you want to fil­ter the log­files after a cer­tain date, the fol­low­ing com­mand is very use­ful. Cat /jboss-4.0.2/server/default/log/server.log | sed "1,/$(date --date='yesterday' '+%Y-%m-%d')/d" Putting it All Together Daily Log Monitor Script to Email Error Stack Traces to the Administrator #!

How To Repair MySQL Replication | HowtoForge - Linux Howtos and. Version 1.0 Author: Falko Timme <ft [at] falkotimme [dot] com> Last edited 05/29/2008 If you have set up MySQL replication, you probably know this problem: sometimes there are invalid MySQL queries which cause the replication to not work anymore. In this short guide I explain how you can repair the replication on the MySQL slave without the need to set it up from scratch again.

I do not issue any guarantee that this will work for you! 1 Identifying The Problem To find out whether replication is/is not working and what has caused to stop it, you can take a look at the logs. On Debian, for example, MySQL logs to /var/log/syslog: grep mysql /var/log/syslog server1:/home/admin# grep mysql /var/log/syslog May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Slave: Error 'Table 'mydb.taggregate_temp_1212047760' doesn't exist' on query. You can see what query caused the error, and at what log position the replication stopped. mysql -u root -p On the MySQL shell, run: mysql> mysql> STOP SLAVE; SYSSTAT - Linux Monitoring Packages. Documentation Some of the following notes come from the Linux From Scratch documentation. Introduction to sysstat The sysstat package contains utilities to monitor system performance and usage activity.

Sysstat contains various utilities, common to many commercial Unixes, and tools you can schedule via cron to collect and historize performance and activity data. Iostat(1) reports CPU statistics and input/output statistics for devices, partitions and network filesystems. mpstat(1) reports individual or combined processor related statistics. pidstat(1) reports statistics for Linux tasks (processes) : I/O, CPU, memory, etc. sar(1) collects, reports and saves system activity information (CPU, memory, disks, interrupts, network interfaces, TTY, kernel tables,etc.) sadc(8) is the system activity data collector, used as a backend for sar. Sa1(8) collects and stores binary data in the system activity daily data file. It is a front end to sadc designed to be run from cron. . $ . Enter ". $ . PHP-LDAP-Admin: LDAP Administration Console.

Oracle Session.