Month: April 2007

How to change MAC address of interface – ubuntu

How to change MAC address of interface – ubuntu

Introduction –

Why we need to change MAC address? On one of our proxy server which is directly connected to internet. Due to some reason I have to assign MAC address to one of the Interface eth0! My ISP want unique MAC address to interface which is connected to there service.

Set MAC address to interface manually –

step(1) Edit the /etc/network/interfaces file. to modify the interface configuration on Ubuntu or Debian system…

root@arunbagul:~# vi /etc/network/interfaces
root@arunbagul:~#

See your network interface conf file. If you have dhcp enabled, it will look like this…

root@arunbagul:~# cat /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

root@arunbagul:~#

step(2) Now specify the MAC address as shown below…

root@arunbagul:~# cat /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
hwaddress ether 01:06:03:04:0B:06

root@arunbagul:~#

step(3) Now restart your network service –

root@arunbagul:~# /etc/init.d/networking restart
* Reconfiguring network interfaces…
There is already a pid file /var/run/dhclient.eth0.pid with pid 4440
killed old client process, removed PID file

…..

DHCPACK from 192.168.1.10
bound to 192.168.1.89 — renewal in 3110 seconds.
[ OK ]
root@arunbagul:~#

step(4) macchanger – is the tool available for Ubuntu to change the MAC address –

How to install macchanger ?

root@arunbagul:~# apt-get install macchanger
Reading package lists… Done
Building dependency tree

…..
Setting up macchanger (1.5.0-1) …

root@arunbagul:~#

step(5) How to use this –

root@arunbagul:~# macchanger eth0
root@arunbagul:~#

Cheers,
Arun Bagul

PHP – Oracle Connectivity

PHP – Oracle Connectivity

Introductions –

Using PHP we can connect many databases like MySQL, Postgresql, DB2, Oracle and SQL server very easily. Now this article provides the information about database connectivity to Oracle using PHP

PHP Oracle functions allow you to access Oracle 10, Oracle 9, Oracle 8 and Oracle 7 databases using the Oracle Call Interface (OCI). They support binding of PHP variables to Oracle placeholders, have full LOB, FILE and ROWID support, and allow you to use user-supplied define variables.

Configuration part in windows php_oci8.dll is the connectivity dll in windows environment. In Linux we can compile php with oracle module

Once the configuration completes you will be able to see this configuration when you execure –

URL = http://localhost/phpinfo.php

<?php

phpinfo();

?>

php-oracle

** Basic example to connect ORACLE database and execute query –

root@arunbagul:~# cat /var/www/php_oracle.php

<?php
$conn = oci_connect(‘hr’, ‘hr’, ‘orcl’);
if (!$conn) {
$e = oci_error();
print htmlentities($e[‘message’]);
exit;
}

$query = ‘SELECT * FROM DEPARTMENTS’;

$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e[‘message’]);
exit;
}

$r = oci_execute($stid, OCI_DEFAULT);
if (!$r) {
$e = oci_error($stid);
echo htmlentities($e[‘message’]);
exit;
}
root@arunbagul:~#

Other way to connect to oracle using simple Oracle functions. But these functions are deprecated. Now a day’s oci8 functions are in used.

Cheers,
Santhosh Tirunahari

Table types (storage Engine) in MySQL

Table types (storage Engine) in MySQL

Introduction –

Any database in MySQL is stored physically in Data directory of MySQL server. You can find data directory in /etc/my.cnf file or from running MySQL process..

arun@arunbagul:~$ ps aux | grep “/usr/sbin/mysqld” | grep -v grep
mysql 5534 0.0 1.0 127920 21136 ? Sl 21:09 0:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –user=mysql –pid-file=/var/run/mysqld/mysqld.pid –skip-external-locking –port=3306 –socket=/var/run/mysqld/mysqld.sock
arun@arunbagul:~$

So data directory for MySQL server is normally “/var/lib/mysql“. Format of storing data physically in data directory is depends of the table type or Storage Engine used by MySQL. There are six (6) types of tables (Storage Engine) you can use in MySQL.

root@arunbagul:~# grep “datadir” /etc/mysql/my.cnf
datadir = /var/lib/mysql
root@arunbagul:~# cd /var/lib/mysql

root@arunbagul:/var/lib/mysql# ls -lF
total 8768
drwxr-xr-x 2 mysql mysql 4096 2008-04-01 07:51 mysql/
drwx—— 2 mysql mysql 4096 2008-04-09 12:39 trac/
drwx—— 2 mysql mysql 4096 2008-02-22 23:18 wordpress/
drwx—— 2 mysql mysql 4096 2008-03-07 11:27 zabbix/
root@arunbagul:/var/lib/mysql#

By default MySQL server creates administrative database called “mysql“. Which contains system tables necessary to control user access, provide help related to information, and support time-zone related functionality.

1) BDB – Tranction safe table that the berkeley DB handler manages. InnoDB tables have replaced BDB tables.

2) Memory – A table whose contents are stored in memory. The data stored in the tables is available only as long as the MySQL server is available. If the server crashes or is shutdown, the data disappears.

3) InnoDB – A transaction safe table that the InnoDB handler mamages. As a result, dtata is not stored in .MYD file, but instead is managed in the InnoDB tablespace.

4) ISAM – This table type was the default table type, now it is deprecated. Now a days MyISAM is the default table type used in MySQL.

5) MERGE – This is the virtual table that is made up of multiple MyISAM tables. Data is not stored in the MERGE table, but rather in the underlying MyISAM tables.

6) MyISAM – This is the default table type used in MySQL. Which support extensive indexing and are optimized for compressions and speed.

root@arunbagul:/var/lib/mysql# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.45-Debian_1ubuntu3.3-log Debian etch distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show variables like ‘storage_engine’;
+——————-+—————–+
| Variable_name | Value |
+——————+—————–+
| storage_engine | MyISAM |
+—————–+——————-+
1 row in set (0.00 sec)

mysql> quit
Bye
root@arunbagul:/var/lib/mysql#

** How to define table/storage type in MySQL ?

mysql> create table person ( id INT(10) PRIMARY KEY, name VARCHAR(20) ) ENGINE=MyISAM;
Query OK, 0 rows affected (0.02 sec)

mysql> quit
Bye
root@arunbagul:~#

Thank you,
Arun Bagul