Friday, 22 July 2011

Oracle Startup

There are 5 states an Oracle database goes through during the startup process.
  1.  Shutdown
    The database is shutdown and cannot be connected to by anyone but SYS.
  2. Startup nomount
    During this phase the database reads the initialization parameters from the spfile or pfile. If you get an error at this stage, it's best to check this file exists, is accessible and contains no errors.
    This phase does not allow access to the database and is usually only done for database creation, or recreation of control files.
  3. Startup mount
    During this phase the database checks the control file, this is a small binary file that records the physical structure of the database.
    If you receive errors during the mount phase, then it is best to check the control file exists.
    This phase allows for certain DBA activities to take place, but does not allow general access to the database.
  4. Startup open
    During this phase the database tries to start in open mode, ready for all users to access. It checks the datafiles exist and any errors at this stage you should check the datafiles.
    This phase can be run in restricted or unrestricted mode, depending on whether you want all users to have access or not.

Thursday, 21 July 2011

Windows - Check what is running on port #

To find out what processes are running a certain port on a windows environment you can issue the following on the command line:
C:/ netstat -o
Proto Local Address Foreign Address State PID
TCP Harvey:1050 localhost:27015 ESTABLISHED 2504
TCP Harvey:1056 localhost:5354 ESTABLISHED 1756
TCP Harvey:1110 localhost:1111 ESTABLISHED 5972
TCP Harvey:1111 localhost:1110 ESTABLISHED 5972
TCP Harvey:1112 localhost:1113 ESTABLISHED 5972
TCP Harvey:1113 localhost:1112 ESTABLISHED 5972
TCP Harvey:1342 localhost:12080 ESTABLISHED 5972
TCP Harvey:1353 localhost:12080 ESTABLISHED 5972
TCP Harvey:1359 localhost:12080 ESTABLISHED 5972

For a more detailed view of active connections you can issue:
C:/ netstat -noa
Active Connections

Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1332
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4

Tuesday, 19 July 2011

Linux - Shutdown halt server

If you want to shutdown a server from the box without it coming back up again you can issue the shutdown command with the -h flag as shown below:
$ shutdown -h now
Broadcast message from root (pts/1) (Fri Jul 8 15:11:33 2011):
The system is going down for system halt NOW!
This should only be issued by the root user and will terminate all sessions to the box. To restart the box you will need to manually switch it back on. The shutdown -r now command is preferred, as this will bring the box down and restart. Use the -h command with caution and only when necessary.

Monday, 18 July 2011

Linux - kill process by UID

To kill all processes by a userid issue the following command:
$ pkill -u <uid>