Sunday, August 25, 2013

Formatted Explain Plan

There are Some steps to get neat and clear explain plan .

In 10.2 and above, you can pull execution plans from the library cache if the SQL has already been executed (in addition to the standard explain plan option from earlier releases).
Last Executed SQL

To get the plan of the last executed SQL issue the following:
SQL> set linesize 150
SQL> set pagesize 2000
SQL> select * from table(dbms_xplan.display_cursor(null,null, 'ALL'));

SQL_ID and child number of the SQL are known

In this case use dbms_xplan.display_cursor as follows:

SQL> set linesize 150
SQL> set pagesize 2000
SQL> select * from TABLE(dbms_xplan.display_cursor('&SQL_ID', &CHILD));
gather_plan_statistics hint

The gather_plan_statistics hint with some additional options may also provide run time statistics:e.g:

SQL> select /*+ gather_plan_statistics */ col1, col2 etc.....

SQL> set linesize 150
SQL> set pagesize 2000
SQL> select * from TABLE(dbms_xplan.display_cursor('&SQL_ID', &CHILD,'ALL IOSTATS LAST'))

Plan from Memory

Bselect * from table(dbms_xplan.display_cursor('&sql_id'));
select * from table(dbms_xplan.display_cursor('&sql_id', NULL, 'ALL'));

For SQL ID, Child Cursor :
select * from table(dbms_xplan.display_cursor('&sql_id', &child_number, 'ALL'));

For SQL Text :
select t.*
from v$sql s, table(dbms_xplan.display_cursor(s.sql_id, s.child_number, 'ALL')) t
where s.sql_text like '%&querystring%';


for more sql plan detail please visit. How to Obtain a Formatted Explain Plan - Recommended Methods (Doc ID 235530.1)

Saturday, August 10, 2013

top command

By default top command displays the processes in the order of CPU usage.
[root@boost ~]# top
top - 11:37:23 up  2:08,  3 users,  load average: 0.01, 0.00, 0.00
Tasks: 330 total,   1 running, 329 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.1%sy,  0.0%ni, 99.5%id,  0.3%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   7893520k total,  3663532k used,  4229988k free,   139728k buffers
Swap: 18431992k total,        0k used, 18431992k free,  2917144k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0 19248 1428 1156 S  0.0  0.0   0:01.58 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1
    7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1


Something about Top command in linux

By default top command displays the processes in the order of CPU usage.




Friday, August 9, 2013

Netstat Command

Netstat Command  is very useful .this command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc.,

below are some example
1. List All Ports (both listening and non listening ports)

List all ports using netstat -a
# netstat -a | more
[root@boost ~]#  netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 boost.localho:licensedaemon *:*                         LISTEN
tcp        0      0 boost.localhost:tr-rsrb-p1  *:*                         LISTEN
tcp        0      0 *:amqp                      *:*                         LISTEN
tcp        0      0 *:10601                     *:*                         LISTEN
tcp        0      0 *:svn                       *:*                         LISTEN
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
tcp        0      0 boost.localho:licensedaemon boost.localhost:60530       ESTABLISHED
tcp        0     52 boost.localhost:ssh         ABTS-North-Dynamic-21:13206 ESTABLISHED
tcp        0      0 boost.localhost:51937       boost.localhost:tr-rsrb-p1  ESTABLISHED


List all tcp ports using netstat -at
# netstat -at
[root@boost ~]#  netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 boost.localho:licensedaemon *:*                         LISTEN
tcp        0      0 boost.localhost:tr-rsrb-p1  *:*                         LISTEN
tcp        0      0 *:amqp                      *:*                         LISTEN
tcp        0      0 *:10601                     *:*                         LISTEN
tcp        0      0 *:svn                       *:*                         LISTEN
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
tcp        0      0 boost.localho:licensedaemon boost.localhost:60530       ESTABLISHED
tcp        0    248 boost.localhost:ssh         ABTS-North-Dynamic-21:13206 ESTABLISHED
tcp        0      0 boost.localhost:51937       boost.localhost:tr-rsrb-p1  ESTABLISHED
tcp        0      0 boost.localhost:tr-rsrb-p1  boost.localhost:51937       ESTABLISHED
tcp        0      0 boost.localhost:60530       boost.localho:licensedaemon ESTABLISHED
tcp        0      0 *:https                     *:*                         LISTEN
tcp        0      0 *:pcsync-https              *:*                         LISTEN
tcp        0      0 *:wbem-https                *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:http                      *:*                         LISTEN
tcp        0      0 *:ncube-lm                  *:*                         LISTEN
tcp        0      0 *:59665                     *:*                         LISTEN
tcp        0      0 *:37652                     *:*                         LISTEN
tcp        0      0 *:23829                     *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 boost.localhost:ipp         *:*                         LISTEN
[root@boost ~]#

List all udp ports using netstat -au
# netstat -au
[root@boost ~]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
udp        0      0 *:966                       *:*
udp        0      0 *:mdns                      *:*
udp        0      0 *:sunrpc                    *:*
udp        0      0 *:ipp                       *:*
udp        0      0 *:904                       *:*
udp        0      0 *:11025                     *:*
udp        0      0 *:39063                     *:*
udp        0      0 boost.localhost:28589       *:*
udp        0      0 boost.localhost:11440       *:*
udp        0      0 boost.localhost:11568       *:*
udp        0      0 *:34632                     *:*
udp        0      0 boost.localhost:37471       *:*
udp        0      0 boost.localhost:39916       *:*
udp        0      0 *:sunrpc                    *:*
udp        0      0 boost.localhost:55299       *:*
udp        0      0 *:904                       *:*

2. List Sockets which are in Listening State

List only listening ports using netstat -l
# netstat -l
[root@boost ~]#  netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 boost.localho:licensedaemon *:*                         LISTEN
tcp        0      0 boost.localhost:tr-rsrb-p1  *:*                         LISTEN
tcp        0      0 *:amqp                      *:*                         LISTEN
tcp        0      0 *:10601                     *:*                         LISTEN
tcp        0      0 *:svn                       *:*                         LISTEN
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
tcp        0      0 *:https                     *:*                         LISTEN
tcp        0      0 *:pcsync-https              *:*                         LISTEN
tcp        0      0 *:wbem-https                *:*                         LISTEN
List only listening TCP Ports using netstat -lt
# netstat -lt
[root@boost ~]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 boost.localho:licensedaemon *:*                         LISTEN
tcp        0      0 boost.localhost:tr-rsrb-p1  *:*                         LISTEN
tcp        0      0 *:amqp                      *:*                         LISTEN
tcp        0      0 *:10601                     *:*                         LISTEN
tcp        0      0 *:svn                       *:*                         LISTEN
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN
tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
tcp        0      0 *:https                     *:*                         LISTEN
tcp        0      0 *:pcsync-https              *:*                         LISTEN
tcp        0      0 *:wbem-https                *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:http                      *:*                         LISTEN
tcp        0      0 *:ncube-lm                  *:*                         LISTEN
tcp        0      0 *:59665                     *:*                         LISTEN
tcp        0      0 *:37652                     *:*                         LISTEN
tcp        0      0 *:23829                     *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 boost.localhost:ipp         *:*                         LISTEN

List only listening UDP Ports using netstat -lu
# netstat -lu
[root@boost ~]# netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
udp        0      0 *:966                       *:*
udp        0      0 *:mdns                      *:*
udp        0      0 *:sunrpc                    *:*
udp        0      0 *:ipp                       *:*
udp        0      0 *:904                       *:*
udp        0      0 *:11025                     *:*
udp        0      0 *:39063                     *:*
udp        0      0 boost.localhost:28589       *:*
udp        0      0 boost.localhost:11440       *:*
udp        0      0 boost.localhost:11568       *:*
udp        0      0 *:34632                     *:*
udp        0      0 boost.localhost:37471       *:*
udp        0      0 boost.localhost:39916       *:*
udp        0      0 *:sunrpc                    *:*
udp        0      0 boost.localhost:55299       *:*
udp        0      0 *:904                       *:*
[root@boost ~]#

List only the listening UNIX Ports using netstat -lx
# netstat -lx
[root@boost ~]# netstat -lx
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     64195  /var/tmp/.oracle/sEXTPROC1986
unix  2      [ ACC ]     STREAM     LISTENING     106946 @/tmp/dbus-Xq2EuEFyq4
unix  2      [ ACC ]     STREAM     LISTENING     11391  /var/run/cups/cups.sock
unix  2      [ ACC ]     STREAM     LISTENING     106862 @/tmp/gdm-greeter-OEzTmrgF
unix  2      [ ACC ]     STREAM     LISTENING     7731   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     56766  /tmp/keyring-mP1t5P/socket
unix  2      [ ACC ]     STREAM     LISTENING     106776 /tmp/.X11-unix/X0

3. Show the statistics for each protocol

Show statistics for all ports using netstat -s
# netstat -s
Ip:
    11150 total packets received
    1 with invalid addresses
    0 forwarded
    0 incoming packets discarded
    11149 incoming packets delivered
    11635 requests sent out
Icmp:
    0 ICMP messages received
    0 input ICMP message failed.
Tcp:
    582 active connections openings
    2 failed connection attempts
    25 connection resets received
Udp:
    1183 packets received
    4 packets to unknown port received.
.....
Show statistics for TCP (or) UDP ports using netstat -st (or) -su
# netstat -st

# netstat -su
4. Display PID and program names in netstat output using netstat -p

netstat -p option can be combined with any other netstat option. This will add the “PID/Program Name” to the netstat output. This is very useful while debugging to identify which program is running on a particular port.

# netstat -pt
[root@boost ~]#  netstat -pt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 boost.localho:licensedaemon boost.localhost:60530       ESTABLISHED 6237/tnslsnr
tcp        0     52 boost.localhost:ssh         ABTS-North-Dynamic-21:13206 ESTABLISHED 25422/0
tcp        0      0 boost.localhost:51937       boost.localhost:tr-rsrb-p1  ESTABLISHED 4155/ora_lreg_mobil
tcp        0      0 boost.localhost:tr-rsrb-p1  boost.localhost:51937       ESTABLISHED 6241/tnslsnr
tcp        0      0 boost.localhost:60530       boost.localho:licensedaemon ESTABLISHED 6056/ora_lreg_boost
[root@boost ~]#

5. Don’t resolve host, port and user name in netstat output

When you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name.

This also speeds up the output, as netstat is not performing any look-up.

# netstat -an
If you don’t want only any one of those three items ( ports, or hosts, or users ) to be resolved, use following commands.

# netsat -a --numeric-ports

# netsat -a --numeric-hosts

# netsat -a --numeric-users
6. Print netstat information continuously

netstat will print information continuously every few seconds.

# netstat -c
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 ramesh-laptop.loc:36130 101-101-181-225.ama:www ESTABLISHED
tcp        1      1 ramesh-laptop.loc:52564 101.11.169.230:www      CLOSING
tcp        0      0 ramesh-laptop.loc:43758 server-101-101-43-2:www ESTABLISHED
tcp        1      1 ramesh-laptop.loc:42367 101.101.34.101:www      CLOSING
^C
7. Find the non supportive Address families in your system

netstat --verbose
At the end, you will have something like this.

netstat: no support for `AF IPX' on this system.
netstat: no support for `AF AX25' on this system.
netstat: no support for `AF X25' on this system.
netstat: no support for `AF NETROM' on this system.
8. Display the kernel routing information using netstat -r

# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     *               255.255.255.0   U         0 0          0 eth2
link-local      *               255.255.0.0     U         0 0          0 eth2
default         192.168.1.1     0.0.0.0         UG        0 0          0 eth2
Note: Use netstat -rn to display routes in numeric format without resolving for host-names.

9. Find out on which port a program is running

# netstat -ap | grep ssh
(Not all processes could be identified, non-owned process info
[root@boost ~]# netstat -ap | grep ssh
tcp        0      0 *:ssh                       *:*                         LISTEN      1917/sshd
tcp        0     52 boost.localhost:ssh         ABTS-North-Dynamic-21:13206 ESTABLISHED 25422/0
tcp        0      0 *:ssh                       *:*                         LISTEN      1917/sshd
[root@boost ~]#

Find out which process is using a particular port:

# netstat -an | grep ':80'
10. Show the list of network interfaces

# netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0         0      0      0 0             0      0      0      0 BMU
eth2       1500 0     26196      0      0 0         26883      6      0      0 BMRU
lo        16436 0         4      0      0 0             4      0      0      0 LRU
Display extended information on the interfaces (similar to ifconfig) using netstat -ie:

# netstat -ie
Kernel Interface table
eth0      Link encap:Ethernet  HWaddr 00:10:40:11:11:11
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:f6ae0000-f6b00000

Searching Duplicate Lines from File @linux

Uniq command is helpful to remove or detect duplicate entries in a file.

Some are below example .
i have created one file here and add some lines there .

$ cat test
aa
aa
bb
bb
bb

xx

when uniq command is run without any option, it removes duplicate lines and displays unique lines as shown below.

$ uniq test
aa
bb

xx
Count Number of Occurrences using -c option

$ uniq -c test
      2 aa
      3 bb
      1 xx


Print only Duplicate Lines using -d option

This option is to print only duplicate repeated lines in file. As you see below, this didn’t display the line “xx”, as it is not duplicate in the test file.

$ uniq -d test
aa
bb

Print only Unique Lines using -u option

This option is to print only unique lines in file.

$ uniq -u test
xx

Thursday, August 8, 2013

Load Balancing for Rac

last week i had work on  Load Balancing issue , below is my finding on Rac load Balancing  .

Client-Side Load Balancing 

Client-side load balancing is defined in your client connection definition (tnsnames.ora file, for example) by setting the parameter LOAD_BALANCE=ON. When you set this parameter to ON, Oracle Database randomly selects an address in the address list, and connects to that node's listener. This balances client connections across the available SCAN listeners in the cluster. 

The SCAN listener redirects the connection request to the local listener of the instance that is least loaded and provides the requested service. When the listener receives the connection request, the listener connects the user to an instance that the listener knows provides the requested service. To see what services a listener supports, run the lsnrctl services command. 

When clients connect using SCAN, Oracle Net automatically load balances client connection requests across the three IP addresses you defined for the SCAN, unless you are using EZConnect. 

Server-Side Load Balancing 

When you create an Oracle RAC database with DBCA, it automatically: 

Configures and enables server-side load balancing 

Sets the remote listener parameter to the SCAN listener (Note: If you do not use DBCA, you should set the REMOTE_LISTENER database parameter to scan_name:scan_port.) 

Creates a sample client-side load balancing connection definition in the tnsnames.ora file on the server 

FAN, Fast Connection Failover, and the load balancing advisory depend on an accurate connection load balancing configuration that includes setting the connection load balancing goal for the service. You can use a goal of either LONG or SHORT for connection load balancing. These goals have the following characteristics: 

LONG: Use the LONG connection load balancing method for applications that have long-lived connections. This is typical for connection pools and SQL*Forms sessions. LONG is the default connection load balancing goal. The following is an example of modifying a service, batchconn, with the srvctl utility to define the connection load balancing goal for long-lived sessions: 

srvctl modify service -d db_unique_name -s batchconn -j LONG 
SHORT: Use the SHORT connection load balancing method for applications that have short-lived connections. When using connection pools that are integrated with FAN, set the CLB_GOAL to SHORT. The following example modifies the service known as oltpapp, using SRVTCL to set the connection load balancing goal to SHORT: 

srvctl modify service -d db_unique_name -s oltpapp -j SHORT 

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

Also you have to check that both nodes are with correct settings about max number of process ( node 1 process + node 2 process = total process as configuration for cluster database, the idea is to have valid configuration of max processes in order in case of node failure to handle workload by surviving node and in the calculation you have to add some % on top in order to avoid max process issues. 

create a cluster managed service using below steps 


1. What is the service for connection? 
- srvctl status service -d <DBNAME> 

2. Add here your connection string 
3. Add here hostname information, VIP`s, SCAN 
4. Check how many ip`s you have related to SCAN hostname ip 
nslookup SCAN_NAME 
if you have more then one IP related to SCAN name -> ping 5 times hostname and check if IP is changing, if you have such results then all is fine.( add information here) 

Ping check should be done as well from Application host in order to ensure that you are using DNS not host file. 

This is how you can add services in case of missing or wrongly added 

Add OLTP service to be available on both two nodes 
srvctl add service -d <DBNAME> -s <SERVICE_NAME> -r <INSTANCE1>,<INSTANCE2> j SHORT -B SERVICE_TIME 

Check service 
srvctl status service -d <DBNAME> 
Service OLTP is not running. 

Start service 
srvctl start service -d <DBNAME> -s <SERVICE_NAME> 

ora.<DBNAME>.<SERVICE_NAME>.svc 
1 ONLINE ONLINE labnode3 Started 

2 ONLINE ONLINE labnode4 Started 

 Jdbc connection string should be like this 

jdbc:oracle:thin:@(DESCRIPTION =(TRANSPORT_CONNECT_TIMEOUT=3)(CONNECT_TIMEOUT=60)(RETRY_COUNT=3)(FAILOVER=ON)(ADDRESS_LIST =(ADDRESS=(PROTOCOL=tcp)(HOST=joshi-SCANVIP.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=joshi)))Remote_listeners=joshi-SCANVIP.example.com:1521 


jdbc:oracle:thin:@(DESCRIPTION =(TRANSPORT_CONNECT_TIMEOUT=3)(CONNECT_TIMEOUT=60)(RETRY_COUNT=3)(FAILOVER=ON)(ADDRESS_LIST =(ADDRESS=(PROTOCOL=tcp)(HOST=joshi-SCAN.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=joshi))) 

MySql Point-In-Time recovery


Recovering up to particular moment in database’s history can be done with innobackupex and the binary logs of the server.

Note that the binary log contains the operations that modified the database from a point in the past. You need a full datadir as a base, and then you can apply a series of operations from the binary log to make the data match what it was at the point in time you want.

For taking the snapshot, we will use innobackupex for a full backup:

$ innobackupex /path/to/backup --no-timestamp
(the --no-timestamp option is for convenience in this example) and we will prepare it to be ready for restoration:

$ innobackupex --apply-log /path/to/backup
For more details on these procedures, see Creating a Backup with innobackupex and Preparing a Full Backup with innobackupex.

Now, suppose that time has passed, and you want to restore the database to a certain point in the past, having in mind that there is the constraint of the point where the snapshot was taken.

To find out what is the situation of binary logging in the server, execute the following queries:

mysql> SHOW BINARY LOGS;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |       126 |
| mysql-bin.000002 |      1306 |
| mysql-bin.000003 |       126 |
| mysql-bin.000004 |       497 |
+------------------+-----------+
and

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 |      497 |              |                  |
+------------------+----------+--------------+------------------+
The first query will tell you which files contain the binary log and the second one which file is currently being used to record changes, and the current position within it. Those files are stored usually in the datadir (unless other location is specified when the server is started with the --log-bin= option).

To find out the position of the snapshot taken, see the xtrabackup_binlog_info at the backup’s directory:

$ cat /path/to/backup/xtrabackup_binlog_info
mysql-bin.000003      57
This will tell you which file was used at moment of the backup for the binary log and its position. That position will be the effective one when you restore the backup:

$ innobackupex --copy-back /path/to/backup
As the restoration will not affect the binary log files (you may need to adjust file permissions, see Restoring a Full Backup with innobackupex), the next step is extracting the queries from the binary log with mysqlbinlog starting from the position of the snapshot and redirecting it to a file

$ mysqlbinlog /path/to/datadir/mysql-bin.000003 /path/to/datadir/mysql-bin.000004 \
    --start-position=57 > mybinlog.sql
Note that if you have multiple files for the binary log, as in the example, you have to extract the queries with one process, as shown above.

Inspect the file with the queries to determine which position or date corresponds to the point-in-time wanted. Once determined, pipe it to the server. Assuming the point is 11-12-25 01:00:00:

$ mysqlbinlog /path/to/datadir/mysql-bin.000003 /path/to/datadir/mysql-bin.000004 \
    --start-position=57 --stop-datetime="11-12-25 01:00:00" | mysql -u root -p
and the database will be rolled forward up to that Point-In-Time.