The combination of FLUSH STATUS and SHOW SESSSION STATUS can be used to see what happens while MySQL executes a query. First, run FLUSH STATUS to reset session status variables to zero.
mysql> FLUSH STATUS;
mysql> SELECT COUNT(*) FROM TABLE;
Procedure to add a swap file
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
# mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab
Append following line:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
$ free -m
vi first edit source file
then move your cursor to start of selection
ma mark current position with letter a
then move your cursor to end of selection
y'a yank to buffer x from current position to mark a
:e other edit target file
move cursor to where you want the data
p put from buffer x
Constructors
When you create a new instance (a new object) of a class using the new keyword, a constructor for that class is called. Constructors are used to initialize the instance variables (fields) of an object. Constructors are similar to methods, but with some important differences.
To copy a block of text between files execute the commands:
| Command |
Explaination |
| 1. |
|
Edit the file containing the text you want to copy. |
| 2. |
|
Go to the top line to be copied. |
| 3. |
ma |
Mark this line as mark “a”. |
| 4. |
|
Go to the bottom line to be copied |
| 5. |
y'a |
Yank (y) the text from the current cursor location to the mark “a” ('a) |
| 6. |
:split second-file |
Open another window containing the second file. (This the file in which the text is to be inserted.) |
| 7. |
|
Go to the line where the insert is to occur. The text will be place after this line. |
| 8. |
p |
Put the text after the cursor. |
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections .
strace -q -f -c -p
strace -f verbose=all -e write=all -o /tmp/strace.log -p [pid]
strace -T -t -q -f -e trace=file,open,close,read -o /tmp/prod.strace.log -p <oms or ui pid>
-f traces all child processes as they are created byt he currently traced process as a result of the fork() system call.
-e is a qualifying expression which modifies which events to trace or how to race them
verbose=all dereferences structures for all system calls
write=all performs a full hexadecimal and ASCII dump of all the data written to all file descriptors
-o output file
-p process id to trace
Replace -p [pid] with [command] to trace a specific command.
Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache…
To use /proc/sys/vm/drop_caches, just echo a number to it.
To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the user should run “sync” first!
tmpfs is supported by the Linux kernel from version 2.4 and up. tmpfs (previously known as shmfs) distinguishes itself from the Linux ramdisk device by allocating memory dynamically and by allowing less-used pages to be moved onto swap space. RAMFS, in contrast, does not make use of virtual memory (which can be an advantage or disadvantage). In addition, MFS and some older versions of ramfs did not grow and shrink dynamically and instead used a fixed amount of memory at all times.
Usage of tmpfs for example is “mount -t tmpfs -o size=1G,nr_inodes=10k,mode=0700 tmpfs /space” which will allow up to 1 GiB in RAM/swap with 10240 inodes and only accessible by the owner of the directory /space. The filesystem’s maximum size can also be changed on-the-fly, like “mount -o remount,size=2G /space”.