вторник, 7 апреля 2009 г.

VxVM Striped Mirrors

Striped Mirrors

vxassist -g datadg make db001_v 10g layout=stripe,mirror stwidth=256 ncol=3 A1D0 A1D1 A1D3 A1D4 A1D5 A1D6
mkfs -F vxfs /dev/vx/rdsk/datadg/db001_v
mount -F vxfs /dev/vx/dsk/datadg/db001_v /var/temp

A simple concat
vxassist -g datadg make 10.1.0.3_v 5g layout=mirror A1L1 A1R1
-------------------------------------------------------------

If vxassist fails to make a mirror we can use vxmake
USe vxprint to find unused space as below

sd A1D1-O4 - A1D1 13335804 4445268 - c1t8d0 ENA
sd A1D1-O3 - A1D1 17781072 4445268 - c1t8d0 ENA
sd A1D1-I4 - A1D1 53343216 4445268 - c1t8d0 ENA

tncbu01:root# vxmake -g datadg plex spare layout=stripe stwidth=64 sd=A1D1-O4,A1D1-O3,A1D1-I4,A1D1-I5,A1D1-I6,A1D2-04,A1D2-I4,A1D2-I5,A1D2-I6,A1D3-O3,A1D3-I3,A1D3-I4,A1D3-I5,A1D3-I6

vxmake -g datadg -U fsgen vol spare_v plex=spare

vxmake -g datadg plex spare2 layout=stripe stwidth=64 sd=A1D4-O5,A1D4-O4,A1D4-O3,A1D4-I4,A1D4-I5,A1D4-I6,A1D5-O5,A1D5-O4,A1D5-O3,A1D5-I4,A1D5-I5,A1D5-I6,A1D6-O3,A1D6-I3,A1D6-I4

vxplex att spare_v spare2

vxvol -g datadg start spare_v

newfs /dev/vx/rdsk/datadg/spare_v

vxvol -g datadg resync spare_v

----------------------------------------------------------------

To manually configure each stage
disk offset (for 1st this is 0 then number in active column + number in next
column (length) for last vol)

1048640 = 1 gig

vxdg -g rootdg free
DISK DEVICE TAG OFFSET LENGTH FLAGS
rootdisk c1t0d0s2 c1t0d0 16386407 54737883 -
rootmirror c1t1d0s2 c1t1d0 12289806 58828707 -

vxmake -g rootdg sd root-db001 disk=rootdisk offset=16386407 len=4194560
vxmake -g rootdg sd root-db001a disk=rootmirror offset=16386407 len=4194560
vxmake -g rootdg sd root-db002 disk=rootdisk offset=20580967 len=4194560
vxmake -g rootdg sd root-db002a disk=rootmirror offset=20580967 len=4vxass194560
vxmake -g rootdg plex db001 layout=stripe stwidth=64 sd=root-db001,root-db001a
vxmake -g rootdg plex db002 layout=stripe stwidth=64 sd=root-db002,root-db002a
vxmake -g rootdg -o largefiles -Ufsgen vol db001_v plex=db001
vxmake -g rootdg -o largefiles -Ufsgen vol db002_v plex=db002
vxvol -g rootdg start db001_v
vxvol -g rootdg start db002_v
mkfs -F vxfs /dev/vx/rdsk/rootdg/db001_v
mkfs -F vxfs /dev/vx/rdsk/rootdg/db002_v
mkdir /db001 /db002
mount -F vxfs /dev/vx/dsk/rootdg/db001_v /db001
mount -F vxfs /dev/vx/dsk/rootdg/db002_v /db002
/usr/lib/fs/vxfs/fsadm -F vxfs -o largefiles /db001
/usr/lib/fs/vxfs/fsadm -F vxfs -o largefiles /db002
add entries to vfstab
/dev/vx/dsk/rootdg/db001_v /dev/vx/rdsk/rootdg/db001_v /db001 vxfs 3 yes largefiles
/dev/vx/dsk/rootdg/db002_v /dev/vx/rdsk/rootdg/db002_v /db002 vxfs 3 yes largefiles

Solaris Installing OpenSSH

Installing OpenSSH
In this example, I install OpenSSH 4.6p1 and prerequisites from Sunfreeware packages on a Solaris 8 Sparc system.

Sunfreeware Packages:

openssh-4.6p1-sol8-sparc-local.gz
libgcc-3.4.6-sol8-sparc-local.gz
openssl-0.9.8e-sol8-sparc-local.gz

# gzip -d openssh-4.6p1-sol8-sparc-local.gz
# gzip -d libgcc-3.4.6-sol8-sparc-local.gz
# gzip -d openssl-0.9.8e-sol8-sparc-local.gz

# pkgadd -d ./openssh-4.6p1-sol8-sparc-local
# pkgadd -d ./libgcc-3.4.6-sol8-sparc-local
# pkgadd -d ./openssl-0.9.8e-sol8-sparc-local

After installing the packages, run the following script to configure and run OpenSSH:
#!/bin/sh

# Create sshd startup/shutdown script
cat << 'SSHD' > /etc/init.d/sshd
#!/bin/sh

case "$1" in
'start')
/usr/local/sbin/sshd
;;
'stop')
/usr/bin/kill `/usr/bin/head -1 /var/run/sshd.pid`
;;
'reload')
/usr/bin/kill -HUP `/usr/bin/head -1 /var/run/sshd.pid`
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0
SSHD
chown root:root /etc/init.d/sshd
chmod 555 /etc/init.d/sshd
ln -s /etc/init.d/sshd /etc/rc2.d/S98sshd

# Create ssh keys
/usr/local/bin/ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
/usr/local/bin/ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N ""
/usr/local/bin/ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N ""

# Use only ssh protocol 2
sed -e 's/#Protocol 2,1/Protocol 2/' /usr/local/etc/sshd_config > /usr/local/etc/sshd_config_new
mv /usr/local/etc/sshd_config_new /usr/local/etc/sshd_config

# Create privilege separation user and environment
mkdir -m 755 /var/empty
chown root:root /var/empty
groupadd sshd
useradd -g sshd -c "OpenSSH privilege separation user" -d /var/empty -s /bin/false sshd

# start sshd
/etc/init.d/sshd start
Old notes

The following instructions show how to install OpenSSH from source and from package for Solaris. I recommend installing from source on Solaris systems, because if a vulnerability is discovered in OpenSSH, it is faster to upgrade from source than wait for package maintainers to release new packages.

Download the "portable" (i.e. you are not running OpenBSD) version of OpenSSH here:
ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
Installing OpenSSH from source
1. Download and install the openssl and zlib prerequisites from source or from package.

2. Download the "portable" version of OpenSSH.

3. Uncompress the OpenSSH tarball.

4. Run ./configure
Note: to build static OpenSSH binaries, run ./configure --with-ldflags=-static

If you receive the following error when running ./configure, you may have to install the libgcc package from Sunfreeware:
checking OpenSSL header version... not found
configure: error: OpenSSL version header not found.

Error in config.log:
configure:8694: ./conftest
ld.so.1: ./conftest: fatal: libgcc_s.so.1: open failed: No such file or directory
Killed

If you receive the following warning when running ./configure:

Random number source: ssh-rand-helper

WARNING: you are using the builtin random number collection
service. Please read WARNING.RNG and request that your OS
vendor includes kernel-based random number collection in
future versions of your OS.

You may want to install the ANDIrand package. This package installs a kernel module that emulates /dev/random and /dev/urandom on Solaris systems. A reboot is not required after installing this package to create the devices.
Alternatively, you may download the PRNGd package and compile OpenSSH with support for PRNGd (--with-prngd-port=xx or --with-prngd-socket=xx). In any case, OpenSSH's WARNING.RNG file appears to suggest using an alternate method of entropy generation rather than the built-in ssh-rand-helper.

If you see:

Random number source: OpenSSL internal ONLY

OpenSSH will use OpenSSL's random number source, which uses /dev/urandom. You are not using OpenSSH's built-in random number collection service, so you should not see the warning message.

5. Run make

6. Create the sshd privilege separation user and environment. View README.privsep from the OpenSSH source for more information.

# [ ! -d /var/empty ] && mkdir -m 755 /var/empty
# chown root:sys /var/empty
# groupadd sshd
# useradd -g sshd -c "OpenSSH privilege separation user" -d /var/empty -s /bin/false sshd

7. Run su root -c "make install"

8. Create an sshd startup/shutdown script.

# vi /etc/init.d/sshd

Add:
#!/bin/sh

case "$1" in
'start')
/usr/local/sbin/sshd
;;
'stop')
/usr/bin/kill `/usr/bin/head -1 /var/run/sshd.pid`
;;
'reload')
/usr/bin/kill -HUP `/usr/bin/head -1 /var/run/sshd.pid`
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0

# chown root:root /etc/init.d/sshd
# chmod 744 /etc/init.d/sshd
# ln -s /etc/init.d/sshd /etc/rc2.d/S98sshd
9. Start sshd.
# /etc/init.d/sshd start

Installing OpenSSH from package

I use the following steps to install OpenSSH from Solaris packages. Please read all scripts carefully along with the excellent Web pages "Installing OpenSSH Packages" and "Installing OpenSSH Packages for SPARC and Intel/Solaris 8."

OpenSSH requires /dev/random or a pseudo-random number generator like PRNGd to generate entropy.

* Solaris 9 provides /dev/random by default. The PRNGd package is not needed to generate entropy.
* If you are using Solaris 8, you may install Solaris patch 112438-01 (PRNG /kernel/drv/random patch) to create /dev/random and /dev/urandom. PRNGd is not needed if you use this patch. A reboot is required after installing this patch to create /dev/random and /dev/urandom. A reboot is not required if you install the Solaris 8 ANDIrand package (see below).
* If you are using earlier versions of Solaris, you may install the ANDIrand package. This package installs a kernel module to emulate /dev/random and /dev/urandom. PRNGd is not needed if you install this package. A reboot is not required after installing the ANDIrand package.
* If you use PRNGd with Solaris 8, the prngd executable is in /usr/local/sbin, not /usr/local/bin. Change /etc/init.d/prngd accordingly.

General instructions:

1. Download and install the openssh, PRNGd (if applicable), openssl, zlib, and libgcc packages from Sunfreeware. I prefer the Sunfreeware mirror ftp://mirrors.xmission.com/sunfreeware

2. Create prngd file (if applicable):

#!/bin/sh

case "$1" in
'start')
/usr/local/sbin/prngd /var/spool/prngd/pool
;;
'stop')
/usr/bin/kill `/usr/bin/ps -e -o pid,args | /usr/bin/grep [p]rngd | /usr/bin/awk '{print $1}'`
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0

3. Create sshd file:

#!/bin/sh

case "$1" in
'start')
/usr/local/sbin/sshd
;;
'stop')
/usr/bin/kill `/usr/bin/head -1 /var/run/sshd.pid`
;;
'reload')
/usr/bin/kill -HUP `/usr/bin/head -1 /var/run/sshd.pid`
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac
exit 0

4. Create install.sh file.

If you are using PRNGd:

#!/bin/sh

# Create entropy
cat /var/log/* /var/adm/* > /usr/local/etc/prngd/prngd-seed
mkdir /var/spool/prngd
/usr/local/sbin/prngd /var/spool/prngd/pool

# Run prngd at startup
cp prngd /etc/init.d
chown root:root /etc/init.d/prngd
chmod 555 /etc/init.d/prngd
ln -s /etc/init.d/prngd /etc/rc2.d/S98prngd

# Create ssh keys
/usr/local/bin/ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
/usr/local/bin/ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N ""
/usr/local/bin/ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N ""

# Run sshd at startup
cp sshd /etc/init.d
chown root:root /etc/init.d/sshd
chmod 555 /etc/init.d/sshd
ln -s /etc/init.d/sshd /etc/rc2.d/S98sshd

# Use only ssh protocol 2; version 1.33 and 1.5 of ssh protocol
# is not completely cryptographically safe (according to Nessus probe)
# Do not allow remote root logins via ssh
# Prevent /etc/motd from displaying twice when using ssh
# Allow X11 forwarding
sed -e 's/#Protocol 2,1/Protocol 2/' -e 's/PermitRootLogin yes/#PermitRootLogin no/' -e 's/#X11Forwarding no/X11Forwarding yes/' -e's/#PrintMotd yes/PrintMotd no/' /usr/local/etc/sshd_config > /usr/local/etc/sshd_config_new
mv /usr/local/etc/sshd_config_new /usr/local/etc/sshd_config

# Create privilege separation user and environment
mkdir -m 755 /var/empty
chown root:root /var/empty
groupadd sshd
useradd -g sshd -c "OpenSSH privilege separation user" -d /var/empty -s /bin/false sshd
# Start sshd
/etc/init.d/sshd start

If you are not using PRNGd:

#!/bin/sh

# Create ssh keys
/usr/local/bin/ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
/usr/local/bin/ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N ""
/usr/local/bin/ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N ""

# Run sshd at startup
cp sshd /etc/init.d
chown root:root /etc/init.d/sshd
chmod 555 /etc/init.d/sshd
ln -s /etc/init.d/sshd /etc/rc2.d/S98sshd

# Use only ssh protocol 2; version 1.33 and 1.5 of ssh protocol
# is not completely cryptographically safe (according to Nessus probe)
# Do not allow remote root logins via ssh
# Prevent /etc/motd from displaying twice when using ssh
# Allow X11 forwarding
sed -e 's/#Protocol 2,1/Protocol 2/' \
-e 's/PermitRootLogin yes/#PermitRootLogin no/' \
-e 's/#X11Forwarding no/X11Forwarding yes/' \
-e 's/#PrintMotd yes/PrintMotd no/' \
/usr/local/etc/sshd_config > /usr/local/etc/sshd_config_new
mv /usr/local/etc/sshd_config_new /usr/local/etc/sshd_config

# Create privilege separation user and environment
mkdir -m 755 /var/empty
chown root:root /var/empty
groupadd sshd
useradd -g sshd -c "OpenSSH privilege separation user" -d /var/empty -s /bin/false sshd
# Start sshd
/etc/init.d/sshd start

5. Run install.sh as root.
# sh ./install.sh

Solaris Disk duplication

Disk duplication
It is easy to duplicate a disk with the same geometry (cylinders, heads, sectors) with the dd command. In the following example, I will duplicate boot disk c0t0d0 with c0t1d0 on a Solaris system. Of course, this is not the same as mirroring the boot disk.

The dd command's bit-for-bit copy includes the partition table and boot block, so duplicating the partition table with prtvtoc and making the disk bootable with installboot is not necessary.

# format < /dev/null
Searching for disks...done


AVAILABLE DISK SELECTIONS:
0. c0t0d0
/sbus@1f,0/SUNW,fas@e,8800000/sd@0,0
1. c0t1d0
/sbus@1f,0/SUNW,fas@e,8800000/sd@1,0
Specify disk (enter its number):

1. Make a bit-for-bit copy of the source disk to the destination disk with dd. Use a 1 megabyte blocksize instead of the 512 byte default to speed up the operation.
dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t1d0s2 bs=1024k

2. Change the /etc/vfstab file on the duplicate boot disk to reflect the correct SCSI ID.

mkdir /tmp/mnt
mount /dev/dsk/c0t1d0s0 /tmp/mnt
vi /tmp/mnt/etc/vfstab

Change references of c0t0d0 to c0t1d0:

:%s/c0t0d0/c0t1d0/g
:wq!

umount /tmp/mnt

3. Test booting off the duplicate boot disk (assuming disk1 is the correct Open Boot Prompt device alias for c0t1d0s0).

reboot -- disk1

Solaris timezones

Solaris timezones
Which timezone am I using?
$ grep '^TZ' /etc/TIMEZONE

How do I change my timezone?
Modify the TZ= line in /etc/TIMEZONE to and reboot the system.

Which timezones are available?
$ ls /usr/share/lib/zoneinfo

Solaris zones

Solaris zones
In this example, I create, boot, and configure a sparse zone named osummdo001.

# zonecfg -z osummdo001
osummdo001: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:osummdo001> create

By default, the zone will not boot when the global zone (system) boots, so I change that behavior.

zonecfg:osummdo001> set autoboot=true

According to the System Administration Guide: Solaris Containers-Resource Management and Solaris Zones (November 2006), the zonepath should not be on ZFS.

zonecfg:osummdo001> set zonepath=/osummdo001/root

The ZFS dataset zfspool/osummdo001/oracle will be made available as /files0/oracle within the zone.

zonecfg:osummdo001> add fs
zonecfg:osummdo001:fs> set dir=/files0/oracle
zonecfg:osummdo001:fs> set special=/zfspool/osummdo001/oracle
zonecfg:osummdo001:fs> set type=lofs
zonecfg:osummdo001:fs> end

I add a network interface to the zone.

zonecfg:osummdo001> add net
zonecfg:osummdo001:net> set physical=dmfe0
zonecfg:osummdo001:net> set address=192.168.1.100
zonecfg:osummdo001:net> end

Next, I verify the zone's configuration, and install the zone.

# zoneadm -z osummdo001 verify

# zoneadm -z osummdo001 install
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <8726> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <297> packages on the zone.
Initialized <297> packages on zone.
Zone is initialized.
Installation of these packages generated errors:
Installation of <1> packages was skipped.
The file
contains a log of the zone installation.

I then boot the zone, and login on the zone's console to complete zone system identification.

# zoneadm -z osummdo001 boot
# zlogin -C osummdo001
Adding a file system to a zone
In this example, I add a ZFS file system named /oradata1 to the osummdo001 zone.

First, I create the ZFS file system in the global zone.

# zfs create zfspool/osummdo001/oradata1

Next, I add the file system to the zone's configuration.

# zonecfg -z osummdo001
zonecfg:osummdo001> add fs
zonecfg:osummdo001:fs> set dir=/oradata1
zonecfg:osummdo001:fs> set special=/zfspool/osummdo001/oradata1
zonecfg:osummdo001:fs> set type=lofs
zonecfg:osummdo001:fs> end
zonecfg:osummdo001> commit
zonecfg:osummdo001> end

The above commit is unnecessary, as the changes would have automatically been committed when typing end.

As of this writing, I do not know of any way to add the file system to a running zone. Rebooting the zone will cause the file system to be added to the zone.

# zoneadm -z osummdo001 reboot

JOBS


1. Создаём программы

2. Создаём расписания

3. Создаём задания для запуска программы в соответствии с расписанием


 

Программы создаются так:

 
BEGIN
  -- PL/SQL Block.
  DBMS_SCHEDULER.create_program (
    program_name   => 'test_plsql_block_prog',
    program_type   => 'PLSQL_BLOCK',
    program_action => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT''); END;',
    enabled        => TRUE,
    comments       => 'Program to gather SCOTT''s statistics using a PL/SQL block.');

  -- Shell Script.
  DBMS_SCHEDULER.create_program (
    program_name        => 'test_executable_prog',
    program_type        => 'EXECUTABLE',
    program_action      => '/u01/app/oracle/dba/gather_scott_stats.sh',
    number_of_arguments => 0,
    enabled             => TRUE,
    comments            => 'Program to gather SCOTT''s statistics us a shell script.');

 
 
  -- Stored Procedure with Arguments.
  DBMS_SCHEDULER.create_program (
    program_name        => 'test_stored_procedure_prog',
    program_type        => 'STORED_PROCEDURE',
    program_action      => 'DBMS_STATS.gather_schema_stats',
    number_of_arguments => 1,
    enabled             => FALSE,
    comments            => 'Program to gather SCOTT''s statistics using a stored procedure.');

  DBMS_SCHEDULER.define_program_argument (
    program_name      => 'test_stored_procedure_prog',
    argument_name     => 'ownname',
    argument_position => 1,
    argument_type     => 'VARCHAR2',
    default_value     => 'SCOTT');

  DBMS_SCHEDULER.enable (name => 'test_stored_procedure_prog');
END;
/

PL/SQL procedure successfully completed.

 
 
Просмотр программ:
 

SELECT owner, program_name, enabled FROM dba_scheduler_programs;

OWNER                          PROGRAM_NAME                   ENABL
------------------------------ ------------------------------ -----
SYS                            PURGE_LOG_PROG                 TRUE
SYS                            GATHER_STATS_PROG              TRUE
SYS                            TEST_PLSQL_BLOCK_PROG          TRUE
SYS                            TEST_EXECUTABLE_PROG           TRUE
SYS                            TEST_STORED_PROCEDURE_PROG     TRUE

5 rows selected.


Удалить программы: 
 
BEGIN
  DBMS_SCHEDULER.drop_program (program_name => 'test_plsql_block_prog');
  DBMS_SCHEDULER.drop_program (program_name => 'test_stored_procedure_prog');
  DBMS_SCHEDULER.drop_program (program_name => 'test_executable_prog');
END;
/

PL/SQL procedure successfully completed.

 
 
Просмотр программ:
 
SELECT owner, program_name, enabled FROM dba_scheduler_programs;

OWNER                          PROGRAM_NAME                   ENABL
------------------------------ ------------------------------ -----
SYS                            PURGE_LOG_PROG                 TRUE
SYS                            GATHER_STATS_PROG              TRUE 
 
 
 

Расписания создаются так:

BEGIN DBMS_SCHEDULER.create_schedule (
    schedule_name   => 'test_hourly_schedule',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=hourly; byminute=0',
    end_date        => NULL,
    comments        => 'Repeats hourly, on the hour, for ever.');
END;
/

PL/SQL procedure successfully completed.

 
 
Просмотр расписаний:
SELECT owner, schedule_name FROM dba_scheduler_schedules;

OWNER                          SCHEDULE_NAME
------------------------------ ------------------------------
SYS                            DAILY_PURGE_SCHEDULE
SYS                            TEST_HOURLY_SCHEDULE



Удалить расписание:
BEGIN
  DBMS_SCHEDULER.drop_schedule (schedule_name => 'TEST_HOURLY_SCHEDULE');
END;
/

PL/SQL procedure successfully completed.

 
 
Просмотр расписаний:
 
SELECT owner, schedule_name FROM dba_scheduler_schedules;

OWNER                          SCHEDULE_NAME
------------------------------ ------------------------------
SYS                            DAILY_PURGE_SCHEDULE

1 row selected. 
 
 
 

Задания (джобы) создаются так:


 
  
 BEGIN
  -- Job defined entirely by the CREATE JOB procedure.
  DBMS_SCHEDULER.create_job (
    job_name        => 'test_full_job_definition',
    job_type        => 'PLSQL_BLOCK',
    job_action      => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT''); END;',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=hourly; byminute=0',
    end_date        => NULL,
    enabled         => TRUE,
    comments        => 'Job defined entirely by the CREATE JOB procedure.');

  -- Job defined by an existing program and schedule.
  DBMS_SCHEDULER.create_job (
    job_name      => 'test_prog_sched_job_definition',
    program_name  => 'test_plsql_block_prog',
    schedule_name => 'test_hourly_schedule',
    enabled       => TRUE,
    comments      => 'Job defined by an existing program and schedule.');

  -- Job defined by existing program and inline schedule.
  DBMS_SCHEDULER.create_job (
    job_name        => 'test_prog_job_definition',
    program_name    => 'test_plsql_block_prog',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=hourly; byminute=0',
    end_date        => NULL,
    enabled         => TRUE,
    comments        => 'Job defined by existing program and inline schedule.');

  -- Job defined by existing schedule and inline program.
  DBMS_SCHEDULER.create_job (
     job_name      => 'test_sched_job_definition',
     schedule_name => 'test_hourly_schedule',
     job_type      => 'PLSQL_BLOCK',
     job_action    => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT''); END;',
     enabled       => TRUE,
     comments      => 'Job defined by existing schedule and inline program.');
END;
/

PL/SQL procedure successfully completed.

 
 
Просмотр заданий (jobs):
 
SELECT owner, job_name, enabled FROM dba_scheduler_jobs;

OWNER                          JOB_NAME                       ENABL
------------------------------ ------------------------------ -----
SYS                            PURGE_LOG                      TRUE
SYS                            GATHER_STATS_JOB               TRUE
SYS                            TEST_FULL_JOB_DEFINITION       TRUE
SYS                            TEST_PROG_SCHED_JOB_DEFINITION TRUE
SYS                            TEST_PROG_JOB_DEFINITION       TRUE
SYS                            TEST_SCHED_JOB_DEFINITION      TRUE
 

 
 
Джобы обычно выполняются асинхронно под контролем job coordinator,
но их можно запускать и останавливать вручную с помощью процедур RUN_JOB и STOP_JOB. 
 
BEGIN
  -- Запустить джоб в синхронном режиме.
  DBMS_SCHEDULER.run_job (job_name            => 'test_full_job_definition',
                          use_current_session => TRUE);

  -- Остановить джоб.
  DBMS_SCHEDULER.stop_job (job_name => 'test_full_job_definition, test_prog_sched_job_definition');
END;
/


Джобы можно удалить так:

BEGIN
  DBMS_SCHEDULER.drop_job (job_name => 'test_full_job_definition');
  DBMS_SCHEDULER.drop_job (job_name => 'test_prog_sched_job_definition');
  DBMS_SCHEDULER.drop_job (job_name => 'test_prog_job_definition');
  DBMS_SCHEDULER.drop_job (job_name => 'test_sched_job_definition');
END;
/

PL/SQL procedure successfully completed.


Просмотр джобов:

SELECT owner, job_name, enabled FROM dba_scheduler_jobs;

OWNER                          JOB_NAME                       ENABL
------------------------------ ------------------------------ -----
SYS                            PURGE_LOG                      TRUE
SYS                            GATHER_STATS_JOB               TRUE

2 rows selected.


 
Классы джобов:

Классы джобов позволяют группировать задания со схожими характеристиками и требованиями к ресурсам, 
что облегчает администрирование.
Если параметр JOB_CLASS процедуры CREATE_JOB не определен, задание присваивается DEFAULT_JOB_CLASS.


-- Просмотр текущих resource consumer groups.

SELECT consumer_group FROM dba_rsrc_consumer_groups;
CONSUMER_GROUP
------------------------------
OTHER_GROUPS
DEFAULT_CONSUMER_GROUP
SYS_GROUP
LOW_GROUP
AUTO_TASK_CONSUMER_GROUP

5 rows selected.


-- Создание джоб класса:
BEGIN
  DBMS_SCHEDULER.create_job_class (
    job_class_name          =>  'test_job_class',
    resource_consumer_group =>  'low_group');
END;
/

PL/SQL procedure successfully completed.



-- Просмотр классов джобов.

SELECT job_class_name, resource_consumer_group FROM dba_scheduler_job_classes;

JOB_CLASS_NAME                 RESOURCE_CONSUMER_GROUP
------------------------------ ------------------------------
DEFAULT_JOB_CLASS
AUTO_TASKS_JOB_CLASS           AUTO_TASK_CONSUMER_GROUP
TEST_JOB_CLASS                 LOW_GROUP

3 rows selected.



Задания могут быть назначены job class-у либо во время создания джоба
или после создания джоба с использованием процедуры SET_ATTRIBUTE.

BEGIN
  -- Создаём джоб.
  DBMS_SCHEDULER.create_job (
    job_name      => 'test_prog_sched_class_job_def',
    program_name  => 'test_plsql_block_prog',
    schedule_name => 'test_hourly_schedule',
    job_class     => 'test_job_class',
    enabled       => TRUE,
    comments      => 'Job defined by an existing program and schedule and assigned toa job class.');

  -- Назначаем джоб классу.
  DBMS_SCHEDULER.set_attribute (
    name      => 'test_prog_sched_job_definition',
    attribute => 'job_class',
    value     => 'test_job_class');
END;
/

PL/SQL procedure successfully completed.


-- Просмотр джобов.
SELECT owner, job_name, job_class, enabled FROM dba_scheduler_jobs;

OWNER                          JOB_NAME                       JOB_CLASS                      ENABL
------------------------------ ------------------------------ ------------------------------ -----
SYS                            PURGE_LOG                      DEFAULT_JOB_CLASS              TRUE
SYS                            GATHER_STATS_JOB               AUTO_TASKS_JOB_CLASS           TRUE
SYS                            TEST_FULL_JOB_DEFINITION       DEFAULT_JOB_CLASS              TRUE
SYS                            TEST_PROG_SCHED_JOB_DEFINITION TEST_JOB_CLASS                 TRUE
SYS                            TEST_PROG_JOB_DEFINITION       DEFAULT_JOB_CLASS              TRUE
SYS                            TEST_SCHED_JOB_DEFINITION      DEFAULT_JOB_CLASS              TRUE
SYS                            TEST_PROG_SCHED_CLASS_JOB_DEF  TEST_JOB_CLASS                 TRUE

7 rows selected.


Удаление джоб классов:

BEGIN
  DBMS_SCHEDULER.drop_job_class (
    job_class_name => 'test_job_class',
    force          => TRUE);
END;
/

PL/SQL procedure successfully completed.

 
 
Параметр force отключает любые зависимые джлбы и устанавливает для их job class значение по умолчанию.
Если job class не имеет зависимостей, параметр force необязателен. 



 
-- Просмотр джоб классов.

SELECT job_class_name, resource_consumer_group FROM dba_scheduler_job_classes;

JOB_CLASS_NAME                 RESOURCE_CONSUMER_GROUP
------------------------------ ------------------------------
DEFAULT_JOB_CLASS
AUTO_TASKS_JOB_CLASS           AUTO_TASK_CONSUMER_GROUP

2 rows selected.
 
 
Заданию могут назначаться приоритет между 1 и 5 (причем 1 является самым высоким),
которые использует координатор очереди джобов. Если приоритет не назначен, используется приоритет 3.

BEING
  DBMS_SCHEDULER.set_attribute (
    name      => 'my_job', 
    attribute => 'job_priority',
    value     => 1);
END;
/


 
 
 
 
 
 
 
 
 






Solaris /dev/pts

Solaris pts
A pty--also known as pts, pt's, pseudo-tty's--is a remote (pseudo) terminal. Prior to Solaris 8, the default maximum value of pty's is 48. Beginning with Solaris 8, the number of pseudo-terminals increases on demand, as long as the syseventd daemon is running.

Attempting to exceed this value may result in errors such as:

Warning: no access to tty (Bad file number).

Sep 4 12:36:58 hostname sshd[16676]: error: /dev/ptmx: No such device
Sep 4 12:36:58 hostname sshd[16678]: error: session_pty_req: session 0 alloc failed

Determine maximum number of pty's:
# echo "pt_cnt/D" | adb -k
physmem 1f4e9
pt_cnt:
pt_cnt: 48

# ls /dev/pts | wc -l
48

The following is a Bourne shell script to determine the current number of pty's in use and the maximun number of pty's (thanks to Ton Voon for showing me how to determine the current number of pty's in use):

#!/bin/sh

PTYS_IN_USE=0
TOTAL_PTYS=`ls /dev/pts | wc -l | sed 's/ //g`
for PTY in /dev/pts/*
do
[ -n "`fuser $PTY 2>/dev/null`" ] && PTYS_IN_USE=`expr $PTYS_IN_USE + 1`
done
echo "PTYs in use: $PTYS_IN_USE"
echo " Total PTYs: $TOTAL_PTYS"

Example output:

PTYs in use: 7
Total PTYs: 48

The following Bourne shell script shows the PIDs in use for each of the system's pty's:

#!/bin/sh

for PTY in `ls /dev/pts | sort -n` ; do
echo "/dev/pts/$PTY"
PIDS=`fuser /dev/pts/$PTY 2>&1 | awk -F: '{ print $2 }' | tr -d '[a-z][A-Z]'`
ps -fp "$PIDS"
echo
done

Example output:
...
/dev/pts/46
UID PID PPID C STIME TTY TIME CMD
root 13009 12508 0 09:56:16 pts/46 0:00 -sh
root 1141 13009 0 10:58:48 pts/46 0:00 /bin/sh ./pts_to_pid
...

Increasing number of pty's:

1. Add set pt_cnt = number to /etc/system
Note: there is no defined limit to the number of pty's that you create; values greater than 3000 have been used in practice. I recommend setting the number of ptys at multiples of 256 until you reach a comfortable limit.

2. Perform a reconfiguration reboot.

If a reboot (but not reconfiguration reboot) is performed after the kernel parameter change, the pty device links can be created with drvconfig;devlinks

Increasing pty's without a reboot
At least with my tests on a Solaris 2.6 system, this is not possible. This link claims it is possible, but I followed the steps, and it did not work.

# adb -k -w /dev/ksyms /dev/mem
physmem 7dd2c
pt_cnt/D
pt_cnt:
pt_cnt: 48
pt_cnt?W400
pt_cnt: 0x30 = 0x400
$q

# drvconfig;devlinks

After running drvconfig;devlinks, /dev/pts was not populated with the additional pty's, so I created them myself.

#!/bin/sh

# Create pty's 48 - 1023
PTY=48
ENDING_PTY=1023

while [ "$PTY" -le "$ENDING_PTY" ] ; do
mknod /devices/pseudo/pts@0:$PTY c 24 $PTY
chmod 644 /devices/pseudo/pts@0:$PTY
chgrp sys /devices/pseudo/pts@0:$PTY
ln -s ../../devices/pseudo/pts@0:$PTY /dev/pts/$PTY
chgrp -h root /dev/pts/$PTY
PTY=`expr $PTY + 1`
done

Unfortunately, this does not work. This link explains why.