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;