Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Quickly and Simply Reconfiguring a UNIX Server using sys-unconfig

Sys-unconfig is a useful utility for Solaris and Linux that allows you to reconfigure your networking. It is easier than doing it manually, which involves editing some or all of the following files depending upon the operating system and version:
  • /etc/defaultrouter
  • /etc/dladm/*
  • /etc/dumpadm.conf
  • /etc/hostname
  • /etc/inet/hosts
  • /etc/nodename
  • /etc/nsswitch.conf
  • /etc/resolv.conf
Sys-unconfig is used for restoring a server's configuration back to its original state, before it was configured. It "unconfigures" the following:
  • Host Name
  • Domain Name
  • Time Zone
  • IP Address
  • IP Subnet Mask
  • Root Password

How to configure native multipathing for Solaris 10

To configure Solaris 10's native multipathing you should first check to see if it is enabled. Look at the Fibre Channel Port Driver Configuration file located at /kernel/drv/fp.conf. By default multipathing is disabled on SPARC-based systems and enabled on x86-based systems.

Find the entry for mpxio-disable and set it to "no" like so:

mpxio-disable="no";


Ownership and permissions for ASM devices

When preparing devices for ASM set the following ownership and permissions:

chown <asm owner>:<asmdba group> <device>
chmod 660 <device>


Example:

chown grid:oinstall c5t60060E8006CFCC000000CFCC00000204d0s0
chmod 660 c5t60060E8006CFCC000000CFCC00000204d0s0

Mount an ISO image on Solaris


lofiadm -a /image-dir/image-name.iso
/dev/lofi/1

mount -F hsfs -o ro /dev/lofi/1 /mnt

Script to create Standard Groups, Users, and Paths on Solaris 10

#!/bin/ksh
# Example of Creating Standard Groups, Users, and Paths
# From Oracle Grid Infrastructure Installation Guide 11g Release 2 (11.2) for Oracle Solaris E24616-01

groupadd -g 1000 oinstall
groupadd -g 1020 asmadmin
groupadd -g 1021 asmdba
groupadd -g 1031 dba
useradd -m -d /export/home/grid -s /bin/bash -u 1100 -g oinstall -G dba,asmadmin grid
passwd grid
useradd -m -d /export/home/oracle/ -s /bin/bash -u 1101 -g oinstall -G dba,asmdba oracle
passwd oracle
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
chown -R grid:oinstall /u01
mkdir /u01/app/oracle
chown oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/

mkdir /opt/oracle
mkdir /opt/oraInventory
chown oracle:oinstall /opt/oracle
chown oracle:oinstall /opt/oraInventory
chmod 755 /opt/oracle
chmod 755 /opt/oraInventory

Add swap space to Solaris 10 zfs


# zfs create -V 16gb rpool/newswap
# swap -a /dev/zvol/dsk/rpool/newswap

Run UNIX shell script from Stored Procedure via DBMS_SCHEDULER

When you try to run a UNIX shell script directly from DBMS_SCHEDULER it runs as the UNIX owner nobody:nobody, which means it will likely have permissions problems and give the error ORA-27369. It is possible to configure DBMS_SCHEDULER so it will run as the oracle user (Metalink Doc ID 389685.1) but if you can't or don't want to do that you can do this:

First you have to give Java permission to access the script:

begin
dbms_java.grant_permission
('SYS',
'java.io.FilePermission',
'[path]/test.sh',
'execute');

dbms_java.grant_permission
('SYS',
'java.lang.RuntimePermission',
'*',
'writeFileDescriptor' );
end;


After that create the Java procedure itself:

create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;

public class Util extends Object
{
public static int RunThis(String args)
{
Runtime rt = Runtime.getRuntime();
int rc = -1;

try
{
Process p = rt.exec(args);

int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];

// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);

rc = p.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
}
finally
{
return rc;
}
}
}
/


Then a function that calls the java procedure:


create or replace
function RUN_CMD(p_cmd in varchar2) return number
as
language java
name 'Util.RunThis(java.lang.String) return integer';
/


And finally the stored procedure:


create or replace procedure RC(p_cmd in varchar2)
as
x number;
begin
x := run_cmd(p_cmd);
end;
/


After that it can be run from DBMS_SCHEDULER like this:


SQL>BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'MyJob',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN rc(''[path]/test.sh''); END;',
start_date => SYSTIMESTAMP,
end_date => NULL,
enabled => TRUE,
comments => 'UNIX shell script run from stored procedure');
END;
/

PL/SQL procedure successfully completed.



Of course it can also be set up with a schedule, etc. like any other stored procedure.

List all ORACLE_SIDs and their home directories on a server (UNIX)

Look in oratab, typically located in /var/opt/oracle or the /etc directories.

$ more /var/opt/oracle/oratab
#
ora9:/oracle/product/10.2.0/db_1:N
EIC:/oracle/product/10.2.0/db_1:N
cmstdev:/oracle/product/10.2.0/db_1:N

Backup and disable crontab

#!/bin/ksh
export CRONTABFILE=crontab.`date +%m%d%y-%H%M%S`

echo Exporting crontab to $CRONTABFILE

crontab -l > $CRONTABFILE

crontab -r

Set prompt to show current directory (ksh)

PS1="[$LOGNAME@`'hostname'`]"' $PWD>: '
export PS1

Locate the Oracle Inventory Directory

Solaris
$ more /var/opt/oracle/oraInst.loc
inventory_loc=/oracle/oraInventory
inst_group=dba
On Linux the file will be under /etc

Set display for X emulation for installation

DISPLAY=[machine-name]:0.0; export DISPLAY


This may vary by server. A good way to determine the correct value is to connect to the server via Xstart and then to check the value of the DISPLAY variable.

(Telnet connection via Xstart)

Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ echo $DISPLAY
10.177.10.137:1.0