Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Wednesday, March 17, 2010

Is MySQL support Julian Dates?

I use it in Oracle and notice there are 10 days missed, for example:

ORCL> select to_date('4/10/1582','dd/mm/yyyy') SHOW_DATE from dual

SHOW_DATE
--------------
04/10/1582

ORCL> select to_date('4/10/1582','dd/mm/yyyy') + 1 SHOW_DATE from dual

SHOW_DATE
--------------
15/10/1582

Say What? the date after 4/10/1582 is 15/10/1582.

But in MySQL i try it but i didn't see this case, example:


mysql> select adddate('1582-10-04', interval 0 day);
+---------------------------------------+
| adddate('1582-10-04', interval 0 day) |
+---------------------------------------+
| 1582-10-04                            |
+---------------------------------------+
1 row in set (0.00 sec)

mysql> select adddate('1582-10-04', interval 1 day);
+---------------------------------------+
| adddate('1582-10-04', interval 1 day) |
+---------------------------------------+
| 1582-10-05                            |
+---------------------------------------+
1 row in set (0.00 sec)

Ohhh its not like Oracle!!!


So Why? Is MySQL support Julian dates?

Tuesday, February 23, 2010

Can I use latin1 to store utf8 data?

I've table contains text column and its charset is latin1, and i can store Arabic text ( and non English character) in this column and retrieve it, i don't know how is it?

So how is that? and why I need utf8?

CREATE TABLE `post` (
`postid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`threadid` int(10) unsigned NOT NULL DEFAULT '0',
`parentid` int(10) unsigned NOT NULL DEFAULT '0',
`username` varchar(100) NOT NULL DEFAULT '',
`userid` int(10) unsigned NOT NULL DEFAULT '0',
`title` varchar(250) NOT NULL DEFAULT '',
`dateline` int(10) unsigned NOT NULL DEFAULT '0',
`pagetext` mediumtext NOT NULL,
`allowsmilie` smallint(6) NOT NULL DEFAULT '0',
`showsignature` smallint(6) NOT NULL DEFAULT '0',
`ipaddress` varchar(15) NOT NULL DEFAULT '',
`iconid` smallint(5) unsigned NOT NULL DEFAULT '0',
`visible` smallint(6) NOT NULL DEFAULT '0',
`attach` smallint(5) unsigned NOT NULL DEFAULT '0',
`importthreadid` bigint(20) NOT NULL DEFAULT '0',
`importpostid` bigint(20) NOT NULL DEFAULT '0',
`infraction` smallint(5) unsigned NOT NULL DEFAULT '0',
`reportthreadid` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`postid`),
KEY `userid` (`userid`),
KEY `threadid` (`threadid`,`userid`),
KEY `datline_idx` (`dateline`),
KEY `threadid_date` (`threadid`,`dateline`),
FULLTEXT KEY `title` (`title`,`pagetext`)
) ENGINE=MyISAM AUTO_INCREMENT=32451742 DEFAULT CHARSET=latin1

Sunday, January 10, 2010

Pass application user id to MySQL database??

In all our application we connect to MySQL database as single db user, and we need to pass the end user id to the mysql database?

So how can we pass it?

I've idea to create plugin to add mysql variables ex. "app_userid" and set it when user login??!!

but i don't have any idea how to create plugin?

Or do you have another idea??

Note: i don't want to change the application code, and i need it portable.

Thursday, October 01, 2009

Update: Find Query Per certain Seconds

In my old post there is a bug when run in MySQL 5.1.30 and old, because the status variable Queries was added in MySQL 5.1.31. So i change to choose between Queries and Questions status variables, and I think the Queries represent more accurate result.

http://forge.mysql.com/tools/tool.php?id=217

By the way:

# Queries
The number of statements executed by the server. This variable includes statements executed within stored programs, unlike the Questions variable. This variable was added in MySQL 5.1.31.

# Questions
The number of statements executed by the server. As of MySQL 5.1.31, this includes only statements sent to the server by clients and no longer includes statements executed within stored programs, unlike the Queries variable.


Sponsored by Hosting.com, provider of San Fransisco colocation services

Thursday, July 30, 2009

Find Query Per certain Seconds

Do you need to find qps for peak hours not avg qps through mysql life.


The MySQL 5.1 offers new GLOBAL_STATUS information schema tables. These can be used to report certain performance metrics, such as the number of queries processed per certain seconds, NOT overall avg queries per second, Its good to know how much qps in peak hours.

http://forge.mysql.com/tools/tool.php?id=217

Thursday, July 09, 2009

Threads with "freeing items", "Sending data" and "Locked" never finish

In one of the servers we have an issue that happens to one of the servers that some items
that have the status of "freeing items" and "Sending data" are just stuck there, causing a
lot of locks on the server, and the load of the server drops to almost 0.

The server then wouldn't restart, and the only solution is to kill the mysqld process, and
fix the crashed tables that result from the kill.

How to repeat:
There is no specific knowledge of when does this happens or why, but it happens like once
every 3 days.

Solution:
turn query cache off.

to follow up see: http://bugs.mysql.com/bug.php?id=45544

Tuesday, June 16, 2009

InnoDB tablespace, single Vs. multiple, and InnoDB defragment

The ibdata file is too big 10GB, and actually we've only about 2GB (data+index) in innodb storage engine.

How we can defragment this file and reduce it?

How is this happened?


By default the ibdata file created initially by (innodb_data_file_path = ibdata1:10M:autoextend) and auto extended by (innodb_autoextend_increment = 8MB) when it’s needed, and this file (tablespace) contain all innodb tables (innodb_file_per_table=OFF) single tablespace.

In this configuration the file will too big, especially when u need to test something in innodb engines and create a lot of innodb tables.

another problem if you truncate or delete all or some data the ibdata file will not decrease size, and when optimize the table the data part of this table will optimize but still there are gaps between tables in tablespace.


In my case:

ibdata file in 10GB and the total sum of (data_length+index_length) of all innodb tables not exceed 2GB!!!!!!!!!!

OS and I/O manipulate with 10GB file but we need only 2GB in worst case!!!!!

If we set innodb_file_per_table=ON then alter all innodb tables, mysql will generate ibdata for each table with its size, its good!!!, but the shared tablespace still exist (10GB) and cannot delete it (it’s necessary even innodb_file_per_table enable or disable) BAD!!!!!!


The Solution:

1- Get all innodb tables in your database:
Select table_name, table_schema from information_schema.tables where engine = 'innodb';

Convert all to myisam by using: alter table table_name engine myisam;
2- Then shutdown mysql.

Till now ibdata file same size 10GB

3- Rename or move to another directory ibdata and ib_log files.
Check this global variables innodb_data_home_dir and innodb_log_group_home_dir to know where are there.

4- Add innodb_file_per_table to cnf file.

5- Then start mysql

mysql will create ibdata file with default size 10MB, and ib_logfile0 and ib_logfile1 (logs).

6- Return back tables to innodb by using: alter table table_name engine innodb;

mysql will create file for each table in database directory.


See this scenario:

My.cnf
innodb_additional_mem_pool_size = 128M
innodb_buffer_pool_size = 2G
innodb_log_buffer_size = 16M
innodb_log_file_size = 16M
innodb_file_per_table


note:
this [user@server~]$ in shell command
and this mysql> in mysql command
in sequence order

mysql> create table musers_test like musers;
Query OK, 0 rows affected (0.02 sec)

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 432K Jun 16 06:28 /var/lib/mysql/test_db/musers_test.ibd

mysql> insert into musers_test select * from musers limit 500000;
Query OK, 500000 rows affected, 1 warning (1 min 12.43 sec)
Records: 500000 Duplicates: 0 Warnings: 0

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 368M Jun 16 06:31 /var/lib/mysql/test_db/musers_test.ibd

mysql> delete from musers_test;
Query OK, 500000 rows affected (1 min 26.64 sec)

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 368M Jun 16 06:34 /var/lib/mysql/test_db/musers_test.ibd

mysql> insert into musers_test select * from musers limit 500000;
Query OK, 500000 rows affected, 1 warning (2 min 58.44 sec)
Records: 500000 Duplicates: 0 Warnings: 0
/* notice the execution time is double previous insert (from 1 min 12.43 sec to 2 min 58.44 sec) */

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 416M Jun 16 06:38 /var/lib/mysql/test_db/musers_test.ibd

mysql> alter table musers_test;
Query OK, 0 rows affected (0.00 sec)

/* decrease file size because innodb_file_per_table=ON */
[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 368M Jun 16 06:43 /var/lib/mysql/test_db/musers_test.ibd

mysql> delete from musers_test;
Query OK, 500000 rows affected (1 min 2.82 sec)

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 368M Jun 16 06:47 /var/lib/mysql/test_db/musers_test.ibd

mysql> alter table musers_test engine innodb;
Query OK, 0 rows affected (5.91 sec)
Records: 0 Duplicates: 0 Warnings: 0

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 432K Jun 16 06:48 /var/lib/mysql/test_db/musers_test.ibd

mysql> insert into musers_test select * from musers limit 5000;
Query OK, 5000 rows affected, 1 warning (1.18 sec)
Records: 5000 Duplicates: 0 Warnings: 0

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 13M Jun 16 06:49 /var/lib/mysql/test_db/musers_test.ibd

mysql> delete from musers_test limit 4000;
Query OK, 4000 rows affected, 1 warning (0.52 sec)

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 13M Jun 16 06:49 /var/lib/mysql/test_db/musers_test.ibd

mysql> alter table musers_test engine innodb;
Query OK, 1000 rows affected (0.37 sec)
Records: 1000 Duplicates: 0 Warnings: 0

[user@server~]$ ll -h /var/lib/mysql/test_db/musers_test.ibd
-rw-rw---- 1 mysql mysql 9.0M Jun 16 06:50 /var/lib/mysql/test_db/musers_test.ibd

also you can run shel command from mysql as mysql> \! ls -lh /var/lib/mysql/test_db/musers_test.ibd


Regards,
Mohammad Lahlouh
:)

Thursday, June 04, 2009

vBulletin, session table is InnoDB

In large vBulletin forum we had strange problem in memory table "session", we've 25M post, 1.7M user, 20K online user.

So we change engine of session table to InnoDB and set configuration of innoDB as follow (be careful this configuration is not proper for other tables because this is good in performance but bad in crash and recovery, and data reliability)

innodb_data_home_dir = /dev/shm/mysql/ #this path in memory partition
innodb_log_group_home_dir = /dev/shm/mysql/
innodb_flush_method = O_DIRECT
innodb_support_xa = 0
innodb_thread_concurrency = 20
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_lock_wait_timeout = 50
innodb_flush_log_at_trx_commit = 0
innodb_doublewrite = 0

thanks

any comment?

UPDATE:


In this configuration when restart MySQL in error log will see:

090620 1:20:06 InnoDB: Failed to set O_DIRECT on file /dev/shm/mysql/ibdata1: OPEN: Invalid argument, continuing anyway
090620 1:20:06 InnoDB: O_DIRECT is known to result in 'Invalid argument' on Linux on tmpfs, see MySQL Bug#26662
090620 1:20:06 InnoDB: Failed to set O_DIRECT on file /dev/shm/mysql/ibdata1: OPEN: Invalid argument, continuing anyway
090620 1:20:06 InnoDB: O_DIRECT is known to result in 'Invalid argument' on Linux on tmpfs, see MySQL Bug#26662

So may be a bug with tmpfs and O_DIRECT!!!

see http://bugs.mysql.com/45671

Monday, April 20, 2009

Oracle to Buy Sun !!!

Sun and Oracle today announced a definitive agreement for Oracle to acquire Sun for $9.50 per share in cash. The Sun Board of Directors has unanimously approved the transaction. It is anticipated to close this summer.

What will happened in MySQL, JAVA.

I think its enough.

http://www.sun.com/aboutsun/pr/2009-04/sunflash.20090420.1.xml

Wednesday, April 15, 2009

Warning Aborted connection, log_warnings and wait_timeout

In my server error log i see

090415 10:55:57 [Warning] Aborted connection 481 to db: 'db' user: 'user' host: 'localhost' (Got timeout reading communication packets)
090415 10:56:16 [Warning] Aborted connection 582 to db: 'db' user: 'user' host: 'localhost' (Got timeout reading communication packets)
090415 11:05:13 [Warning] Aborted connection 2693 to db: 'db' user: 'root' host: 'localhost' (Got timeout reading communication packets)


every thread connected to mysql and sleep more than wait_timeout mysql will close it.

the previous warning depend on log_warnings level, by default log_warnings = 1, if its =2 all the closed connection will written in mysql error log.

I think we don't need this warning.;)

--log-warnings[=level], -W [level]

Option Sets Variable Yes, log-warnings
Variable Name log_warnings
Variable Scope Both
Dynamic Variable Yes
Disabled by skip-log-warnings
Value Set Type numeric
Default 1

Print out warnings such as Aborted connection... to the error log. Enabling this option is recommended, for example, if you use replication (you get more information about what is happening, such as messages about network failures and reconnections). This option is enabled (1) by default, and the default level value if omitted is 1. To disable this option, use --log-warnings=0. If the value is greater than 1, aborted connections are written to the error log. See Section B.1.2.11, “Communication Errors and Aborted Connections”.

If a slave server was started with --log-warnings enabled, the slave prints messages to the error log to provide information about its status, such as the binary log and relay log coordinates where it starts its job, when it is switching to another relay log, when it reconnects after a disconnect, and so forth.



wait_timeout

The number of seconds the server waits for activity on a non-interactive connection before closing it. This timeout applies only to TCP/IP and Unix socket file connections, not to connections made via named pipes, or shared memory.

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

Sunday, April 12, 2009

mysqlsla amazing tool

mysqlsla is interesting tool to analyze slow log query, aggregate same query in one and generate unique sql statement withCount, (max, min, avg) execute time, lock time, Rows sent, Rows examined for each unique one.

you can use it to review indexes and drop unused index, and create another.


Report for slow logs: slowquery1day.txt
791 queries total, 85 unique
Sorted by 't_sum'
Grand Totals: Time 23.05k s, Lock 2.18k s, Rows sent 24.17M, Rows Examined 120.61M


____________________________________________________________ 001 ___
Count : 355 (44.88%)
Time : 7588 s total, 21.374648 s avg, 11 s to 203 s max (32.92%)
95% of Time : 6352 s total, 18.848665 s avg, 11 s to 44 s max
Lock Time (s) : 675 s total, 1.901408 s avg, 0 to 191 s max (30.95%)
95% of Lock : 57 s total, 169.139 ms avg, 0 to 6 s max
Rows sent : 141 avg, 1 to 150 max (0.21%)
Rows examined : 37.17k avg, 24 to 310.07k max (10.94%)
Database : db_test
Users :
FrashaSlvReplic@ 70.84.164.205 : 92.11% (327) of query, 87.74% (694) of all users
Frashat_test@ 70.84.164.205 : 7.89% (28) of query, 5.44% (43) of all users

Query abstract:
SELECT post.postid, post.pagetext, ifnull( user.username , post.username ) AS username, dateline FROM noway_post AS post LEFT JOIN noway_user AS user ON (user.userid = post.userid) WHERE threadid = N AND visible = N AND post.userid NOT IN (N1) ORDER BY dateline ASC LIMIT N,N;

Query sample:
SELECT post.postid, post.pagetext, IFNULL( user.username , post.username ) AS username, dateline
FROM noway_post AS post
LEFT JOIN noway_user AS user ON (user.userid = post.userid)
WHERE threadid = 314734
AND visible = 1
AND post.userid NOT IN (28816)
ORDER BY dateline ASC
LIMIT 300,150;

_____________________________________________________________ 002 ___
Count : 90 (11.38%)
Time : 1840 s total, 20.444444 s avg, 11 s to 128 s max (7.98%)
95% of Time : 1445 s total, 17 s avg, 11 s to 35 s max
Lock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%)
95% of Lock : 0 total, 0 avg, 0 to 0 max
Rows sent : 25 avg, 0 to 25 max (0.01%)
Rows examined : 13.89k avg, 146 to 26.54k max (1.04%)
Database : db
Users :
FrashaSlvReplic@ 70.84.164.205 : 100.00% (90) of query, 87.74% (694) of all users

Query abstract:
SELECT COUNT(*) AS COUNT, threadid, MAX(dateline) AS lastpost FROM noway_post AS post WHERE post.userid = N AND post.visible = N AND post.threadid IN (N25) GROUP BY threadid;

Query sample:
SELECT COUNT(*) AS count, threadid, MAX(dateline) AS lastpost
FROM noway_post AS post
WHERE post.userid = 268569 AND
post.visible = 1 AND
post.threadid IN (0820005, 636923, 803089, 735659, 735645, 808314, 765143, 688062, 738500, 787405, 633043, 454061, 703866, 707968, 676619, 647881, 645328, 451514, 674289, 650001, 654712, 562233, 645180, 638518, 619261)
GROUP BY threadid;

_____________________________________________________________ 003 ___
Count : 15 (1.90%)
Time : 1574 s total, 104.933333 s avg, 21 s to 282 s max (6.83%)
95% of Time : 1292 s total, 92.285714 s avg, 21 s to 261 s max
Lock Time (s) : 47 s total, 3.133333 s avg, 0 to 42 s max (2.15%)
95% of Lock : 5 s total, 357.143 ms avg, 0 to 5 s max
Rows sent : 84 avg, 10 to 100 max (0.01%)
Rows examined : 69.30k avg, 1.03k to 219.67k max (0.86%)
Database : db
Users :
FrashaSlvReplic@ 70.84.164.205 : 100.00% (15) of query, 87.74% (694) of all users

Query abstract:
SELECT DISTINCT thread.threadid, thread.forumid, post.userid FROM noway_thread AS thread INNER JOIN noway_post AS post ON(thread.threadid = post.threadid ) WHERE MATCH(post.title, post.pagetext) AGAINST ('S') AND thread.forumid NOT IN (N20) AND thread.forumid IN(N1) AND post.visible = N LIMIT N;

Query sample:
SELECT
DISTINCT thread.threadid, thread.forumid, post.userid
FROM noway_thread AS thread
INNER JOIN noway_post AS post ON(thread.threadid = post.threadid )
WHERE MATCH(post.title, post.pagetext) AGAINST ('هذه الدنيا عجايب') AND thread.forumid NOT IN (0,38,41,117,55,94,99,100,72,39,42,43,57,44,37,26,40,27,34,53) AND thread.forumid IN(86) AND post.visible = 1
LIMIT 100;


http://hackmysql.com/mysqlsla

Wednesday, April 08, 2009

A Brief Introduction to MySQL Performance Tuning

Here are some common performance tuning concepts that I frequently run into. Please note that this really is only a basic introduction to performance tuning. For more in-depth tuning, it strongly depends on your systems, data and usage.

Server Variables

For tuning InnoDB performance, your primary variable is innodb_buffer_pool_size. This is the chunk of memory that InnoDB uses for caching data, indexes and various pieces of information about your database. The bigger, the better. If you can cache all of your data in memory, you’ll see significant performance improvements.

For MyISAM, there is a similar buffer defined by key_buffer_size, though this is only used for indexes, not data. Again, the bigger, the better.

Other variables that are worth investigating for performance tuning are:

query_cache_size - This can be very useful if you have a small number of read queries that are repeated frequently, with no write queries in between. There have been problems with too large a query cache locking up the server, so you will need to experiment to find a value that’s right for you.

innodb_log_file_size - Don’t fall into the trap of setting this to be too large. A large InnoDB log file group is necessary if you have lots of large, concurrent transactions, but comes at the expense of slowing down InnoDB recover, in event of a crash.

sort_buffer_size - Another one that shouldn’t be set too large. Peter Zaitsev did some testing a while back showing that increasing sort_buffer_size can in fact reduce the speed of the query.

Server Hardware

There are a few solid recommendations for improving the performance of MySQL by upgrading your hardware:

  • Use a 64-bit processor, operating system and MySQL binary. This will allow you to address lots of RAM. At this point in time, InnoDB does have issues scaling past 8 cores, so you don’t need to go out of your way to have lots of processors.
  • Speaking of RAM, buy lots of it. Enough to fit all of your data and indexes, if you can.
  • If you can’t fit all of your data into RAM, you’ll need fast disks, RAID if you can. Have multiple disks, so you can seperate your data files, OS files and log files onto different physical disks.

Query Tuning

Finally, though probably the most important, we look at tuning queries. In particular, we make sure that they’re using indexes, and they’re running quickly. To do so, turn on the Slow Query Log for a day, with log_queries_not_using_indexes enabled as well. Run the resulting log through mysqldumpslow, which will produce a summary of the log. This will help you prioritize which queries to tackle first. Then, you can use EXPLAIN to find out what they’re doing, and adjust your indexes accordingly.

Upgrading MySQL with minimal downtime through Replication

Problem

With the release of MySQL 5.1, many DBAs are going to be scheduling downtime to upgrade their MySQL Server. As with all upgrades between major version numbers, it requires one of two upgrade paths:

  • Dump/reload: The safest method of upgrading, but it takes out your server for quite some time, especially if you have a large data set.
  • mysql_upgrade: A much faster method, but it can still be slow for very large data sets.

I’m here to present a third option. It requires minimal application downtime, and is reasonably simple to prepare for and perform.

Preparation

First of all, you’re going to need a second server (which I’ll refer to as S2). It will act as a ’stand-in’, while the main server (which I’ll refer to as S1) is upgraded. Once S2 is ready to go, you can begin the preparation:

  • If you haven’t already, enable Binary Logging on S1. We will need it to act as a replication Master.
  • Add an extra bit of functionality to your backup procedure. You will need to store the Binary Log position from when the backup was taken.
    • If you’re using mysqldump, simply add the –master-data option to your mysqldump call.
    • If you’re using InnoDB Hot Backup, there’s no need to make a change. The Binary Log position is shown when you restore the backup.
    • For other backup methods, you will probably need to get the Binary Log position manually:
      mysql> FLUSH TABLES WITH READ LOCK;
      mysql> SHOW MASTER STATUS;
      (Perform backup now...)
      mysql> UNLOCK TABLES;

Once you have a backup with the corresponding Binary Log position, you can setup S2:

  • Install MySQL 5.1 on S2.
  • Restore the backup from S1 to S2.
  • Create the Slave user on S1.
  • Enter the Slave settings on S2. You should familiarise yourself with the Replication documentation.
  • Enable Binary Logging on S2. We’ll need this during the upgrade process.
  • Setup S2 as a Slave of S1:
    • If you used mysqldump for the backup, you will need to run the following query:
      mysql> CHANGE MASTER TO MASTER_HOST='S2.ip.address', MASTER_USER='repl_user', MASTER_PASSWORD='repl_password';
    • For any other method, you’ll need to specify the Binary Log position as well:
      mysql> CHANGE MASTER TO MASTER_HOST='S2.ip.address', MASTER_USER='repl_user', MASTER_PASSWORD='repl_password', MASTER_LOG_FILE='mysql-bin.nnnnnnn', MASTER_LOG_POS=mmmmmmmm;
  • Start the Slave on S2:
    mysql> START SLAVE;

The major pre-upgrade work is now complete.

Upgrade

Just before beginning the upgrade, take a backup of S2. For speed, I’d recommend running the following queries, then shutting down the MySQL server and copying the data files for the backup.

mysql> STOP SLAVE;
mysql> SHOW MASTER STATUS;

Once the backup is complete, restart S2 and let it catch up with S1 again.

When you’re ready to begin the upgrade, you will need a minor outage. Stop your application, and let S2 catch up with S1. Once it has caught up, they will have identical data. So, switch your application to using S2 instead of S1. Your application can continue running unaffected while you upgrade S1 server.

  • Stop the Slave process on S2:
    mysql> STOP SLAVE;
  • Stop S1.
  • Upgrade S1 to MySQL 5.1.
  • Move the S1 data files to a backup location.
  • Move the backup from S2 into S1’s data directory.
  • Start S2.
  • Setup S2 as a Slave to S1, same as when we made S1 a Slave of S2.
  • Let S2 catch up with S1. When it has caught up, stop your application, and make sure S2 is still caught up with S1.
  • Switch your application back to using S1.

Complete! Hooray! You just need to run a couple of queries on S1 to clean up the Slave settings:

mysql> STOP SLAVE;
mysql> CHANGE MASTER TO MASTER_HOST='';

Conclusion

You can keep the outage to only a few minutes while performing this upgrade, removing the need for potentially expensive downtime. If you need the downtime to be zero, you probably want to be looking at a Circular Replication system, though that’s getting a little outside of this blog post.

Tuesday, February 20, 2007

How to play Real audio and video files (*.rm) with Windows Media player!?

How to play Real audio and video files (*.rm) with Windows Media player!?
Because of competition between Microsoft and Real Networks, Windows Media Player does not support Real audio and video files, and real networks does not release any patch for WMP. But, Real has released a patch for other media players.
Now, I want learn you, how you can use this patch to play Real audio and video files.
You should have Windows Media Player and Real Player:
1- First go to sourceforge.net website and download RealMedia Splitter from guliverkli Project. to download directly go to:
http://sourceforge.net/project/showfiles.p...ackage_id=87719
2- Extract zipped file and copy it to your system directory:
Win9x: c:\windows\system
WinXP: c:\windows\system32
3-Click Start > Run > and type “regsvr32 realmediasplitter.ax” and then click Ok.
4-Run your Windows Media Player, select “any file(*.*)” from file type field and open a *.rm file, Windows Media Player will display an error message that the selected file has an extension that is not recognized by Windows Media Player. Select check box and press ok.
Now enjoy whit your Windows Media Player!?

To add *.rm extension to your WMP file type field :
Run Registry Editor and find following key :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer\Player\Extensions\Types
Double click on “1” and add *.rm to value data field.

NOTE : incorrectly editing the registry may damage your system. Before making changes please create a back up.

Saturday, January 13, 2007

Convert Flash Video (.flv) to AVI (.avi) or MPEG (.mpg) - lifehack.org

Convert Flash Video (.flv) to AVI (.avi) or MPEG (.mpg) - lifehack.org: "Convert Flash Video (.flv) to AVI (.avi) or MPEG (.mpg)

Hitrec at VideoHelp forum introduces a software called RivaFLVencoder which able you to convert .flv files (Flash Video) into avi and mpg files. This is extremely useful when you download youtube or google videos and you don’t like it play in flv player. With this conversion, you can play google videos in many systems, such as iPod Video. One catch: Most of the time, audio can be transcoded to the target format. However sometimes audio codec cannot not be transcoded, you can follow this instruction to mux that back into the target file:

… It’s possible that the .flv contains an audiocodec that will not be transcoded. A solution for that is to play the original .flv and record the audio with Audacity (for instance) and to mux that recording with the .avi or .mpg you get from Riva…"

How to Download Google Video - lifehack.org

How to Download Google Video

Okay, it is just not fun to play video online with slow Internet connection - to have smooth video playback, the best way it is still downloading the whole clip locally and playback. However Google Video does not provide a link for one to download. The movie is played by Google Video Player, which is Online Flash FLV player.

New Method: The easiest method now to download google video is to use online video download service to expose the real URL.

Old Method:
Good news is that Felipe Cepriano over at FelipeCN has found a quick way to download Google Video. The key is to unescape the parameter of the Google Player URL by using a javascript function. In simple instruction:

  • Go to Google Video and find a video.
  • View the page source code and search for the keyword ‘googleplayer‘
  • Copy and paste the videoUrl parameter (all of the characters after the keyword ‘videoUrl=’)
  • Press Ctrl-L to go to URL location bar. Type Javascript:unescape(”videoUrl”) where videoUrl should be the last parameter you have copied into the clipboard.
  • It should output the actual URL on the broswer, copy and paste that URL onto your browser location bar again to download the FLV movie.
  • Play it with a FLV Player.

Download Google Videos

Wednesday, December 20, 2006

How to plug JInitiator to Firefox...

I can run Oracle Forms on Mozilla Firefox.

1- Install JInitiator.
2- C:\Program Files\Oracle\JInitiator 1.1.8.19\bin\NPJinitXXXX.dll --XXXX = Version.
3- Paste it under this directory of Firefox(C:\Program Files\Mozilla Firefox\plugins).
4- Restart Firefox.

Wednesday, December 06, 2006

How to Disable Windows Login Screensaver

How to Disable Windows Login Screensaver

Have you ever been annoyed by the computer going into a screensaver before you've even logged in to it? This is a step-by-step guide to disabling this feature.

Steps

  1. Login to your computer as an amdinistrator account.
  2. Go to Start->Run
  3. Type regedit into the text box
  4. Navigate in the explorer like window to the section: HKEY_USERS -> .DEFAULT -> CONTROL PANEL -> DESKTOP
  5. Change the "ScreenSaveActive" value to 0 and "ScreenSaveTimeOut" value to 0


Tips

  • It is a good idea to backup the registry before you make any changes to it.
  • Do not edit any values in the registry unless you explicitly know what you are doing.


Warnings

  • Editing the registry can make you computer completely unusable and inaccessible.

How to Use Windows XP Built in Remote Desktop Utility

How to Use Windows XP Built in Remote Desktop Utility

This explains how to connect to another computer on your local network through Windows XP's built-in remote desktop utility.

Steps

  1. Remote Desktop must be enabled on all the computers to which you wish to connect. To ensure that it is enabled, follow these steps:
  2. Right click the My Computer icon on your desktop or start menu and click properties.
  3. Click the Remote tab at the top of the system properties window and check the box next to "Allow users to connect remotely to this computer."
  4. After you have completed these steps, you are ready to connect to another computer. Before you start, make sure both computers are turned on and connected to your Local Area Network (LAN). It also helps if you both have configured the same workgroup as your default, if you are not on a domain configuration. Most home networks are not on a domain.
  5. On the computer you will be connecting from click Start-->Run and type 'mstsc.' Press ENTER.
  6. Type the name of the computer you wish to connect to in the connection window.
  7. Log in using the username and password supplied by the computer owner. You can not sign into a Limited Account using Remote Desktop.


Tips

  • To find the name of the computer you wish to connect to log onto that computer and right click My Computer, click properties, and click the Computer name tab.
  • The computer you are connecting to must have a password (the login password cannot be blank).
  • If the computer name does not work, try using its IP address (see How To article)
  • Use Start/Settings/Control Panel/Systems icon if you don't have a My Computer icon on your desktop.

How to Convert Measurements Easily in Microsoft Excel

How to Convert Measurements Easily in Microsoft Excel

We've all been in a situation where we need to convert one measurement to another. An objects mass was measured in ounces and not kilos, or the lumber you ordered was measured in metres instead of feet, or someone is planning a trip to the USA and wants to know the speed limits in mp/h when they're used to km/h. There are a multitude of jobs where this is a daily task, some of them where measurements must be exact. Well, there is an easier way. There is a function in Microsoft Excel called CONVERT that will convert from one measurement system to another and all you have to do is specify the number and the measurement systems!

Steps

  1. Start Microsoft Excel
  2. The CONVERT function is not installed by default. It is part of the Analysis Add-in tool pack. To install add-ins, Click on the Tools menu, and click on Add-ins.
    The Add-ins command
    The Add-ins command
  3. You will need to put in a checkmark beside Analysis Toolpak.
    The Analysis toolpak
    The Analysis toolpak
  4. Depending on how Microsoft Office was installed, you may be asked to provide the install CD.
  5. The other add-ins are worth installing, most notably Solver, but they are beyond the scope of this article.
  6. The CONVERT function is now installed. Let's test it by converting miles to kilometres
  7. Type =CONVERT(60,"mi","km"). You should get a number around 100 (CONVERT returned 97, for the record).
  8. A complete listing of measurement units that the CONVERT function supports is available from Microsoft Office Online