Monday, December 19, 2011

undefined symbol: apr_atomic_xchgptr

When compiling SVN server, and you get this error

undefined symbol: apr_atomic_xchgptr

for my cases, it's due to the SVN library pointing the /usr/lib64 rather than apache's apr, hence you need to recompile your SVN server by pointing your library to where your apache APR located


Friday, December 16, 2011

To find the installed path for a package in Linux

Try this:
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

to request the server to change the location where it should read the php.ini from?

Just add an entry in httpd.conf (/etc/httpd/conf/httpd.conf) as following:

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

YES! finally taken my second paper for MySQL 5 database administrrator certified professional exam.
AND YES!!!!! YES!!! YES!!!  i passed them :)
waiting for the soft copy of my certificate 

Tuesday, November 29, 2011

MySQL DBA Exam II

It's the day, the day which i would have to attend my MySQL DBA exam paper 2.
All the best to me :)

Wednesday, November 23, 2011

Oracle MySQL DBA Certification Exam 1 - CX310-810

21st November 2011 - 3pm to 4:30pm (+8.00 GMT)

I passed the exam: 98% , with one wrong answered question 
looking forward to the exam II (CX310-810) at 28th November 2011

Cheers!

Wednesday, November 9, 2011

Wednesday, October 19, 2011

error: C++ preprocessor "/lib/cpp" fails sanity check

solution i found:

it's due to gcc-c++ is not installed in Centos, after executing the command as below, it solve my issue

shell> yum install gcc-c++

Friday, October 7, 2011

Steve Jobs Leaving

A great lost to computer world.
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.

Tuesday, July 26, 2011

Hardware: Router interface

Configure "DMZ" - to allow outside access(via public ip) to local machine



MySQL: MySQL Privileges needed for SELECT ... INTO OUTFILE

MySQL "FILE" Privilege is need to grant to the user, to execute SELECT ...INTO OUTFILE ..  
or 
LOAD DATA INFILE "/tmp/xxxx.csv" INTO .... 

or else, you will get 

Access denied for user 'test'@'%'  when you run the query


Thursday, July 14, 2011

Linux Administration: check the server last boot, uptime and the start up and shutdown log

1) Running "uptime" which will show you how long it has been up. You can figure out last boot from that.

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

Here is the command:

chkconfig --level 2345 portmap on

Reference Link:

Run Level Reference Link:



Wednesday, July 13, 2011

MySQL Error: SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/xxxx.csv' (Errcode: 28)

if you happened to see the error as following, when you are running MySQL select ... into outfile "/tmp/xxxxx.csv";

 SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/xxxx.csv' (Errcode: 28)

checkout your /tmp folder space in your linux, you will find your space is not enough for the file you are going to put into /tmp folder
to check,

shell> df -h

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

After the success of MySQL, we can see a lots of Open Source Database blooming like mushroom after the rain. Among them are MariaDB, VoltDB, SkySQL( if not mistaken ) and etc.. etc....
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 server

So 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 ?

if you happened to find in your mysql server log the same error as below when you start up the mysql server; And you are not able to see the InnoDB storage engine as one of the enabled storage engine in your mysql server via 

mysql> show engines \G

Suppose Result
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Engine: InnoDB
     Support: YES
     Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
          XA: YES
  Savepoints: YES
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Server error log:
110608 22:53:00 InnoDB: Initializing buffer pool, size = 2.0G
110608 22:53:00 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
110608 22:53:00 [ERROR] Plugin 'InnoDB' init function returned error.
110608 22:53:00 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.


Solution:
1. Remove ibdata1 and  ib_logfile* from the location /var/lib/mysql on your server (depends on which location you install your mysql server data folder)

CAUTIONS:
Backup your innodb tables first, before you delete the ibdata1 file, in case you haven't enable the "innodb_file_per_table" option in your my.cnf

NOTES:
My case: this error happened when i have mass changes on the settings options inside the my.cnf file (mainly on the buffering, and caching values) and trying to restart the mysql server. i have existing InnoDB tables runnning. So i have to dump out the data to be restore again later


Wednesday, June 1, 2011

Can't use "locate" in your linux?

if you have getting the error as following:


locate: can not open `/var/lib/mlocate/mlocate.db': No such file or directory

simply run 
Shell > updatedb

to update your system's file indexing, then you are able to do the searching after the process completed


Saturday, May 28, 2011

To modify subnet mask or IP address of LINUX Network interface - eth0

this is where you can get your the file that consisting of your gateway ip, your server's IP address and the subnet mask information

/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

Why you would use java.util.Calendar to get your Now/Current Time?

Calendar cal = Calendar.getInstance();
cal.getTime();

Answer: Only when you need to get the Now/Current Time from different time zone

MySQL - Setting MySQL Database Server for Production Server

Run the command below:

/usr/bin/mysql_secure_installation

Action to be taken for the mysql_secure_installation

1. would request you to change your root password, 
2. remove the "test" database, and remove the anonymous account
3. remove the "root" user remote login access
4. reload privileges tables 

To Install Perl for Fedora 14 - Dependencies Package as following

Installing:
 perl                                         i686                          4:5.12.3-143.fc14                           updates                         11 M
Installing for dependencies:
 perl-Module-Pluggable                        noarch                        1:3.90-143.fc14                             updates                         38 k
 perl-Pod-Escapes                             noarch                        1:1.04-143.fc14                             updates                         31 k
 perl-Pod-Simple                              noarch                        1:3.13-143.fc14                             updates                        211 k
 perl-libs                                    i686                          4:5.12.3-143.fc14                           updates                        613 k
 perl-threads                                 i686                          1.81-1.fc14                                 fedora                          47 k
 perl-threads-shared                          i686                          1.32-143.fc14                               updates                         51 k

Thursday, May 19, 2011

Delete Files Older Than x Days on Linux

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We'll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.

Command Syntax

find /path/to/files* -mtime +5 -exec rm {} \;

Note that there are spaces between rm, {}, and \;

Explanation

The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.
This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.

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 )

Download your Sysbench source from 


Extract the tar file.
Before proceed to execute the command below in the Linux shell, run the 

shell> ldconfig -p| grep mysql

to check if libmysqlclient is install, result screen would be as following
--------------------------------------------------------------------------------------------------------
libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.16
libmysqlclient.so (libc6,x86-64) => /usr/lib64/libmysqlclient.so
--------------------------------------------------------------------------------------------------------

if it's empty, proceed to install the "libmysqlclient" by download the "MySQL-shared-5.5.9-1.linux2.6.x86_64.rpm" and install it via execute the command below at where your rpm file is.

     rpm -ivh MySQL-shared-5.5.9-1.linux2.6.x86_64.rpm


After all the checking steps above is done, execute the following linux commands steps by steps.

shell > aclocal
shell > libtoolize --force --copy
sysbench_installation_root_folder >  ./autogen.sh    (this file is inside the sysbench source folder)
sysbench_installation_root_folder > ./configure
sysbench_installation_root_folder > make
sysbench_installation_root_folder > make install 



Below is the READ ONLY test

shell > sysbench --num-threads=16 --max-requests=100000 --test=oltp --oltp-table-size=500000 --mysql-socket=/var/lib/mysql/mysql.sock --oltp-read-only --mysql-user=sqlUser --mysql-password=pswd --mysql-db=test run

Install sysbench error

If you happened to have see this error when you install your Sysbench

/usr/bin/ld: cannot find -lmysqlclient_r

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.

--------------------------------------------------------------------------------------------------------
libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.16
libmysqlclient.so (libc6,x86-64) => /usr/lib64/libmysqlclient.so
--------------------------------------------------------------------------------------------------------


OR else it is empty.

The solution if the result screen is empty is to download "MySQL-shared-5.5.9-1.linux2.6.x86_64.rpm" and install it. Execute the linux command as below, if you had download the rpm file. 

         shell > rpm -ivh MySQL-shared-5.5.9-1.linux2.6.x86_64.rpm


Afterward, you are able to continue install your Sysbench without the error as below shown.



MySQL Purge binlog Safely

First of all, please check slave server status with the SQL query below:

show slave status;

look for the "Relay_Master_Log_File" column, and see which master binlog the slave had replicated up to.
example data: mysql-bin.000096


At your master 
mysql> PURGE BINARY LOGS TO 'mysql-bin.000096';

Master will clean up the mysql binlog up to mysql-bin.000096 ( the file with this name will still remain there)



Wednesday, April 6, 2011

to allow the user to be able to execute linux command

add the <user_name> to the 
/etc/sudoers 

e.g line add

support ALL=(ALL) NOPASSWD:ALL

Because the file is a readonly file, you first need to change the file permission to allow write to the file by root user

chmod g+rw /etc/sudoers

and you have to change it back to readonly file

chmod g-r /etc/sudoers






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.