Pages

Sunday, February 20, 2011

Database Tools - PL/SQL programming

Built-in Functions
•Character Functions
–UPPER(string)  converts text to uppercase
–LOWER  converts text to lowercase
–INITCAP  capitalises first letter of each word
–LENGTH  string length including pads
–LTRIM  trims characters from left
–RTRIM  trims characters from right
–RPAD  pads a string on the right
•Number Functions
            –Trigonometric functions
            –Mathematical functions
•Conversion Functions
            –TO_CHAR converts dates, numbers to varchar2
            –TO_DATE converts text to dates (correct format)
            –TO_NUMBER converts text to numbers
•Number Functions
            –Trigonometric functions
            –Mathematical functions
•Conversion Functions
–TO_CHAR  converts dates, numbers to varchar2
–TO_DATE  converts text to dates (correct format)
–TO_NUMBER converts text to numbers


•Grouping Functions (cf SQL)
            –AVG
            –COUNT
            –SUM
•Miscellaneous
            –object functions
            –SQLCODE
            –SQLERRM
            –UID
            –USER

STORED PROCEDURE
Syntax

CREATE [OR REPLACE] PROCEDURE procedure_name
   (arg1 [IN] datatype, .. arg2 OUT datatype, arg3 INOUT datatype)
AS | IS
  {variables;}
BEGIN
  {statements;}
END;


FUNCTION
Syntax
CREATE [OR REPLACE] FUNCTION function_name
 (arg1 [IN] datatype, .. arg2 OUT datatype,  .. arg4  INOUT datatype )
  RETURN datatype
AS | IS
  {variables;}
BEGIN
  {statements;}
RETURN returnstatement;
END;        

PACKAGE

Encapsulated collection of schema objects (procedures, functions, cursors, variables, constants and exceptions)
Advantages
           •Better organisation of the application (each package has clear, well defined interfaces )
           •Privileges are granted more easily
           •Variables and cursors persist for the session
           •Allow procedure and function overloading
           •Reduce I/O by loading schema objects simultaneously
           •Code re-use
Syntax
  CREATE [OR REPLACE] PACKAGE pack_name AS
  {FUNCTION f_name(arg1…);}
  {PROCEDURE p_name(arg1…);}
  {variables;}
  {cursors;}
  END pack_name;

TRIGGER
Trigger Types and Events
 15 triggers
–4 basic types
  Before Statement
  Before Row
  After Row
  After Statement
–for each of 3 statements
  Insert, Update, Delete
–instead of triggers (Views)
  Insert, Update, Delete

Syntax
CREATE [OR REPLACE] TRIGGER name
    { BEFORE | AFTER }
  {INSERT | UPDATE | DELETE [OF column_name]}
  ON table_name
  [FOR EACH ROW [WHEN [(condition)]]]
       DECLARE
  {declarations;}
       BEGIN
  {code statements;}
       END;


Limitations on Views
–limited updatability
           •distinct not specified
           •every element is a column (not an aggregate function)
           •only the many side of a 1:many
–inserts only into one table
           •must contain all not null columns
           •no violation of integrity constraints

Instead of Triggers
CREATE [OR REPLACE] TRIGGER name
    INSTEAD OF {INSERT | UPDATE | DELETE }  ON view_name
  FOR EACH ROW
         BEGIN
  {statements;}
         END;
eg:-
CREATE OR REPLACE TRIGGER credit

AFTER INSERT ON ord
FOR EACH ROW
DECLARE
  balance number;
BEGIN
  SELECT credit_balance INTO balance FROM customer
  WHERE customer_id = :NEW.customer_id;
  balance := balance - :NEW.total;
  UPDATE customer
  SET credit_balance = balance
  WHERE customer_id = :NEW.customer_id;
END;

CURSOR
eg:-
DECLARE

CURSOR c_emp IS
SELECT * FROM emp
WHERE department = ‘LONDON’;
BEGIN
   FOR emp_record IN c_emp LOOP
      IF emp_record.salary_type = ‘HOURLY’ THEN
  emp_record.salary_rate := emp_record.salary_rate * 1.1;
      ELSEIF emp_record.salary_type = ‘MONTHLY’ THEN
  emp_record.salary_rate := emp_record.salary_rate + 90;
      END IF;
   END LOOP;
   COMMIT;
END;

Friday, February 11, 2011

Oracle Administration Identify Environment


Checking Your Current Release Number

COL PRODUCT FORMAT A35
COL VERSION FORMAT A15
COL STATUS FORMAT A15 
SELECT * FROM PRODUCT_COMPONENT_VERSION;

PRODUCT                                  VERSION     STATUS
---------------------------------------- ----------- -----------
NLSRTL                                   10.2.0.1.0  Production
Oracle Database 10g Enterprise Edition   10.2.0.1.0  Prod
PL/SQL                                   10.2.0.1.0  Production

Database Administration

EASY CONNECT
The easy connect naming method provides TCP/IP connectivity to databases without the
  • # sqlplus /@:/
  • # sqlplus sys/oracle@:1521/
STARTING AND STOPPING THE DATABASE CONTROL PROCESS
  • # emctl start dbconsole
  • # emctl stop dbconsole
  • # emctl status dbconsole
STARTUP OPTIONST.Simmonds 2010
--The instance reads the initialization parameter file, allocates SGA memory, and starts the background processes
  • SQL> startup nomount;  
--The instance opens the database control file, but does not open the datafiles 
  • alter database mount;
--Instance opens the redo log files and datafiles for the database25
  • SQL> alter database open; 
  • SQL> startup;
SHUTTING DOWN A DATABASE INSTANCE I
  • SQL> shutdown normal
  • SQL> shutdown immediate
  • SQL> shutdown abort
  • SQL> shutdown transactional
  • SQL> shutdown
CREATE USER
SQL> CREATE USER jsmith IDENTIFIED BY password
     DEFAULT TABLESPACE “USERS” 
     TEMPORARY TABLESPACE “TEMP” 
     PROFILE clerk ACCOUNT UNLOCK;

GRANTING SYSTEM PRIVILEGES

SQL> GRANT { system_privilege| role | ALL PRIVILEGES } 
     TO { user | role | PUBLIC } [, { user | role | PUBLIC }]
     IDENTIFIED BY password] 
     [WITH ADMIN OPTION]

GRANTING OBJECT PRIVILEGES

SQL> GRANT update (department_id, location_id)
     ON departments
     TO scott, manager
     WITH GRANT OPTION;

CONFIRMING PRIVILEGES GRANTED

Data Dictionary View
  • ROLE_SYS_PRIVS                System privileges granted to roles
  • ROLE_TAB_PRIVS               Table privileges granted to roles
  • USER_ROLE_PRIVS             Roles accessible by the user
  • USER_TAB_PRIVS_MADE  Object privileges granted on the user’s objects
  • USER_TAB_PRIVS_RECD   Object privileges granted to the user
  • USER_COL_PRIVS_MADE  Object privileges granted on the columns of the user’s objects
  • USER_COL_PRIVS_RECD   Object privileges granted to the user on specific columns
  • USER_SYS_PRIVS                System privileges granted to the user
CREATING ROLES
  • SQL> CREATE ROLE manager IDENTIFIED BY mgr_password;
  • SQL> SET ROLE manager IDENTIFIED BY mgr_password;
CREATING PROFILES
SQL> CREATE PROFILE app_user LIMIT 
     SESSIONS_PER_USER UNLIMITED 
     CPU_PER_SESSION UNLIMITED 
     CPU_PER_CALL 3000 
     CONNECT_TIME 45 
     LOGICAL_READS_PER_SESSION 
     DEFAULT LOGICAL_READS_PER_CALL 1000 
     PRIVATE_SGA 15K

     FAILED_LOGIN_ATTEMPTS 5
     PASSWORD_LIFE_TIME 60
     PASSWORD_REUSE_TIME 60
     PASSWORD_REUSE_MAX 5
     PASSWORD_LOCK_TIME 1/24;

SUPPLIED PASSWORD VERIFICATION FUNCTION

SQL> ALTER PROFILE DEFAULT LIMIT 
     PASSWORD_VERIFY_FUNCTION 
     verify_function_11g;


MANAGING DATABASE STORAGE STRUCTURES
CONTROL FILES DATA DICTIONARY VIEWS

V$DATABASE                         Displays database information from the control file
V$CONTROLFILE                   Lists the names of control files
V$CONTROLFILE_RECORD_SECTION       Displays information about control file record sections
V$PARAMETER         Names of control files as specified in the CONTROL_FILES initialization parameter

SQL> SELECT NAME FROM V$CONTROLFILE;

CREATING A TABLESPACE 
Permanent
      SQL> create tablespace ts_data
           datafile '/home/oracle/db1/data.dbf' 
           size 10M 
           autoextend on 
           maxsize 200M 
           extent management local 
           uniform  size 64K;
Temporary
      SQL> create temporary tablespace ts_temp
           tempfile'/home/oracle/db1/temp01.dbf' 
           size 5M 
           autoextendon;
Undo
     SQL> create undotablespace ts_undo
          datafile'/home/oracle/db1/undo.dbf '
          size 100M;

Managing Schema Objects&Managing Data
CREATING AND MODIFYING TABLES

SQL> CREATE TABLE hr.new_jobs (
     job_id NUMBER(5)CONSTRAINT jobid_id_pk PRIMARY KEY,
     job_title VARCHAR2(30)CONSTRAINT jib_title UNIQUE,
     min_salary NUMBER(6),
     max_salary NUMBER(6),
     CONSTRAINT fk_deptno FOREIGN KEY (job_title) REFERENCES
     job(job_title)
     )
     TABLESPACE users;

SQL> ALTER TABLE hr.new_jobs ADD bonus NUMBER(6);

Copy table structure and the data (only NOT NULL constraint will be copied into the new table)
SQL> CREATE TABLE my_jobs AS SELECT * FROM hr.new_jobs;

Truncate table
SQL> TRUNCATE TABLE hr.employees;

Disable Constraint 
SQL> ALTER TABLE empDISABLE CONSTRAINT emp_empno_pk CASCADE;

Add Constraint
SQL> ALTER TABLE dept_20
     ADD CONSTRAINT fk_empid_hiredate
     FOREIGN KEY (employee_id, hire_date)
     REFERENCES hr.job_history(employee_id, start_date)
     EXCEPTIONS INTO wrong_emp;

RESOLVING LOCK CONFLICTS WITH SQL

SQL> select sid, serial#, username from v$session 
     where sid in (select blocking_session from v$session)
SQL> alter system kill session '144,8982' immediate;


Flashback Technology

Flashback Drop
reverses the effects of a DROP TABLE operation
Flashback Table
rewinds tables to a specified point in time with a single statement
Flashback Database
rewinds an Oracle database to a previous time to correct problems caused by logical data corruptions or user errors
Flashback Query (Version Query, Transaction Query)
allows to query all data at a specified point in time, trieves all the versions of the rows that exist between two points in time

SQL> SELECT owner, original_name, object_name,type, ts_name, 
     droptime, related, space
     FROM dba_recyclebin
     WHERE can_undrop = 'YES';



SQL> FLASHBACK TABLE table_name
     TO BEFORE DROP [RENAME TO new_name];

SQL> FLASHBACK TABLE bonus TO SCN 6099208;

SQL> FLASHBACK TABLE bonus TO TIMESTAMP (SYSTIMESTAMP –INTERVAL '1' minute);

DROPTABLEPURGEcommand permanently drops a table and its dependent objects from the database, bypassing the Recycle Bin

SQL> DROP TABLE [PURGE];

FLASHBACK VERSIONS - PSEUDO COLUMNS
Flashback Version Query returns a table with a row for each version of the row that existed at any time during the specified time interval. Each row in the table includes pseudo columns of metadata about the row version

VERSIONS_STARTTIME, VERSIONS_STARTSCN
This pseudocolumnidentifies the time when the data first had the values reflected in the row version

VERSIONS_ENDTIME, VERSIONS_ENDSCN
SCN or TIMESTAMP when the row version expired

VERSIONS_XID
Transaction that created the version

VERSIONS_OPERATION
Operation that produced the version: I for insertion, D for deletion, or U for update

SQL> SELECT versions_startscn, versions_starttime, versions_endscn,         versions_endtime,versions_xid, versions_operation,last_name, salary
     FROM employees
     VERSIONS BETWEEN TIMESTAMP
     TO_TIMESTAMP('2008-12-18 14:00:00','YYYY-MM-DD HH24:MI:SS')
     AND TO_TIMESTAMP('2008-12-18 17:00:00','YYYY-MM-DD HH24:MI:SS')
     WHERE first_name= 'John'

CONFIGURING DATABASE FOR THE FLASHBACK
Before you can issue the command to Flashback, Database must be configured for archiving and FLASHBACK enabled

SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE FLASHBACK ON;

Database must be started in MOUNT mode
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;


SQL> FLASHBACK DATABASE TO TIMESTAMP(SYSDATE-1/24); OR
SQL> FLASHBACK DATABASE TO SCN 53943;

To view changes the database can be opened in read-only mode.The database must be opened read/write with the RESETLOGS option when finished

SQL> ALTER DATABASE OPEN RESETLOGS;

Database Backup and Recovery

RECOVERY MANAGER
  • Automatically diagnoses data failures
  • Determines and presents appropriate repair options
  • Performs repairs if requested by the user
SQL> rman target /
RMAN> backup database;
RMAN> configure controlfile autobackup on;


RMAN> list failure;
RMAN> advise failure;
RMAN> repair failure;

Moving Data between Systems

SQL*LOADER CONTROL FILE

Empl.ctl
LOAD DATAINFILE ’empl.dat’BADFILE ’empl.bad’DISCARDFILE ’empl.dsc’APPENDINTO TABLE empFIELDS TERMINATED BY ‘,’TRAILING NULLCOLS(empno integer external(4),last name,first name,email,deptno integer external(2),sal decimal external (5,2),hiredateSYSDATE));
INFO ABOUT EXTERNAL TABLES
DBA_EXTERNAL_TABLES
DBA_EXTERNAL_LOCATIONS
DBA_TABLES
ALL_EXTERNAL_TABLES
ALL_EXTERNAL_LOCATIONS
ALL_TABLES
DATA PUMP EXPORT / IMPORT
expdp admin/oracleFULL=yPARALLEL =2 TDIRECTORY=data_pump_dirDUMPFILE=HREXP01_U%.DMP, HREXP02_U%.DMP,FILESIZE=2GCOMRESSION=all
impdp admin/oracleFULL=yPARALLEL =2DIRECTORY=data_pump_dirDUMPFILE=HREXP01_U%.DMP,HREXP02_U%.DMP 

Friday, October 1, 2010

Network related Commands

Display Connection Configuration: ipconfig /all

Display DNS Cache Info: ipconfig /displaydns

Clear DNS Cache: ipconfig /flushdns

Release All IP Address Connections: ipconfig /release

Renew All IP Address Connections: ipconfig /renew

Re-Register the DNS connections: ipconfig /registerdns

Change/Modify DHCP Class ID: ipconfig /setclassid

Network Connections: control netconnections

Network Setup Wizard: netsetup.cpl

Test Connectivity: ping whatismyip.com

Trace Route: tracert

Displays the TCP/IP protocol sessions: netstat

Display Local Route: route

Display Resolved MAC Addresses: arp

Display Name of Computer Currently on: hostname

Display DHCP Class Information: ipconfig /showclassid

NameServer Lookup: nslookup whatismyip.com

Wednesday, June 9, 2010

Oracle 10g Quick Installation

Oracle Prerequisites and Install Requirements

Login to Solaris 10 server as root and open a terminal window
# /usr/sbin/prtconf | grep Memory - Check RAM (Recommended 1GB)
# /usr/sbin/swap –s - Check Swap (Free Space on swap)
# df -h /tmp - Check /tmp (Recommended 750MB)
# uname –r - Check Solaris Version
# hostname - Check host name

Check for Required installed Solaris Packages
# pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWi1of
SUNWi1cs SUNWi15cs SUNWxwfnt

If any package is missing (not installed), install them using Solaris 10 CD pack as below example
#pkgadd -d . SUNWi1cs

Create User Groups, Oracle Users & .profile
To create user groups related to oracle, edit group file using vi editor and add 2 user groups
(oracle, oinstall) as per below
# vi /etc/group
dba::101:
oinstall::100:oracle

To create oracle user refer the below sequence
# mkdir /export/home/oracle
# vi /etc/passwd
oracle:x:101:101:Oracle Super User:/export/home/oracle:/sbin/sh

# pwconv
# chown –R oracle:dba /export/home/oracle
# passwd –r files oracle
To check the oracle user ID, group use below command
(if output doesn’t match with example correct live machine according to example)

# id -a oracle
uid=101(oracle) gid=101(dba) groups=100(oinstall)
To change primary (-g) and supplementary (-G) groups

# usermod –g 101 –G 100 oracle
To create oracle user .profile follow the instructions below

#vi /export/home/oracle/.profile
umask 022 -> default permission
TMP=/tmp -> TMP to directory /tmp
TMPDIR=$TMP -> TMPDIR to same directory /tmp
DISPLAY=localhost:0.0 -> Display to local host
export TMP TMPDIR DISPLAY -> export to make available as env.
ORACLE_BASE=/oracle/app/oracle -> oracle products to installing dir.
ORACLE_HOME=/oracle/app/oracle/10.2.0/db1 -> oracle home dir. for executables
ORACLE_SID=orcl -> oracle instance (orcl is default)
PATH=$ORACLE_HOME/bin:$PATH -> dir. to search commands & prgs.
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH -> export to make available as env.

Configure Solaris 10 System Parameters Using
Resource Control Projects
#projadd oracle - Create a new resource project
Add new line to “/etc/user_attr" file
oracle::::project=oracle
#su – oracle
$ id –p - Check oracle user
uid=101(oracle) gid=101(dba) projid=100(oracle)
(if output doesn’t match with example correct live machine according to example)

$ prctl -n project.max-shm-memory -i project oracle - Check shared memory
project: 100: oracle
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
privileged 254MB – deny - To be increased for better performance
system 16.0EB max deny
To set the kernel system value for the shared memory parameter, open another root shell and
perform the following two commands, make sure at least one terminal session is still logged in as
the oracle user. Then from root user shell issue these commands to set shared memory to 4GB.

# prctl -n project.max-shm-memory -v 4gb -r -i project oracle
# projmod -s -K "project.max-shm-memory=(priv,4gb,deny)" oracle

The first dynamically resets the value, while the second makes changes to the "/etc/project" file
so the value is persistent between reboots. To see changes to /etc/project perform the following
# cat /etc/project
system:0::::
user.root:1::::
noproject:2::::
default:3::::
group.staff:10::::
oracle:100::::project.max-shm-memory=(priv,4294967296,deny)

Now to go back to the oracle shell command terminal and type the following again to see that
the project information has been update to 4GB for the shared memory kernel system
parameter.
$ prctl -n project.max-shm-memory -i project oracle
project: 100: oracle
NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
project.max-shm-memory
privileged 4.00GB – deny - New value of Shared Memory
system 16.0EB max deny
If performed a new default Solaris installation, it is likely that this is the only system kernel
parameter you need to set is "max-shm-memory" for Oracle 10g.

Install Oracle® 10g
Logout from root and Login as user oracle
To install oracle on Solaris 10 first you have to transfer the zip (compressed) file to server
Insert CDROM containing oracle 10g ‘zip’ file (ex: 10202_database_solx86.zip)
NOTE : Recommended minimum free space required
Mount Total Free
--------- --------- ----------------------------------------------------
/ 6GB 3GB -> root
/oracle 6GB 6GB -> Oracle installing directory
/export/home 1GB -> Users home directories
/u01 3GB 2GB -> to transfer & unzip compressed file
/archive 8GB 8GB -> if only archiving is enabled

#cd /cdrom
#cp –R 10202_database_solx86.zip /u01
#cd /u01
#unzip 10202_database_solx86.zip
#cd database
#./runInstaller

Basic installation will be enough for the requirement
Insert & confirm ‘database password’ here
Keep system group name ad ‘dba’

If warning displays on below checks ‘check’ to ‘user verified’
Confirm to Install

Wait for installation completes,…..
Another screen you will see

Change if required a last minute password change,…

Installation seems to be successful
Once you see this pop-up window open a new terminal windows, log in as root and run the
specified scripts,…. Once complete come back to this window and press ‘ok’

Example screen dumps of above
CONGRATULATIONS !!! you have installed the Oracle 10g successfully.
Refer the web link on below window to “Enterprise Manager Control”
Ie,.. http://:1158/em

Press ‘Installed Products’ to check installed components

Install Oracle® 10g Web Administration
Logout from root and Login as user oracle to check and start listener control
# su – oracle
$ lsnrctl start
$ emctl start dbconsole
or
To Log into Enterprise Manager start your ‘web browser’

Tuesday, April 20, 2010

Installing gcc compiler on Solaris 10

1 Installing gcc compiler on Solaris 10
1.1 Extract Packges
After downloading create and move files to the directory /download and gunzipped them
bash-3.00# cd download
bash-3.00# gunzip gcc-3.4.6-sol10-x86-local.gz 
bash-3.00# gunzip libiconv-1.11-sol10-x86-local.gz

1.2 Install libiconv package
After that installed the libiconv package first, since that is a requirement.
bash-3.00# pkgadd -d libiconv-1.11-sol10-x86-local

Select package(s) you wish to process (or 'all' to process all packages).
(default: all) [?,??,q]: all


Do you want to install these conflicting files [y,n,?,q] y


1.3 Install gcc-3.4.6-sol10-x86-local
bash-3.00# pkgadd -d gcc-3.4.6-sol10-x86-local.gz

Select package(s) you wish to process (or 'all' to process all packages).
(default: all) [?,??,q]: all


Do you want to install these conflicting files [y,n,?,q] y  


1.4 Check gcc installation
bash-3.00$ gcc -v



1.5 Install & test GNU "make"
1.5.1 Extract and check
bash-3.00# gzip -d make-3.81-sol10-x86-local.gz 
bash-3.00# head make*

1.5.2 Install make into /usr/local/bin:
bash-3.00# rlogin localhost -l root (optional if you're already root)
bash-3.00# cd /download
.bash-3.00# pkgadd -d make-3.81-sol10-x86-local


1.5.3 Test the installation: 
bash-3.00# /usr/sbin/pkgchk -d make* SMCmake


1.6 Set class path
Add class path to .cshrc or .profile file
path= /bin/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/lib:/usr/ccs/bin:/usr/local/bin:/usr/bin: /usr/sfw/bin:$path

Note : check with ‘# env’ to make sure the PATH you enter is active

2 Test GCC and GMAKE
2.1 Test GCC
To test GNU "gcc" on a simple C src program
bash-3.00# mkdir /tmp/test 
bash-3.00# vi /tmp/test/hello.c #include main() { printf("Hello world.\n"); return 0; }

bash-3.00# gcc /tmp/test/hello.c -o /tmp/test/hello.exe
bash-3.00# /tmp/test/hello.exe


2.2 Test gmake
To test GNU "gmake" using a simple Makefile
bash-3.00# vi /tmp/test/Makefile


bash-3.00# cd /tmp/test 
bash-3.00# gmake hello 
bash-3.00# ./hello

Jboss-4.0.2 Application Server in Solaris 10

1 Jboss-4.0.2 Application Server in Solaris 10
1.1 Directory structure
1.2 Check pre condition
Check the disk space in /apps to make sure that it still have enough space for installation. ( put the JBoss folder inside /apps folder)

# bash
bash-3.00# df -h /apps

Filesystem size used avail capacity Mounted on
       /dev/dsk/c0d0s0 7.7G 3.7G 3.9G 49% /

1.3 Installation
1.3.1 Unzip the JBoss file to /apps folder:

bash-3.00# unzip /Desktopjboss-4.0.2.zip -d /apps/
Wait until the unzip process is finished. Then the JBoss folder (jboss-4.0.2.zip) should be exist in the /apps folder.

To verify the folder I type this command:
bash-3.00# ls -la
/apps/ drwxr-xr-x 6 root sys 512 Apr 20 21:12 .
drwxr-xr-x 41 root root 1024 Apr 20 20:16 ..
drwxr-xr-x 3 root bin 512 Apr 12 13:20 SUNWits
drwxr-xr-x 4 root bin 512 Apr 12 13:35 SUNWmlib
drwxr-xr-x 8 root root 512 Dec 4 21:28
jboss-4.0.2.zip.zip drwxr-xr-x 8 root root 512 Apr 12 13:45 staroffice8
bash-3.00#

1.4 Start Web Servewr
1.4.1 Start (run) the JBoss AS:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# sh run.sh –c default

By default JBoss will use port 8080. If your port is conflict with other web server, you can change the JBoss port number to something else. Now, I open the browser then type in:

http://localhost:8080 or http://192.168.1.IP:8080

1.4.2 Stop (shutdown) the JBoss:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# ./shutdown.sh –s
or
if started as a service
bash-3.00# sh shutdown.sh -s 127.0.0.1 -S
Server shutdown may take a while - check logfiles for completion

1.4.3 Delete work and tmp folders inside following folder
bash-3.00# cd /apps/jboss-4.0.2/server/default/
bash-3.00# rm –r tmp work


1.5 Deployment Web Application in jboss-4.0.2
1.5.1 Deploy web application in JBoss AS.
To deploy the web application, just copy the icard.war file to the /apps/jboss-4.0.2/server/default/deploy folder:
To verify that the file is copied successfully, use this command:
bash-3.00# cd /apps/jboss-4.0.2/server/default/deploy
bash-3.00# ls -la | grep war

drwxr-xr-x 6 root root 512 Dec 4 17:23 ROOT.war
drwxr-xr-x 6 root root 512 Dec 4 17:23 jmx-console.war
-rw-r--r-- 1 root root 4157406 Apr 21 12:30 Application_name.war

1.5.2 Start the application server:
bash-3.00# cd /apps/jboss-4.0.2/bin/
bash-3.00# sh run.sh –c default
or
bash-3.00# /apps/jboss-4.0.2/bin/run.sh -b 127.0.0.1

During the JBoss AS is running, it will automatically deploy the war file. Notice this message in the JBoss console: 13:40:37,159 INFO [TomcatDeployment] deploy, ctxPath=/icard, vfsUrl=icard.war

1.5.3 Application dependencies
If there is application dependencies put inside /server/default/libs folder

1.5.5 Enabling login module for jboss
1.5.5.1 jboss-web.xml 
bash-3.00# cd /apps/ jboss-4.0.2/server/default/deploy/jmx-console.war/WEB-INF/
bash-3.00# vi jboss-web.xml

Uncomment following
< -- Uncomment the security-domain to enable security. You will need to edit the html adaptor login configuration to setup the login modules used to authentication users. java:/jaas/jmx-console -- >

1.5.5.2 Web.xml - Jass enable 
bash-3.00# cd /apps/ jboss-4.0.2/server/default/deploy/jmx-console.war/WEB-INF/
bash-3.00# vi Web.xml Uncomment following

HtmlAdaptor An example security config that only allows users with the role JBossAdmin to access the HTML JMX console web application /* GET POST JBossAdmin -- >

1.5.5.3 User name, password and user roles
bash-3.00# cd /apps/jboss-4.0.2/server/default/conf/props
Edit jmx-console-roles.properties and jmx-console-users.properties

1.5.5.4 Start web application.
Now open the browser and type in http://192.168.1.IP:8080/Application_name/


1.5.6 To remove the web Application
What we need to do is just delete the war file. It can be done during the server is running or server is offline. Suppose here, the JBoss AS is running.

To remove the web application:
bash-3.00# cd /apps/jboss-4.0.2/server/default/deploy
bash-3.00# rm -rf Application_name.war

After deletion, in the JBoss console will automatically remove this web application. 13:42:57,274 INFO [TomcatDeployment] undeploy, ctxPath=/icard, vfsUrl=icard.war

Trouble shooting solaris Network Configuration

ADD NETWORK ON SOLARIS 10 x86


press ifconfig -a on terminal and find the network connection (eg –bnx0, elxl0,lo0)

lo0: flags=2001000849 mtu 8232 index
inet 127.0.0.1 netmask ff000000



elxl0: flags=1000843 mtu 1500 index 2
inet 192.168.1.220 netmask ffffff00 broadcast 192.168.1.255
ether 0:b0:d0:69:d5:e

Then use following command to assign ip address
            bash-3.00# ifconfig bnx0 192.168.1.55 netmask 255.255.255.0 up

use following command to assign default router
            bash-3.00# route add default 192.168.1.1

Trouble shooting

Check hosts file
         bash-3.00# cat /etc/hosts
         127.0.0.1 localhost
         192.168.1.IP mcbsol10

Check IP range (should appear as below)
         bash-3.00# cat /etc/netmasks
         192.168.1.0 255.255.255.0

Check default router
         bash-3.00# etc/defaultrouter
        192.168.1.1

Check nodename file
        bash-3.00# cat /etc/nodename
        LiveServer

If Network is not working, even after you up network, then follow bellow list of commands

      bash-3.00# ifconfig bnx0 down

Unbind existing IP address to a Network Interface Card
      bash-3.00# ifconfig bnx0 unplumb


Bind an IP address to a Network Interface Card
       bash-3.00# ifconfig bnx0 plumb


       bash-3.00# ifconfig bnx0 192.168.1.220 netmask 255.255.255.0 up
(optional)
       bash-3.00# /etc/default/inetinit start

Enable Ftp for root

      bash-3.00# vi /etc/ftpd/ftpusers
      remove# root

Also, don't forget to edit the file /etc/ftpaccess and comment out the 'deny-uid' and 'deny-gid' lines.
If the file doesn't exist, there is no need to create it.


Configure Telnet for root logins

edit the file /etc/default/log-in as follows:

        # If CONSOLE is set, root can only login on that device.
        # Comment this line out to allow remote login by root.
        #CONSOLE=/dev/console
        # PASSREQ determines if log-in requires a password.
        #
        PASSREQ=YES

       # ALTSHELL determines if the SHELL environment variable should be set
       #
       ALTSHELL=YES

       # PATH sets the initial shell PATH variable
       #PATH=/usr/bin:

       # to log all root log-in at level LOG_NOTICE and multiple failed login
       #
       SYSLOG=YES