In my blog, i would discuss the problem i face in daily routine. Following are some of them: mysql error, mysql replication, mysql database corrupted repair, innodb tablespace corruption, mysql storage engines, mysql optimization and tuning, reinstall mysql linux server, linux command for dummies, linux administration tips, mysql administration tips, Linux server benchmarking
Monday, December 19, 2011
undefined symbol: apr_atomic_xchgptr
Friday, December 16, 2011
To find the installed path for a package in Linux
rpm -ql packagename
To find a file anywhere on your system:
locate filename
find / -name filename
Friday, December 9, 2011
Fixing a php.ini configuration file location problem
PHPIniDir "/etc"
* make sure your php.ini is under /etc/php.ini Tuesday, December 6, 2011
WHEN installing apache 2.2: No recognized SSL/TLS toolkit detected
While running Apache configure, if you get this error:
No recognized SSL/TLS toolkit detected
…do this:
yum install -y openssl-devel # Required for Apache configure
Wednesday, November 30, 2011
MySQL 5 Database Administrator Certified Professional Exam
Tuesday, November 29, 2011
MySQL DBA Exam II
Wednesday, November 23, 2011
Oracle MySQL DBA Certification Exam 1 - CX310-810
Wednesday, November 9, 2011
Wednesday, October 19, 2011
error: C++ preprocessor "/lib/cpp" fails sanity check
Friday, October 7, 2011
Steve Jobs Leaving
A giant that changed the computing experience had leave us ..
Salute him for his innovation.
His words and his impressive presentation.
Steve Jobs (1955-2011)
you will always being remembered.
Thursday, September 22, 2011
Tuesday, July 26, 2011
Hardware: Router interface
MySQL: MySQL Privileges needed for SELECT ... INTO OUTFILE
Thursday, July 14, 2011
Linux Administration: check the server last boot, uptime and the start up and shutdown log
2) who -b (doesn't work in some distros) will give you actual date/time of last boot.
3) last -x will show you what /var/log/wtmp recorded for shutdowns. (Note you may have to specify last -x -f /var/log/wtmp.1 or something similar to see older logs.)
Linux Administration: to add a linux service to boot time
Wednesday, July 13, 2011
MySQL Error: SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/xxxx.csv' (Errcode: 28)
Tuesday, July 12, 2011
Unable to connect to internet while connected to VPN
On the VPN connection Properties dialog, on the Network tab, select Internet Protocol (TCP/IP) then click Properties. On the TCP/IP Properties dialog click on the Advanced button. Make sure the check box for 'Use default gateway on remote network' is unselected.
Note that for this change to take affect you'll need to reconnect if you're already connected to the VPN.
Friday, July 8, 2011
Databases: DBMS blooming
but is it necessary to have all these new database create ?
why they not maybe combine their efforts to create another Better SQL database, and send the MySQL to history ??
wondering ...
Wednesday, June 15, 2011
Find Files By Access, Modification Date / Time Under Linux or UNIX
Ido not remember where I saved pdf and text files under Linux. I have downloaded files from the Internet a few months ago. How do I find my pdf or text files?
You need to use the find command. Each file has three time stamps, which record the last time that certain operations were performed on the file:
[a] access (read the file's contents) - atime
[b] change the status (modify the file or its attributes) - ctime
[c] modify (change the file's contents) - mtime
You can search for files whose time stamps are within a certain age range, or compare them to other time stamps.
You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.
- -mtime +60 means you are looking for a file modified 60 days ago.
- -mtime -60 means less than 60 days.
- -mtime 60 If you skip + or - it means exactly 60 days.
So to find text files that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -print
Display content of file on screen that were last modified 60 days ago, use
$ find /home/you -iname "*.txt" -mtime -60 -exec cat {} \;
Count total number of files using wc command
$ find /home/you -iname "*.txt" -mtime -60 | wc -l
You can also use access time to find out pdf files. Following command will print the list of all pdf file that were accessed in last 60 days:
$ find /home/you -iname "*.pdf" -atime -60 -type -f
List all mp3s that were accessed exactly 10 days ago:
$ find /home/you -iname "*.mp3" -atime 10 -type -f
There is also an option called -daystart. It measure times from the beginning of today rather than from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday, type the command
$ find /home/you -iname "*.mp3" -daystart -type f -mtime 1
Where,
- -type f - Only search for files and not directories
-daystart option
The -daystart option is used to measure time from the beginning of the current day instead of 24 hours ago. Find out all perl (*.pl) file modified yesterday, enter:
find /nas/projects/mgmt/scripts/perl -mtime 1 -daystart -iname "*.pl"
You can also list perl files that were modified 8-10 days ago, enter:
To list all of the files in your home directory tree that were modified from two to four days ago, type:
find /nas/projects/mgmt/scripts/perl -mtime 8 -mtime -10 -daystart -iname "*.pl"
-newer option
To find files in the /nas/images directory tree that are newer than the file /tmp/foo file, enter:
find /etc -newer /tmp/foo You can use the touch command to set date timestamp you would like to search for, and then use -newer option as follows
touch --date "2010-01-05" /tmp/foo # Find files newer than 2010/Jan/05, in /data/images find /data/images -newer /tmp/foo
Read the man page of find command for more information:
man find
Tuesday, June 14, 2011
Change the machine name/hostname in Linux
How to change the hostname of a Linux system
Normally we will set the hostname of a system during the installation process. Many peoples don't care about this, and don't change the hostname even if for example this was set to something really stupid by the datacenter that installed the system (most likely they will set this to "debian" on any debian installation, etc). For me, it is important to see on each one of the ssh screens I will have open at any time a different hostname that is relevant and will give me quickly the information on what system I am logged in.
Change the hostname on a running system
On any Linux system you can change its hostname with the command 'hostname'… Here are some quick usages of the command line hostname:
hostname without any parameter it will output the current hostname of the system.
hostname --fqd it will output the fully qualified domain name (or FQDN) of the system.
hostname NEW_NAME will set the hostname of the system to NEW_NAME. This is active right away and will remain like that until the system will be rebooted (because at system boot it will set this from some particular file configurations – see bellow how to set this permanently). You will most probably need to exit the current shell in order to see the change in your shell prompt.
Permanent hostname change on Debian based systems
Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh
/etc/hostname serverSo on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:
/etc/init.d/hostname.sh start to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used hostname.sh).
Permanent hostname change on RedHat based systems
RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit
/etc/sysconfig/network NETWORKING=yes HOSTNAME="plain.domainname.com" GATEWAY="192.168.0.1" GATEWAYDEV="eth0" FORWARD_IPV4="yes"So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME variable.
Use sysctl to change the hostname
Why would someone need a different method of doing the same thing as above? No idea, but here is anyway: use sysctl to change the variable kernel.hostname:
Use:
sysctl kernel.hostname to read the current hostname, and
sysctl kernel.hostname=NEW_HOSTNAME to change it.
Wednesday, June 8, 2011
InnoDB storage engine failed ?
Wednesday, June 1, 2011
Can't use "locate" in your linux?
Saturday, May 28, 2011
To modify subnet mask or IP address of LINUX Network interface - eth0
/etc/sysconfig-network-scripts/ifcfg-eth
e.g contents inside the file
TYPE=Ethernet
BOOTPRO=none
IPADDR=192.168.2.3
PREFIX=24
GATEWAY=192.168.2.1
DEFROUTE=yes
DNS1=192.168.2.1
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="Auto eth0"
UUID=42b275d6-a04d-4898-8df1-cde310f3cal7
ONBOOT=yes
HWADDR=08:00:27:64:XX:XX
After modified the file, restart the "network" service
/sbin/service network restart
Wednesday, May 25, 2011
JAVA - Why you would use java.util.Calendar to get your NOW/ Current Time
MySQL - Setting MySQL Database Server for Production Server
To Install Perl for Fedora 14 - Dependencies Package as following
Thursday, May 19, 2011
Delete Files Older Than x Days on Linux
Sunday, May 15, 2011
Friday, May 13, 2011
MySQL Replication - To be review
1. Create c:\slave folder
2. Copy my.ini into C:\slave folder
3. Change port=3312 in my.ini
4. Create c:\slave\data folder
5. Copy mysql folder from mysql original data folder (Documents & Settings)
6. run "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install mysqlslave --defaults-file=C:\slave\my.ini
master my.ini
[mysqld]
log-bin=mysql-bin
server-id=1
slave my.ini
[mysqld]
server-id=2
master:
CREATE USER 'repl'@'localhost' IDENTIFIED BY 'slavepass';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost';
FLUSH TABLES WITH READ LOCK;
c:\>mysqldump --port=3306 -uroot -ppassword --all-databases --lock-all-tables > dbdump.db
OR mysqldump --all-databases --master-data > c:/dbdump.db
UNLOCK TABLES;
slave:
mysql --port=3312 -uroot -ppassword < c:/dbdump.db
net start and stop both
Obtaining the Replication Master Binary Log Coordinates
master:
SHOW MASTER STATUS;
*identify binlog file and position
slave:
mysql --port=3311 -uroot -ppassword
show variables like 'port';
show variables like 'hostname';
show variables like 'server_id';
mysql>CHANGE MASTER TO
-> MASTER_HOST='localhost',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='slavepass',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mysql-bin.000001',
-> MASTER_LOG_POS=332;
mysql>start slave
MASTER:
INSERT INTO World.City (Name, CountryCode) VALUES ('Selangor','MY');
SLAVE:
mysql>SELECT ID, Name FROM World.City WHERE name='Selangor';
Both Master & Slave:
Show Processlist;
Tuesday, April 19, 2011
Steps to install Sysbench for Linux ( Centos 5 )
Install sysbench error
Check whether your libmysqlclient is there by execute
shell> ldconfig -p| grep mysql
Result screen would be similar as below, if the libmysqlclient is already installed.
OR else it is empty.
MySQL Purge binlog Safely
Friday, April 15, 2011
Thursday, April 14, 2011
To Uninstall a Service .eg. MySQL from Linux
Wednesday, April 13, 2011
Wednesday, April 6, 2011
to allow the user to be able to execute linux command
Thursday, March 10, 2011
Five configuration options affect of the MySQL performance
(A) connections
Connection is usually from the Web server, the following are some of the parameters related with the connection, and how to set them.
1, max_connections
This is the Web server allows the maximum number of connections, each connection uses memory.
2,max_packet_allowed
Maximum packet size, generally mean that you need to return a chunk the size of the largest data set, if you use a remote mysqldump, then the need for greater its value.
3,aborted_connects
Check the state of the system counter, is no growth, growth that if the client connection error.
4,thread_cache_size
Access MySQL connections will create a new thread, because the MySQL open and close connections are cheap, fast speed, it is not like other databases, such as Oracle are so many persistent connections, but the thread is created in advance and will not save time, That is why the reasons for the MySQL thread cache.
Please attention to these additional threads, so your thread cache more, for 2550 or 100 thread_cache_size, memory footprint is not much.
(B) Query cache
(C) Temp tables
Memory query speed is very fast, so we hope that all of the sorting operations are in memory, so that we can adjust the query result set in order to achieve a smaller sort of memory, or to be more variable.
tmp_table_size
max_heap_table_size
Whenever you create temporary tables in MySQL, which will use the minimum of these two variables as the critical value, in addition to building temporary tables on disk, it will also create many sessions, these sessions will be limited to seize the resources, the most Good is to adjust the query rather than the higher of these parameters, while there is a need to pay attention BLOB or TEXT field types of the table will be directly written to disk.
(D) concurrent sessions
MySQL Each concurrent sessions has its own memory, this memory is the memory allocated to the SQL query, so you want to make it as large as possible to meet the needs. But you can not balance the same time, the number of concurrent sessions within the database consistency. Here is a littleblack art is the MySQL cache is allocated as needed, so you can not just add them and multiply by the number of concurrent sessions, this estimate down to less than the typical use of MySQL is much greater.
Best practice is to start MySQL, connect all the session, and then continue to focus on top-level session of the VIRT column, mysqld number of rows usually remain relatively stable, which is the total amount of actual memory, minus all the static MySQL memory region to be the actual All session memory, and then divided by the number of sessions to be average.
1,read_buffer_size
Size of the buffer used for doing full table scans of MyISAM tables. Allocated per thread, if a full scan is needed.
2,sort_buffer_size
The size of the sorting buffer, it is best to set it to 1M-2M, and then set in the thread for a particular query to set a higher value.
3,join_buffer_size
Implementation of the joint distribution of the buffer size of the query, set the size to 1M-2M, and then again in a separate demand for each thread in the set.
4,read_rnd_buffer_size
Used to sort and order by operations, it is best to set it to 1M, then the session can be used as a thread variable is set to a larger value.
(E) slow query log
MySQL slow query log is a useful feature.
1, log_slow_queries
Parameters log_slow_queries MySQL my.cnf file to set parameters in it, set it on, by default, MySQL will file into the data directory, files with "hostname-slow.log " in the form of name, but you When setting this option you can assign a name.
2, long_query_time
The default value is 10 seconds, you can dynamically set it, the value from 1 to set it on, if thedatabase is started, by default, the log will be closed.
3, log_queries_not_using_indexes
Turn this option is a good idea, it truly records the query returns all rows.
MySQL query cache in the query plan includes two analysis, and the returned data set, if the underlying table data or structural changes will make the query cache item is invalid.
1, query_cache_min_res_unit
MySQL query cache parameters query_cache_min_res_unit the size of the block is allocated, use the following formula to calculate the average size of the query cache, set this variable according to the results, MySQL will be more effective use of the query cache, query cache more reduce the memory waste.
2, query_cache_size
This parameter set the total size of the query cache.
3, query_cache_limit
This tells MySQL lost query is larger than this size, is still relatively rare for large queries, such as the implementation of a large run a batch report statistics, so that should not be filled with a large result set query cache.
qcache hit ratio = qcache_hits/(qcache_hits + com_select).
SQL> show status like 'qcache%';
SQL> show status like 'com_%';
Find these variables.
average query size = (query_cache_size – qcache_free_memory)/qcache_queries_in_cache.
SQL> show variables like 'query%';
qcache_ * status variables you can get with:
SQL> show status like 'qcache%';
Get query_cache_size value.