Pages

Sunday, November 28, 2010

Repairing Linux ext2 or ext3 file system


1) File system must be unmounted, you cannot repair it while it is running. Take system down to runlevel one (make sure you run all command as root user):
# init 1

2)Unmount file system, for example if it is /home (/dev/sda3) file system then type command:
# umount /home
OR
# umount /dev/sda3

3) Now run fsck on the partition:
# fsck /dev/sda3

However be sure to specify the file system type using -t option. Recenly one of our sys admin run the command on ext3 file system w/o specifying file system. Result was more corruption as fsck by default assumes ext2 file system.
# fsck -t ext3 /dev/sda3
OR
# fsck.ext3 /dev/sda3

Tip if you don't know your file system type then typing mount command will display file system type.

fsck will check the file system and ask which problems should be fixed or corrected. If you don't wanna type y every time then you can use pass -y option to fsck.
# fsck -y /dev/sda3

Please not if any files are recovered then they are placed in /home/lost+found directory by fsck command.

4) Once fsck finished, remount the file system:
# mount /home

5) Go to multiuser mode
# init 3


More help

fsck -n /dev/sda1

The output looks like this:

fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)
/dev/sda1: clean, 159037/1254176 files, 1095299/2504124 blocks

Next we remove the journal from /dev/sda1, thus turning it into an ext2 partition:

tune2fs -O ^has_journal /dev/sda1

The output looks like this:

tune2fs 1.38 (30-Jun-2005)

Then run

e2fsck -f /dev/sda1

e2fsck 1.38 (30-Jun-2005)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda1: 164178/1254176 files (0.6% non-contiguous), 1051617/2504124 blocks

Now we resize our file system with resize2fs. resize2fs can resize ext2 file systems, but not ext3 file systems, that's why we had to turn /dev/sda1 to ext2. Currently, 4.1GB are used on /dev/sda1 (see the df -h output above), So it's safe to shrink it from 10GB to about 6GB (if you make it smaller than 4.1GB, you will lose data!). Therefore we run

resize2fs /dev/sda1 6000M

The output is as follows:

resize2fs 1.38 (30-Jun-2005)
Resizing the filesystem on /dev/sda1 to 1536000 (4k) blocks.
The filesystem on /dev/sda1 is now 1536000 blocks long.

Please take note of the amount of blocks (1536000) and their size (4k). We need that soon.

Now we delete our /dev/sda1 partition (don't be afraid, no data will be lost) and create a new, smaller one (but still big enough to hold our resized file system!). We can do this with fdisk:


How To Resize ext3 Partitions Without Losing Data

Assuming this is your partition table:

Dev Type Mount Size
sda1 nt40 nt40 1992M
sda2 linux / 1498M
sda3 swap 117M
sda4 extended 5036M
sda5 swap 117M
sda6 home /home 4910M


-backup your /home on to your tape drive.

-check and make sure the backup worked

-use fdisk to delete the home partition and create several smaller partitions:(make /dev/sda6 about 800 megs)

fdisk /dev/sda

-create a file system on /dev/sda6:

mke2fs /dev/sda6

-mount it and copy all files in /usr to sda6:

mount /dev/sda6 /mnt
cd /usr
ls (sanity check)
cp -a * /mnt
cd /mnt
ls (sanity check)

-change fstab to mount /usr/ as /dev/sda6:

/dev/sda6 /usr ext2 defaults 1 2

Don't leave this one there:

/dev/sda6 /home ext2 defaults 1 2

-reboot and check that everything is okay

mount (Did sda6 appear mounted on /usr?)
startx (Did X start up?)

-reboot into single user mode, umount /usr, and erase the /usr file on sda2:

init 1
cd /
umount /usr (if this doesn't work "fuser -k /usr" and then try again.)
mount (sanity check)
cd /usr
ls (sanity check)
rm -rf *

-reboot and check that disk space
df (or df -h)

Monday, September 13, 2010

Error on export PLS-00201: identifier 'SYS.DBMS_DEFER_IMPORT_INTERNAL' must be declared

Error --------------------------------
EXP-00008: ORACLE error 6550 encountered
ORA-06550: line 1, column 18:
PLS-00201: identifier 'SYS.DBMS_DEFER_IMPORT_INTERNAL' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1204
ORA-06512: at "SYS.DBMS_SQL", line 323
ORA-06512: at "SYS.DBMS_EXPORT_EXTENSION", line 97
ORA-06512: at "SYS.DBMS_EXPORT_EXTENSION", line 126
ORA-06512: at line 1
. . exporting table DEF$_AQERROR
EXP-00008: ORACLE error 6510 encountered
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.DBMS_EXPORT_EXTENSION", line 50
ORA-06512: at "SYS.DBMS_EXPORT_EXTENSION", line 126
ORA-06512: at line 1

Solution -------------------------------------------------------


grnat execute on SYS.DBMS_DEFER_IMPORT_INTERNAL to [User];
grant execute on SYS.DBMS_EXPORT_EXTENSION to [User];

Tuesday, July 20, 2010

My FZ8

In 2007, first time i bought new camera for my own usage. I took several hunderds of photos animals, flowers and erath. With this section i may invite photo lovers to joine with us to share idears and maintain digital photo galary. I uses panasonic FZ8 camera for photography. Also will be implement a new photographic forum for srilankan fans. Intention is to share idears amoung our comunity and helps to biginers to come with a crative idears. I think all our fance will be please with my photo galary

Wednesday, May 19, 2010

High-water Mark

This is a term used with table segments stored in the database. If you envision a table, for example, as a 'flat' structure or as a series of blocks laid one after the other in a line from left to right, the high-water mark (HWM) would be the rightmost block that ever contained data, as illustrated in Figure 10-1.

+---- high water mark of newly created table
|
V
+--------------------------------------------------------+
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

high water mark after inserting 10,000 rows
|
v
+--------------------------------------------------------+
|x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | |
|x |x |x |x |x |x |x |x |x |x |x |x | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+


high water mark after inserting 10,000 rows
|
v
+--------------------------------------------------------+
|x |x |x |x |x |x |x | | | | | | | | | | | | |
|x |x |x |x |x |x |x | | | | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+


Figure 10-1. Depiction of an HWM

Figure 10-1 shows that the HWM starts at the first block of a newly created table. As data is placed into the table over time and more blocks get used, the HWM rises. If we delete some (or even all) of the rows in the table, we might have many blocks that no longer contain data, but they are still under the HWM, and they will remain under the HWM until the object is rebuilt, truncated, or shrunk (shrinking of a segment is a new Oracle 10g feature that is supported only if the segment is in an ASSM tablespace).

The HWM is relevant since Oracle will scan all blocks under the HWM, even when they contain no data, during a full scan. This will impact the performance of a full scan¿especially if most of the blocks under the HWM are empty. To see this, just create a table with 1,000,000 rows (or create any table with a large number of rows), and then execute a SELECT COUNT(*) from this table. Now, DELETE every row in it and you will find that the SELECT COUNT(*) takes just as long (or longer, if you need to clean out the block! Refer to the 'Block Cleanout' section of Chapter 9) to count 0 rows as it did to count 1,000,000. This is because Oracle is busy reading all of the blocks below the HWM to see if they contain data. You should compare this to what happens if you used TRUNCATE on the table instead of deleting each individual row. TRUNCATE will reset the HWM of a table back to 'zero' and will truncate the associated indexes on the table as well. If you plan on deleting every row in a table, TRUNCATE¿if it can be used¿would be the method of choice for this reason.

In an MSSM tablespace, segments have a definite HWM. In an ASSM tablespace, however, there is an HWM and a low HWM. In MSSM, when the HWM is advanced (e.g., as rows are inserted), all of the blocks are formatted and valid, and Oracle can read them safely. With ASSM, however, when the HWM is advanced Oracle doesn¿t format all of the blocks immediately¿they are only formatted and made safe to read upon their first use. So, when full scanning a segment, we have to know if the blocks to be read are 'safe' or unformatted (meaning they contain nothing of interest and we do not process them). To make it so that not every block in the table need go through this safe/not safe check, Oracle maintains a low HWM and a HWM. Oracle will full scan the table up to the HWM¿and for all of the blocks below the low HWM, it will just read and process them. For blocks between the 'low HWM' and the HWM, it must be more careful and refer to the ASSM bitmap information used to manage these blocks in order to see which of them it should read and which it should just ignore.

Code provide by me to reuse the import.

DECLARE

CURSOR shrink_table IS
SELECT table_name FROM all_tables
WHERE owner = 'DPG'
AND tablespace_name = 'USERS'
ORDER BY table_name;

BEGIN

FOR cur_st IN shrink_table LOOP

EXECUTE IMMEDIATE 'ALTER TABLE ' || cur_st.table_name || ' ENABLE ROW MOVEMENT';
EXECUTE IMMEDIATE 'ALTER TABLE ' || cur_st.table_name || ' SHRINK SPACE';

END LOOP;

END;

Tuesday, April 13, 2010

Oracle on ubuntu

1 Why Ubuntu?

Ubuntu is a recent distribution that continualy evolve. Its based on another distribution: Debian. So we have for example the packet system that have made it famous: apt-get. Ubuntu's advantage is it capacity to evolve quickly, a new stable version is released every 6 months, it « user-friendly » orientation, it philosophy (I let you discover more on this distribution to this address: http://www.ubuntulinux.org), and more generaly the GNU/Linux philosophy that we don't detail here.

The actual stable version is the 5.10 « Breezy Badger » version.This distribution is Desktop orientated. You could use it as a server distribution too, it's not a problem. The next version will be the 6.06 « Dapper Drake » and it'll have a professionnal and a server version.

But you'll ask me something: If Ubuntu is easy as I said, why create a How To on it? As a matter of fact, Oracle have modify it installer for unallowed some distribution. So Oracle cannot be installed, but there is a tips.

2 Before the installation
2.1 Downloading, libraries installation

First, we have to get the Oracle 10g RC2 installer for Linux. You have to go on the Oracle site: http://www.oracle.com and download it (you'll have to register) Then type this line to install the necessary libraries :

sudo apt-get install gcc, make, binutils,libmotif3,lesstif2,rpm,libaio,zip

After the download, we have to unzip the archive file that we have download:

unzip fichier_d'installation_oracle.zip

2.2 Red Hat simulation

The first thing to do in the system's preparation is to simulate a Red Hat distribution. Don't worry, it's not difficult when you follow the guide. The Red Hat is differenciated by Ubuntu in the directory architecture. So we'll create some symbolic link to simulate the Red Hat architecture:

sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/bin/rpm /bin/rpm
sudo ln -s /usr/bin/basename /bin/basename
sudo ln -s /etc /etc/rc.d

To finish with this step, we have to create a file /etc/redhat-release that countain the information of the Red Hat system, this file is scanned by the installer and if it doesn't exist or if the information countained are wrong, the installer will not work:

sudo gedit /etc/redhat-release

Copy/Paste the following text:

Red Hat Linux release 3.0 (drupal)

2.3 Users / groups Oracle's creation and some modification

This will simply create the system requirement:


sudo userdel nobody
sudo groupadd oinstall
sudo groupadd dba
sudo groupadd nobody
sudo useradd -g oinstall -G dba -p passwd -d /home/oracle oracle -s /bin/bash
sudo useradd -g nobody nobody

Now, we create the directory where Oracle will be installed

sudo mkdir -p /u01/app/oracle
sudo mkdir -p /u02/oradata
sudo chown -R oracle:oinstall /u01 /u02
sudo chmod -R 775 /u01 /u02

At the end of /etc/security/limits.conf add the following:


* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536

In the file /etc/pam.d/login, /etc/pam.d/su uncomment the following:

session required /lib/security/pam_limits.so

Add this line to /etc/profile

if [ $USER = "oracle" ]; then
ulimit -u 16384 -n 65536
fi

Add the following lines to the end of /home/oracle/.bashrc (open it in root or oracle user):


umask 022
PATH=${PATH}:/u01/app/oracle/oracle/product/10.2.0/db_1/bin/

ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/db_1/
ORACLE_SID=orcl
ORATAB=/etc/oratab
ORACLE_HOME_LISTNER=$ORACLE_BASE
ORACLE_BASE=$ORACLE_HOME

export ORACLE_BASE ORACLE_SID ORATAB ORACLE_HOME ORACLE_HOME_LISTNER

The system is now correctly configurated. Well going to the next step.

Launch a terminal and execute the following:

cd your_database_dir
xhost +
sudo su
su oracle
ORACLE_BASE=/u01/app/oracle
ORACLE_SID=orcl
export ORACLE_BASE ORACLE_SID
unset ORACLE_HOME
unset TNS_ADMIN
ORATAB=/etc/oratab
umask 022
./runInstaller

Open a terminal and do (in our case)

sudo /u01/app/oracle/oracle/product/10.2.0/db_1/oraInventory/orainstRoot.sh
sudo /u01/app/oracle/oracle/product/10.2.0/db_1/root.sh