Wednesday, December 11, 2013

How to identify Machine manufacturer and model information

AIX

# prtconf

HP UX

# model
# /usr/bin/arch -k
#machineinfo

Linux

# dmidecode system-manufacturer
dmidecode 2.9
SMBIOS entry point at 0xcf52db98
SMBIOS 2.7 present.
88 structures occupying 3180 bytes.
Table at 0x000E8827.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
        Vendor: Hewlett-Packard
        Version: J01 v02.15
        Release Date: 11/10/2011
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 1024 kB
        Characteristics:
                PCI is supported
                PNP is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                EDD is supported
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                ACPI is supported
                USB legacy is supported
                BIOS boot specification is supported
                Function key-initiated network boot is supported
                Targeted content distribution is supported
        BIOS Revision: 2.15


Solaris

# prtdiag
System Configuration:  Sun Microsystems  sun4u Sun SPARC Enterprise M4000 Server
System clock frequency: 1012 MHz
Memory size: 16384 Megabytes



Tuesday, December 10, 2013

Oracle Database: Drop Database

$ sqlplus / as sysdba
SQL> select * from v$instance;
SQL> shutdown immediate;
SQL> startup mount exclusive restrict;
SQL> drop database;

Tuesday, November 26, 2013

ZFS Tuning

Check Arc Memory Usage
# echo ::memstat|mdb -k
Page Summary                Pages                MB  %Tot
------------     ----------------  ----------------  ----
Kernel                     525663              4106    6%
ZFS File Data             5375945             41999   64%              <--- ZFS ARC Cache
Anon                      1641742             12826   20%
Exec and libs               35704               278    0%
Page cache                 531177              4149    6%
Free (cachelist)           121617               950    1%
Free (freelist)            156760              1224    2%
Total                     8388608             65536

to limit ZFS ARC Cache size, add/modify below line in /etc/system (it will take effect after next reboot)

set zfs:zfs_arc_max=6442450944

References:
http://www.solarisinternals.com/wiki/index.php/ZFS_Evil_Tuning_Guide
http://docs.oracle.com/cd/E26502_01/html/E29022/chapterzfs-1.html#scrolltoc

Thursday, November 21, 2013

Blueimp Jquery Upload File Plugin


Change upload folder

<?php
 
/*
* jQuery File Upload Plugin PHP Example 5.14

* https://github.com/blueimp/jQuery-File-Upload

* Copyright 2010, Sebastian Tschan

* https://blueimp.net

* Licensed under the MIT license:

* http://www.opensource.org/licenses/MIT
*/


define('DIR_DOWNLOAD', $_SERVER['DOCUMENT_ROOT'].'/');

define ('HTTP_SERVER' , 'http://'.$_SERVER['HTTP_HOST']);
error_reporting(E_ALL | E_STRICT);

require('UploadHandler.php');
 
$session_folder='aniu';

$upload_handler = new UploadHandler(array(

'upload_dir' => DIR_DOWNLOAD . 'userprofiles/',

'upload_url' => HTTP_SERVER . '/userprofiles/',

'image_versions' => array(

'thumbnail' => array(
'upload_dir' => DIR_DOWNLOAD . 'userprofiles/',
'upload_url' => HTTP_SERVER . '/userprofiles/',


),

));
?>

UploadHandler 

use index.php or specify a name

 $(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = 'server/php/',
        uploadButton = $('<button/>')
            .addClass('btn btn-primary')
            .prop('disabled', true)
            .text('Processing...')
            .on('click', function () {

Change progress bar color

        .progress {
                height: 20px;
                margin-bottom: 20px;
                overflow: hidden;
                background-color: #f5f5f5;
                display: block;
                border-radius: 4px;
                box-shadow: inset 0 1px 2px rgba(0,0,0,0.1) }

        .progress-bar {
                float: left;
                overflow: hidden;
                display: block;
                width: 0;
                height: 100%;
                font-size: 12px;
                color: #008;
                text-align: center;
                background-color: #00fa0f;
                box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
                transition: width .6s ease }

Change progress bar behaviour

        $('#progress .progress-bar').css(
            'visibility',
            'hidden'
        );

 Remove "no file selected."


 <!DOCTYPE html>
<html>
<head>
<style>

.inputWrapper {
    height: 100%;
    width: 108px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    /*Using a background color, but you can use a background image to represent a button*/
    background-color: #DDF;
}
.fileInput {
    cursor: pointer;
    height: 100%;
    position:absolute;
    top: 0;
    right: 0;
    z-index: 99;
    /*This makes the button huge. If you want a bigger button, increase the font size*/
    font-size:50px;
    /*Opacity settings for all browsers*/
    opacity: 0;
    -moz-opacity: 0;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)
}
</style>
</head>

<body>
 <div class="inputWrapper fileinput-button">
    <button id="image_alt">Select Picture</button>
    <input id="fileupload" class="fileInput" type="file" name="files[]" multiple>
</div>
</body>
</html>

Change File Name

 <?php
/*
 * jQuery File Upload Plugin PHP Example 5.14
 * https://github.com/blueimp/jQuery-File-Upload
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

define('DIR_DOWNLOAD', $_SERVER['DOCUMENT_ROOT'].'/');
define ('HTTP_SERVER' , 'http://'.$_SERVER['HTTP_HOST']);

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
//$upload_handler = new UploadHandler();

$session_folder='aniu';

class CustomUploadHandler extends UploadHandler
{
    protected function trim_file_name($name, $type) {
        $name = parent::trim_file_name($name, $type);
        $name="thisistestname.jpg";
        return $name;
    }
}

$upload_handler = new CustomUploadHandler(array(
'upload_dir' => DIR_DOWNLOAD . '../test/files/',
'upload_url' => HTTP_SERVER . '/test/files/',
'image_versions' => array(
'thumbnail' => array(
'upload_dir' => DIR_DOWNLOAD .'/test/files/thumbnails/',
'upload_url' => HTTP_SERVER . '/test/files/',
),
),
));
?>

Monday, November 18, 2013

Python: Install Easy_install on Linux


 
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
 
If failed to install, but you have got the binary file, you can try below command lines to finish the process
 
# python setup.py build
# python setup.py install

Wednesday, November 6, 2013

Install GIT Client on SuSE 11.2


Add repositories:
For Git,
# zypper addrepo http://download.opensuse.org/repositories/devel:/tools:/scm/SLE_11_SP2/devel:tools:scm.repo
For perl
# zypper addrepo http://download.opensuse.org/repositories/devel:/languages:/perl/SLE_11/devel:languages:perl.repo

if cannot find the repository, try below one.

#  zypper addrepo http://download.opensuse.org/repositories/devel:/languages:/perl/SLE_11_SP3/devel:languages:perl.repo

Install packages
# zypper install perl-Error

# zypper install git-core

Tuesday, November 5, 2013

MongoDB: Sharding Database

#start shardsrv
mongod --shardsvr --dbpath ./data/db --port 27018 --smallfiles --logappend
#start configsrv
with --configsvr specified the default port for listening becomes 27019 and the default data directory /data/configdb. Wherever your data directory is, it is suggested that you verify that the directory is empty before you begin.
mongod --configsvr --dbpath ./data/configdb --smallfiles --logappend
#start mongos
mongos --configdb localhost:27019


#connect mongos
mongo
sh.addShard("a/localhost:27018")

to shard a collection, you must have an index on the shard key, so you will need to create the index first


db.trades.ensureIndex( { ticker:1, time:1 } )
sh.enableSharding("week6")
sh.shardCollection("week6.trades",{ticker:1,time:1},false)
use config
db.chunks.find()
db.chunks.find({}, {min:1,max:1,shard:1,_id:0,ns:1})



#start new monogd
mkdir ./data/db2
mongod --shardsvr --dbpath ./data/db2 --port 27020 --smallfiles --logappend
#add Shard in mongos prompt
sh.addShard("a/localhost:27020")
Now wait for the balancer to move data among the two shards more evenly. Periodically run: use config
db.chunks.find( { ns:"week6.trades" }, {min:1,max:1,shard:1,_id:0} ).sort({min:1})
db.chunks.aggregate( [
 { $match : { ns : "week6.trades" } } ,
 { $group : { _id : "$shard", n : { $sum : 1 } } }
] )

Build MongoDB Replica Set

Prepare DB Directories

mkdir -p /data/rs1 /data/rs2 /data/rs3



Configure Replica Set

Now start three mongo instances as follows. Note that are three commands. The browser is probably wrapping them visually.

./mongod --replSet ing --logpath "1.log" --dbpath /data/rs1 --port 27017 --smallfiles --fork
./mongod --replSet ing --logpath "2.log" --dbpath /data/rs2 --port 27018 --smallfiles --fork
./mongod --replSet ing --logpath "3.log" --dbpath /data/rs3 --port 27019 --smallfiles --fork

Now connect to a mongo shell and make sure it comes up

./mongo --port 27017

Now you will create the replica set. Type the following commands into the mongo shell:

config = { _id: "ing", members:[
          { _id : 0, host : "localhost:27017"},
          { _id : 1, host : "localhost:27018"},
          { _id : 2, host : "localhost:27019"} ]
};
rs.initiate(config);

At this point, the replica set should be coming up. You can type

rs.status()

to see the state of replication.

config = { _id: "ing", members:[
          { _id : 0, host : "localhost:27001"}
]
};
rs.initiate(config);

Other Replicaset Operation


rs.add("localhost:27002")
rs.add("localhost:27003")

rs.remove("localhost:27001")

Friday, November 1, 2013

Subversion Configuratioin Sample

Add below entries into /etc/apache2/conf.d/subversion.conf

<IfModule mod_dav_svn.c>
<Location /test>
        DAV svn          
        SVNPath /srv/svn/test
        AuthType Basic                
        AuthName "Test Repository"        

        AuthzLDAPAuthoritative Off
        AuthBasicProvider ldap   

        AuthLDAPURL "ldap://ldap.goweekend.ca/dc=goweekend,dc=ca?uid?sub?(ldappermission=svntest)"
        REQUIRE valid-user                                                                      

        <LimitExcept GET PROPFIND OPTIONS REPORT>
          Require valid-user              
        </LimitExcept>                          
</Location>                                     

<Location /training>
        DAV svn    
        SVNPath /srv/svn/training/

        Require valid-user
        <LimitExcept GET PROPFIND OPTIONS REPORT>
        AuthType Basic
        AuthName "SVN Training"
        AuthUserFile /srv/svn/training/conf/svnpasswd
        AuthzSVNAccessFile /srv/svn/training/conf/authz
        </LimitExcept>
</Location>

</IfModule>

Wednesday, October 30, 2013

Cyrus IMAP Administration

Configuration Files:
/etc/imapd.conf
/etc/cyrus.conf

Login as cyrus
$ cyradm -user cyrus localhost


localhost> help
authenticate, login, auth         authenticate to server
chdir, cd                         change current directory
createmailbox, create, cm         create mailbox
deleteaclmailbox, deleteacl, dam  remove ACLs from mailbox
deletemailbox, delete, dm         delete mailbox
disconnect, disc                  disconnect from current server
exit, quit                        exit cyradm
help, ?                           show commands
info                              display mailbox/server metadata
listacl, lam, listaclmailbox      list ACLs on mailbox
listmailbox, lm                   list mailboxes
listquota, lq                     list quotas on specified root
listquotaroot, lqr, lqm           show quota roots and quotas for mailbox
mboxcfg, mboxconfig               configure mailbox
reconstruct                       reconstruct mailbox (if supported)
renamemailbox, rename, renm       rename (and optionally relocate) mailbox
server, servername, connect       show current server or connect to server
setaclmailbox, sam, setacl        set ACLs on mailbox
setinfo                           set server metadata
setquota, sq                      set quota on mailbox or resource
subscribe, sub                    subscribe to a mailbox
unsubscribe, unsub                unsubscribe from a mailbox
version, ver                      display version info of current server
xfermailbox, xfer                 transfer (relocate) a mailbox to a different server
localhost> setquota user.dav 51200


export all user name to file
$ cyradm -user cyrus localhost -password <password> << EOF > user.txt
>lm
>EOF

List all quota into text file
$ cyradm -user cyrus localhost -password <password> << EOF > user.txt
>quota
>EOF

Cyrus admin to clean up mail box

$ /usr/lib/cyrus/bin/ipurge -f -b 0 <user.mailbox>

# References:
http://liseyko.blogspot.ca/2007/07/cyrus-management.html


Tuesday, October 29, 2013

Setup APEX Environment

Oracle APEX Installation Guide Download Oracle HTTP Server


POC Env:

http://apex.goweekend.ca:7777/pls/apex/apex_admin

admin

Database:

SID: APEX

Server: apex.goweekend.ca

Port: 1521





Apex Workspace

http://apex.goweekend.ca:8080/apex

Workspace: WS1



Restart APEX

Login as oracle

$ sqlplus / as sysdba

$ shutdown immediate

$ startup

Ensure Listener is up

Login as ohs

$ cd /usr2/middleware/Oracle_WT/instances/apex/bin

$ ./opmnctl stopall

$ ./opmnctl startall

Thursday, October 10, 2013

MongoDB: Readahead for /data/db/ is set to 512KB

OS: Suse Linux 11 SP2

Problem:
Wed Sep 11 08:15:55.215 [initandlisten] ** WARNING: Readahead for /data/db/ is set to 512KB
Wed Sep 11 08:15:55.215 [initandlisten] **          We suggest setting it to 256KB (512 sectors) or less
Wed Sep 11 08:15:55.215 [initandlisten] **          http://dochub.mongodb.org/core/readahead

Solution:

Login as root, and check current Readhead. First of all, find out the file system your database located in. i.e.
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             448G  319G  107G  75% /

in my case, /dev/sda2 is the one.
#  blockdev --getra /dev/sda2

Change  Readahead
# blockdev --setra 256 /dev/sda2

restart mongodb server


$ mongo
> use admin
> db.shutdownServer({shutdown:1, force:true})

Start mongodb server again
$ mongodb

Wednesday, October 9, 2013

SVN: ACL Configuration on Linux


Purpose

Restrict access to SVN contents

Configuration Files

/srv/svn/<repository name>/conf/authz  
/srv/svn/<repository name>/conf/svnserve.conf
/srv/svn/<repository name>/conf/svnpasswd
/etc/apache2/conf.d/subversion.conf

Users

Define users in /srv/svn/<repository name>/conf/svnpasswd
# cd /srv/svn/<repository name>/conf
# htpasswd2 -m svnpasswd svnadmin
New password:
Re-type new password:
Adding password for user svnadmin

Subversion Server

Add below entries in section [general]
anon-access = read
auth-access = write
password-db = svnpasswd
authz-db = authz

 ACL

Define group and access in
[groups]
svnadmins = svnadmin1, svnadmin2
developers =developer1, developer2
qas =qa1, qa2
[/]
*=r
@svnadmins = rw

[/trunk]
@svnadmins = rw
@developers = rw
@qas = r

Apache2

add below lines /etc/apache2/conf.d/subversion.conf
<Location /<repository name>>
        DAV svn
        SVNPath /srv/svn/<repository name>/
        # Limit write permission to list of valid users.
        <LimitExcept GET PROPFIND OPTIONS REPORT>
        AuthType Basic
        AuthName "Online"
        AuthUserFile /srv/svn/<repository name>/conf/svnpasswd
        AuthzSVNAccessFile /srv/svn/<repository name>/conf/authz
                Require valid-user
        </LimitExcept>
</Location>
Restart Apache2
# service apache2 restart



Friday, October 4, 2013

SVN CLI and Kwallet Integration on SuSE Linux 11

Purpose:


Use kwallet to save SVN credential instead of plain-text password.

Prerequisites:


Subversion client, systemsettings from KDE, kwallet, libsvn_auth_kwallet-1-0

Limitation:


To run svn client to use kwallet, you have to run it on the client GUI console.

Install Subversion Client


Install subversion from SuSE repository,

For SLE 11 SP3 run the following as root:

# zypper addrepo http://download.opensuse.org/repositories/devel:tools:scm:svn/SLE_11_SP3/devel:tools:scm:svn.repo
# zypper refresh
# zypper install subversion

For SLE 11 SP2 run the following as root:

# zypper addrepo http://download.opensuse.org/repositories/devel:tools:scm:svn/SLE_11_SP2/devel:tools:scm:svn.repo
# zypper refresh
# zypper install subversion

For SLE 11 run the following as root:

# zypper addrepo http://download.opensuse.org/repositories/devel:tools:scm:svn/SLE_11/devel:tools:scm:svn.repo
# zypper refresh
# zypper install subversion

Install Systemsettings


Ignore this step if Systemsettings has been installed on your desktop

# zypper install kdebase4-workspace

Install kwallet


Ignore this step if kwallet has been installed on your desktop

# zypper install kwallet

Install libsvn_auth_kwallet-1-0


Ignore this step if libsvn_auth_kwallet-1-0 package has been installed on your desktop

# zypper in libsvn_auth_kwallet-1-0

Enable and configure kwallet


Login as root, and run systemsettings.

Choose Tab Advanced -&gt; KDE Wallet

In KDE Wallet Configuration Window -&gt; Wallet Preference:

    Check Enable KDE Wallet Subsystem, and click New button to create new wallet
    Give a name to the new wallet, i.e. aniu
    Input password to protect your wallet, and click Create
    Click Apply, then Click Launch Wallet Manager which is right above Apply Button
    Close the configuration button

Configure subversion client


Run svn, and it will create ~/.subversion folder and the configuration files needed.

# cd ~/.subversion

edit config, and add below entry in [auth] section:

password-stores = kwallet

edit server, and add below entries in [global] section:

store-passwords = yes

store-plaintext-passwords = no

Verify Integration


On client desktop, start xterm,

# cd /var/tmp

# mkdir test

# svn co <url>

After you type in username and password, a GUI window pops up to ask your wallet password, and then choose Allow Always.

You may got Segmentation Fault message, please ignore it, and run the command again.

If it says the folder has been locked, please run svn cleanup to unlock the folder, run the checkout command again.

Check the wallet, you would be able to see a new folder called Subversion with one password.

Keep your wallet password secret because with it, people can see your svn password stored in the wallet.

Run below command, it won't ask you for password anymore.

# svn up


Thursday, October 3, 2013

Subversion Installation on SuSE Linux

Prerequisites

Apache 2
Neon Library
Subversion Client

Installation

Prerequisites Installation

1.    Install Apache 2
2.    Install neon from first DVD, libneon27-0.29.6-6.7.1.x86_64.rpm
3.    Get Subversion Server and Client Binaries
4.    Install SubVersion Client first, and then Subversion Server
       to install SVN client on SuSE linux, please refer to http://software.opensuse.org/download.html?project=devel:tools:scm:svn&package=subversion

Subversion Installation

Install Subversion Client
# zypper install subversion
Change folder to where Subversion Server binary placed
# rpm -ivh subversion-server-1.6.17-51.1.x86_64.rpm
After Subversion installation, you should be able to find below file placements:

# rpm -ql subversion-server-1.6.17-51.1.x86_64
/etc/apache2/conf.d
/etc/apache2/conf.d/subversion.conf
/usr/lib64/apache2
/usr/lib64/apache2/mod_authz_svn.so
/usr/lib64/apache2/mod_dav_svn.so

Configuration

Configure Apache 2

1. Apply below changes in /etc/sysconfig/apache2

APACHE_MODULES="authz_host actions alias auth_basic authz_groupfile authn_file authz_user autoindex cgi dir include log_config mime negotiation setenvif status userdir asis dav dav_fs imagemap php5 perl python dav_svn authz_svn authz_default ssl"

< APACHE_SERVER_FLAGS="SSL"
2. SSL Enablement
Creating a “Dummy” Certificate
Generating a dummy certificate is simple. Just call the script /usr/bin/gensslcert. It creates or overwrites the following files:

    /etc/apache2/ssl.crt/ca.crt
    /etc/apache2/ssl.crt/server.crt
    /etc/apache2/ssl.key/server.key
    /etc/apache2/ssl.csr/server.csr

A copy of ca.crt is also placed at /srv/www/htdocs/CA.crt for download.

Apply below changes to /etc/apache2/vhosts.d/vhost-ssl.conf (copy it from vhost-ssl.template if it doesn't exist)
Comment out below line:
SSLProtocol all -SSLv2 -SSLv3


Restart Apache2 and test both secure and non-secured connection.

Configure SVN Repository

Initialization

# svnadmin create /path/to/repository
# svnlook info /path/to/repository

Chang repository group and permission
Suggestion: change the group to apache2 group, permission 770

Edit subversion.conf as needed

Using local password file to authentication

 <Location /repos>
        DAV svn
        SVNPath /srv/svn/repos


        # Limit write permission to list of valid users.
        <LimitExcept GET PROPFIND OPTIONS REPORT>
                Require valid-user
        AuthType Basic
        AuthName "Test Repository"
        AuthUserFile /srv/svn/repos/conf/passwd
        SVNPathAuthz on
        AuthzSVNAccessFile /srv/svn/repos/conf/authz
        </LimitExcept>
</Location>

Using LDAP Authentication

 <Location /repos>
        DAV svn
        SVNPath /srv/svn/repos
        AuthType Basic
        AuthName "Utilities"

        AuthzLDAPAuthoritative Off
        AuthBasicProvider ldap

        AuthLDAPURL "ldap://ldap.goweekend.ca/dc=suzhou,dc=goweekend,dc=ca?uid?sub?(appperm=svnusers)"
        REQUIRE valid-user

        # Limit write permission to list of valid users.
        <LimitExcept GET PROPFIND OPTIONS REPORT>
                Require valid-user
        </LimitExcept>
</Location>

Repository Populating (optional)

Dump repository
# svnadmin dump /path/to/sourceRepository > repositoryDump.rep

Load repository from dump file
#  svnadmin load /path/to/targetRepository <repositoryDump.rep

Verification

open browser and type in url like below:
http://<server name>.domain.name/<repository name>

Wednesday, September 25, 2013

Oracle: Setup APEX on Linux


 Install Oracle HTTP Server


Download binary (Oracle Webtier Utilities) from http://www.oracle.com/technetwork/java/webtier/downloads/index2-303202.html

Create user/group
user name: ohs
group: ohs

log on as ohs

extract binary into /var/tmp/ohs

$ cd /var/tmp/ohs/Disk1
$ ./runInstaller


Follow the instructions on screen to create an instance called apex and finish installation, at the end you will see the url to connect to your OHS.

to uninstall it, please run below command in  <Web_Tier_ORACLE_HOME>/oui/bin

$ ./runInstaller -deinstall


Download and Install APEX

Download the binary from
http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html

extract it into /var/tmp/apex

Full development environment

Run apexins.sql passing the following four arguments in the order shown:

SQL> @apexins.sql tablespace_apex tablespace_files tablespace_temp images

Where:

    tablespace_apex is the name of the tablespace for the Oracle Application Express application user.

    tablespace_files is the name of the tablespace for the Oracle Application Express files user.

    tablespace_temp is the name of the temporary tablespace or tablespace group.

    images is the virtual directory for Oracle Application Express images. To support future Oracle Application Express upgrades, define the virtual image directory as /i/.
 

connect to your database using sqlplus as sysdba


$ cd /var/tmp/apex/apex
$ sqlplus / as sysdba
SQL> @apexins.sql SYSAUX SYSAUX TEMP /i/


Change the Password for the ADMIN Account

Login as sysdba

SQL> @apxchpwd.sql

 Type in your password when asked.

Configure APEX_PUBLIC_USER Account

Run the following statement:

SQL> ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK

Changing the Password for the APEX_PUBLIC_USER Account

SQL> ALTER USER APEX_PUBLIC_USER IDENTIFIED BY new_password

About Password Expiration in Oracle Database 11g

 SQL> CREATE PROFILE UNLIMITED_PASSWORD_LIFETIME LIMIT
  SESSIONS_PER_USER DEFAULT
  CPU_PER_SESSION DEFAULT
  CPU_PER_CALL DEFAULT
  CONNECT_TIME DEFAULT
  IDLE_TIME DEFAULT
  LOGICAL_READS_PER_SESSION DEFAULT
  LOGICAL_READS_PER_CALL DEFAULT
  COMPOSITE_LIMIT DEFAULT
  PRIVATE_SGA DEFAULT
  FAILED_LOGIN_ATTEMPTS DEFAULT
  PASSWORD_LIFE_TIME UNLIMITED  
  PASSWORD_REUSE_TIME DEFAULT
  PASSWORD_REUSE_MAX DEFAULT
  PASSWORD_LOCK_TIME DEFAULT
  PASSWORD_GRACE_TIME DEFAULT
  PASSWORD_VERIFY_FUNCTION DEFAULT;

SQL> ALTER USER APEX_PUBLIC_USER
  PROFILE UNLIMITED_PASSWORD_LIFETIME
  ACCOUNT UNLOCK;


Granting Connect Privileges


The following example demonstrates how to grant connect privileges to any host for the APEX_040200 database user. This example assumes you connected to the database where Oracle Application Express is installed as SYS specifying the SYSDBA role.

DECLARE
  ACL_PATH  VARCHAR2(4000);
BEGIN
  -- Look for the ACL currently assigned to '*' and give APEX_040200
  -- the "connect" privilege if APEX_040200 does not have the privilege yet.

  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
   WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;

  IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_040200',
     'connect') IS NULL THEN
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
     'APEX_040200', TRUE, 'connect');
  END IF;

EXCEPTION
  -- When no ACL has been assigned to '*'.
  WHEN NO_DATA_FOUND THEN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
    'ACL that lets power users to connect to everywhere',
    'APEX_040200', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;

Enable

Enabling Oracle XML DB Protocol Server


EXEC DBMS_XDB.SETHTTPPORT(8080);

Load Images


if below script failed, user will see blank page when connect to workspace.

SQL> @apxldimg.sql

PL/SQL procedure successfully completed.

Enter value for 1: /var/tmp

PL/SQL procedure successfully completed.

. Loading images directory: /var/tmp/apex/images

Directory created.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


Commit complete.


Directory dropped.

timing for: Load Images
Elapsed: 00:03:18.77

Friday, September 13, 2013

Build Ear File with ant for MongoDB, WebSphere Application Server

I have explained how to setup MongoDB development environment for WebSphere Application Server with Eclipse in post: http://feijiangnan.blogspot.ca/2013/09/setup-eclipse-for-mongodb-and-websphere.html, let's go further to compile the code using Apache Ant.

In this scenario, I used Linux to run the tasks.

1. Install Ant

You can find the binary and installation guide on http://ant.apache.org/

2. Create build.xml like below


<?xml version="1.0"?>
<project name="mongodbHelloWorld" default="buildEar" basedir=".">
    <description>
        First Mongodb Java Project
    </description>
    <!-- set global properties for this build -->
    <property name="distName" value="mongodbHelloWorld" />
    <property name="src" location="src" />
    <property name="build" location="build" />
    <property name="warDir" location="wars" />
    <property name="earDir" location="ears" />
    <property name="outputDir" location="output" />
    <property name="warFile" value="${distName}.war" />
    <property name="earFile" value="${distName}.ear" />
    <property name="wasJRELib" value="/opt/IBM/WebSphere/AppServer/java/jre/lib" />
    <property name="wasLib" value="/opt/IBM/WebSphere/AppServer/java/jre/lib" />
    <property name="wasJavaLib" value="/opt/IBM/WebSphere/AppServer/java/lib" />
    <property name="wasLibExt" value="/opt/IBM/WebSphere/AppServer/java/jre/lib/ext" />
    <property name="wasPlugins" value="/opt/IBM/WebSphere/AppServer/plugins" />
    <property name="wasEndorsed" value="/opt/IBM/WebSphere/AppServer/endorsed_apis" />
    <property name="wasJEE" value="/opt/IBM/WebSphere/AppServer/dev/JavaEE/6.0" />
    <property name="wasVM" value="/opt/IBM/WebSphere/AppServer/java/jre/lib/amd64/default/jclSC160" />

    <path id="project.class.path">
        <pathelement location="lib/mongo-java-driver-2.11.2.jar" />
        <fileset dir="${wasJEE}" includes="*.jar" />
        <fileset dir="${wasJRELib}" includes="*.jar" />
        <fileset dir="${wasLib}" includes="*.jar" />
        <fileset dir="${wasJavaLib}" includes="*.jar" />
        <fileset dir="${wasLibExt}" includes="*.jar" />
        <fileset dir="${wasEndorsed}" includes="*.jar" />
        <fileset dir="${wasPlugins}" includes="*.jar" />
    </path>


    <target name="init">
        <!-- Create the time stamp -->
        <tstamp />
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}" />
    </target>

    <target name="compile" depends="init" description="compile the source ">
        <!-- Compile the java code from ${src} into ${build} -->
        <javac srcdir="${src}" destdir="${build}" includeantruntime="false">
            <classpath refid="project.class.path" />
        </javac>
    </target>

    <target name="buildWar" depends="compile" description="generate the distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${warDir}/lib" />
        <war destfile="${warDir}/wars/${warFile}" needxmlfile='false'>

            <webinf dir="WebContent/WEB-INF">
                <include name="**/*.xml" />
            </webinf>

            <classes dir="WebContent/WEB-INF/classes" />
           
            <lib dir="lib">
                <include name="mongo-java-driver-2.11.2.jar" />
                <exclude name="jdbc1.jar" />
            </lib>
        </war>

    </target>

    <target name="clean" description="clean up">
        <!-- Delete the ${build} and ${warDir} directory trees -->
        <delete dir="${build}" />
        <delete dir="${warDir}" />
        <delete dir="${earDir}" />
    </target>

    <target name="buildEar" depends="clean, buildWar">
        <mkdir dir="${earDir}/META-INF" />

        <copy todir="${earDir}/" file="${warDir}/wars/${warFile}" />
        <copy tofile="${earDir}/META-INF/application.xml" file="application.xml" />
    <!--    <copy todir="${earDir}/META-INF">
            <fileset dir="localDirectory" includes="was.policy" />
        </copy>
        -->
        <jar jarfile="${outputDir}/${earFile}" basedir="${earDir}">
            <!-- Define the properties for the Manifest file. -->
            <manifest>
                <attribute name="Implementation-Vendor" value="Go Weekend" />
                <attribute name="Implementation-Title" value="Client Registration" />
                <attribute name="Implementation-Version" value="1.0" />
            </manifest>
        </jar>
    </target>
</project>

3. Create application.xml as below

<?xml version="1.0" encoding="UTF-8"?>
<application id="HellowMongodb" version="6" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
        <application-name>HelloMongoDB</application-name>
        <display-name>Hello Mongodb</display-name>
        <icon>
                <small-icon>/META-INF/MongoDB_Small.jpeg</small-icon>
                <large-icon>/META-INF/MongoDB_Large.jpeg</large-icon>
        </icon>
        <module id="WebModule_HelloMongodb">
                <web>
                        <web-uri>mongodbHelloWorld.war</web-uri>
                        <context-root>HelloMongodb</context-root>
                </web>
        </module>
</application>

4. Create web.xml in WebContent/WEB-INF

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>mongodbHelloWorld</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

5. Run Ant to build ear file


 ant -f build.xml buildEar

6. Deploy the ear file

Deploy the ear file in your WebSphere Application Server, and connect to the application in your browser like:
http://<your hostname>:9060/HelloMongodb/HelloMongodb

Friday, September 6, 2013

WAS: move deployment manager and application server profiles between differrent platforms


Backup profiles

On source server
$ cd $DMGR_BIN
$ ./manageprofiles.sh -backupProfile -profileName <Dmgr profile name> -backupFile /var/tmp/Dmgr_Backup.zip
$ cd $NODE_BIN
$ ./manageprofiles.sh -backupProfile -profileName <Application Server profile name> -backupFile /tmp/Appsrv_Backup.zip

Restore profiles on destination

Transfer the backup files to destination server.

On destination server
$ cd $WAS_HOME/bin
restore deployment manager profile
$ ./manageprofiles.sh -restoreProfile -backupFile /var/tmp/Dmgr_Backup.zip
restore WAS node profile
$ ./manageprofiles.sh -restoreProfile -backupFile /var/tmp/Appsrv_Backup.zip

 

Customize configuration files

Deployment Manager


replace all old hostname with new hostname in deployment manager serverindex.html, i.e.
/opt/IBM/WebSphere/AppServer/profiles/<Dmgr profile name>/config/cells/<cell name>/nodes/<dmgr node name>/serverindex.xml
fix all os and architeture configuration in node-metadata.properties
/opt/IBM/WebSphere/AppServer/profiles/<Dmgr profile name>/config/cells/<cell name>/nodes/<dmgr node name>/node-metadata.properties

WAS Node Profile

replace all old hostname with new hostname in node agent serverindex.html, i.e.
/opt/IBM/WebSphere/AppServer/profiles/<Dmgr profile name>/config/cells/<cell name>/nodes/<app server node name>/serverindex.xml
fix all os and architeture configuration in node-metadata.properties
/opt/IBM/WebSphere/AppServer/profiles/<Dmgr profile name>/config/cells/<cell name>/nodes/<app server node name>/node-metadata.properties

Synchornize node with deployment manager

./syncNode.sh <dmgr server name> <dmgr soap port number>

Start up profiles

$ cd $DMGR_BIN
$ ./startManager
$ cd $NODE_BIN
$ ./startNode.sh
$ ./startServer.sh server1

Setup Eclipse for mongoDB and WebSphere Application Development Environment


Install JDK

Download jdk from http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
# cd /opt
# <path to jdk binary>/jdk-6u38-linux-x64.bin
# cd /opt/jdk1.6.0_38

set environment variables for users accordingly
set JAVA_HOME=/opt/jdk1.6.0_38
and set PATH=$JAVA_HOME/bin:$PATH

Install mongoDB

Download mongoDB from http://www.mongodb.org/downloads
Extract the binaries in /opt/mongoDB
Verify Installation
# cd /opt/mongoDB/bin
Start Server
# ./mongod

Start client
# ./mongo

Install WebSphere Application Server

please refer to IBM WebSphere Application Server Installation

Install Eclipse

Download Eclipse from http://www.eclipse.org/downloads/
Eclipse Juno is used in this scenario.
extract the binary into /opt/tools
$ cd /opt/tools
$ tar -zxf eclipse-jee-juno-SR2-linux-gtk-x86_64.tar.gz
$ mv eclipse mongodbDev

Configuring Eclipse with WebSphere Application Server

Help -> Eclipse Marketplace -> Search
type in "Websphere application server" in Find field, and click Go
In the results panel, Install "IBM WebSphere Application Server V8.0 Developer Tools for Eclipse Juno"
Followin instructions in screen to finish the installation.
Restart Eclipse

Goto Windows -> Preferences -> Server -> Runtime Environments
Remove the existing one "Web Preview Server Runtime".
Add -> IBM -> WebSphere Application Server v8.0
Check "Create a new local server", click Next
Point "Installation Dictionary" to your WebSphere Application Server installation location, i.e. /opt/IBM/WebSphere/AppServer
Provide information accordingly in the following screens, and click Finish.
Goto Windows -> Preferences -> Server -> WebSphere Application Server to verify the settings.

Download MongoDB Java Driver from http://api.mongodb.org/java/
we use version of 2.11.2 in this scenario, and put it in your CLASSPATH.

Create First Application, mongodbHelloWorld

Goto File -> New -> Dynamic Web Project
Project Name: mongodbHelloWorld
Click Finish

In project of mongodbHelloWorld, goto File -> New -> Servlet
Java package: ca.goweekend.mongo
Class name: HelloMongodb
Click Finish
paste below code in HelloMongodb.java, and you will see many errors.

Now let's include Mongodb Java Driver into CLASSPATH to resove those errors.
right click on mongodbHelloWorld project, and choose properties -> Java Build Path -> Libraries -> Add External Jars, add the Java driver you downloaded before. Click OK, and the errors should be all gone.

Goto Windows -> Preferences -> Java -> Build Path -> Classpath Variables -> New
Name: Mongodb Java Driver
Path: /apps/mongodb/mongo-java-driver-2.11.2.jar

HelloMongodb.java

package ca.goweekend.mongo;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.ws.webcontainer.servlet.ServletConfig;
import com.mongodb.MongoClient;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;

/**
 * Servlet implementation class HelloMongodb
 */
@WebServlet("/HelloMongodb")
public class HelloMongodb extends HttpServlet {
        private static final long serialVersionUID = 1L;

        /**
         * @see HttpServlet#HttpServlet()
         */
        public HelloMongodb() {
                super();
        }

        public void init(ServletConfig config) {
                System.out.println("Inititiating Database Connection.");
        }

        /**
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
         *      response)
         */
        protected void doGet(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {

                MongoClient mongleClient = new MongoClient("db.goweekend.ca",
                                27017);

                DB db = mongleClient.getDB("HelloMongodb");

                DBCollection coll = db.getCollection("client");

                try {
                        BasicDBObject doc = new BasicDBObject();

            String yourIPAddress = request.getRemoteAddr();
            String hostname = request.getRemoteHost();
            int portNumber = request.getRemotePort();
                        doc.put("hostname", hostname);
                        doc.put("ipaddress", yourIPAddress);
                        doc.put("portnumber", portNumber);

                        coll.insert(doc);

                } catch (Exception e) {
                        e.printStackTrace();
                }

                DBCursor cursor = coll.find();

                try {
                   while(cursor.hasNext()) {
                           response.getWriter().print(cursor.next());
                           response.getWriter().print("\n");
                   }
                } finally {
                   cursor.close();
                }
        }
}

right click on HellowMongodb.java in Enterprise Explorer Panel, and chose Run As -> Run on Server, and follow the instructions on screen, and you will see the result. Open the URL on different machine, you will see different machine entries added in MongoDB.

To use ant to build ear file, please refer to http://feijiangnan.blogspot.ca/2013/09/build-ear-file-with-ant-for-mongodb.html

Thursday, September 5, 2013

Oracle Database 11g: JDBC Connection Authentication Using Certificate

Please finish instructions 1-3.1 in Oracle 11g: SQLNet Authentication Using PKI

Create location to hold jar files needed, i.e. /home/oracle/SSL
$ mkdir -p /home/oracle/SSL
Copy the jar files needed to test the connection.
$ cd $ORACLE_HOME/jlib
$ cp ojpse.jar oraclepki.jar /home/oracle/SSL/
$ cp osdt_cert.jar osdt_core.jar /home/oracle/SSL/
$ cp $ORACLE_HOME/jdbc/lib/ojdbc6.jar /home/oracle/SSL/
Create DbSSLTester.java with below code:
    import java.security.Security;                                                                                                                                            

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;


    public class DbSSLTester

    {
    public static void main(String[] args)
    throws Exception
    {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Security.insertProviderAt(new oracle.security.pki.OraclePKIProvider(), 3);
    String url = "jdbc:oracle:thin:@(DESCRIPTION = " +
    "(ADDRESS_LIST = " +
    "(ADDRESS = " +
    "(PROTOCOL = TCPS)" +
    "(HOST = suzhou.goweekend.ca)" +
    "(PORT = 2484)" +
    ")" +
    ") " +
    "(CONNECT_DATA = (SERVICE_NAME = GUSU))" +
    ")";

    java.util.Properties info = new java.util.Properties();
    info.setProperty("oracle.net.authentication_services", "(TCPS)");
    info.setProperty("javax.net.ssl.trustStore", "/app/oracle/product/11.2.0.3/owm/wallets/fei/cwallet.sso");
    info.setProperty("javax.net.ssl.trustStoreType", "SSO");
    info.setProperty("javax.net.ssl.keyStore", "/app/oracle/product/11.2.0.3/owm/wallets/fei/cwallet.sso");
    info.setProperty("javax.net.ssl.keyStoreType", "SSO");

    Connection conn = DriverManager.getConnection(url, info);
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select user from dual");

    while (rset.next())
    System.out.println(rset.getString(1));

    rset.close();
    stmt.close();
    conn.close();
    }
    }
$ export CLASSPATH=$CLASSPSTH:/home/oracle/SSL/ojpse.jar:/home/oracle/SSL/oraclepki.jar:/home/oracle/SSL/osdt_cert.jar:/home/oracle/SSL/osdt_core.jar:/home/oracle/SSL/ojdbc6.jar
$ export PATH=/opt/jdk1.6.0_38/bin:$PATH
$ javac DbSSLTester.java
$java DbSSLTester
 FEI

Oracle Database 11g: SQLNet Authentication Using PKI


Secure connection between Oracle Server and Client

1. Create the server and client wallets

1.1 Server

  • Create wallet location
    $ mkdir /app/oracle/product/11.2.0.3/owm/wallets/server
  • Initiate wallet
    $ orapki wallet create -wallet /app/oracle/product/11.2.0.3/owm/wallets/server -auto_login -pwd think4me
  • Create self-signed certificate
    $ orapki wallet add -wallet /app/oracle/product/11.2.0.3/owm/wallets/server -dn 'CN=server' -keysize 2048 -self_signed -validity 3650 -pwd think4me
  • Export server root certificate
    $ orapki wallet export -wallet /app/oracle/product/11.2.0.3/owm/wallets/server -dn 'CN=server' -cert /app/oracle/product/11.2.0.3/owm/wallets/server/server_ca.cert

1.2 Client

  • Create wallet location
    $ mkdir /app/oracle/product/11.2.0.3/owm/wallets/fei
  • Initiate wallet
    $ orapki wallet create -wallet /app/oracle/product/11.2.0.3/owm/wallets/fei -auto_login -pwd think4me
  • Create self-signed certificate
    $ orapki wallet add -wallet /app/oracle/product/11.2.0.3/owm/wallets/fei -dn 'CN=fei' -keysize 2048 -self_signed -validity 3650 -pwd think4me
  • Export root certificate
    $ orapki wallet export -wallet /app/oracle/product/11.2.0.3/owm/wallets/fei -dn 'CN=fei' -cert /app/oracle/product/11.2.0.3/owm/wallets/fei/client_fei_ca.cert

2. Exchange the server and client root certificates

2.1 Import client root certificate into server wallet

$ orapki wallet add -wallet /app/oracle/product/11.2.0.3/owm/wallets/server -trusted_cert -cert /app/oracle/product/11.2.0.3/owm/wallets/fei/client_fei_ca.cert -pwd Welcome1

2.2 Import server root certificate into client wallet

$ orapki wallet add -wallet /app/oracle/product/11.2.0.3/owm/wallets/fei -cert /app/oracle/product/11.2.0.3/owm/wallets/server/server_ca.cert -pwd Welcome2

3. Configure TCPS on the server and client

3.1 Server

  • listener.ora
SID_LIST_LISTENER =
  (SID_LIST =    
    (SID_DESC =  
      (GLOBAL_DBNAME = weekend.db.goweekend.ca)
      (ORACLE_HOME = /app/oracle/product/11.2.0.3)
      (SID_NAME = weekend)                           
    )                                                
  )                                                  
SSL_CLIENT_AUTHENTICATION = TRUE
WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = /app/oracle/product/11.2.0.3/owm/wallets/server)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db.goweekend.ca)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCPS)(HOST = db.goweekend.ca)(PORT = 2484))
    )
  )
  •  sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (BEQ, TCPS)
SSL_VERSION = 0
NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME)
SSL_CLIENT_AUTHENTICATION = TRUE
WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = /app/oracle/product/11.2.0.3/owm/wallets/server)
    )
  )

3.2 Client

  • sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (TCPS)
SSL_VERSION = 0
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
SSL_SERVER_DN_MATCH = Yes
SSL_CLIENT_AUTHENTICATION = TRUE
WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = /opt/app/oracle/product/11.2.0.2/owm/wallets/fei)
    )
  )
  •  tnsnames.ora
WEEKEND =
  (DESCRIPTION =
   (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = tcps)(HOST = db.goweekend.ca)(PORT = 2484))
   )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = weekend)
    )
    (SECURITY =
      (SSL_SERVER_CERT_DN="CN=server"))
  )

4. Configure database and user

4.1 OS_AUTHENT_PREFIX and REMOTE_OS_AUTHENT

The database parameter OS_AUTHENT_PREFIX must be null and REMOTE_OS_AUTHENT must be FALSE.
SQL> show parameter remote_os_authent
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_os_authent                    boolean     FALSE
SQL> show parameter os_authent_prefix
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
os_authent_prefix                    string      ops$
SQL>
if any of them doesn't meet the requirements, use below command to change it.
Login as sysdba,

    SQL> alter system set remote_os_authent=FALSE scope=spfile;
    and
    SQL> alter system set os_authent_prefix='' scope=spfile;
If any above changes made, please restart the instance.

4.2 Users

The user within the database has to be created specifying the distiguished name (DN) on their certificate.

SQL> create user user2 identified externally as 'CN=fei';
The user should have have create session granted so they are able to connect,
SQL> grant create session to fei;
If the user exists, please run below command to change it.
SQL> alter user identified externally as 'CN=fei';

5. Test Connection

On client, run below command:
$ sqlplus /nolog
SQL> connect /@weekend
Connected.
SQL>



Thursday, August 29, 2013

Wednesday, August 28, 2013

SAS Folders and Logs



C:\SAS\StrategyManagementConfig\Lev1\Documents\Instructions.html


Monday, August 26, 2013

SNMP OID for disks

# snmpwalk -v 3 -l AuthNoPriv -u cactiadmin -A <password> <hostname>  .1.3.6.1.2.1.25.2.3.1
HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1                                                              
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3                                                              
HOST-RESOURCES-MIB::hrStorageIndex.6 = INTEGER: 6                                                              
HOST-RESOURCES-MIB::hrStorageIndex.7 = INTEGER: 7                                                              
HOST-RESOURCES-MIB::hrStorageIndex.8 = INTEGER: 8                                                              
HOST-RESOURCES-MIB::hrStorageIndex.10 = INTEGER: 10                                                            
HOST-RESOURCES-MIB::hrStorageIndex.31 = INTEGER: 31                                                            
HOST-RESOURCES-MIB::hrStorageIndex.32 = INTEGER: 32                                                            
HOST-RESOURCES-MIB::hrStorageIndex.33 = INTEGER: 33                                                            
HOST-RESOURCES-MIB::hrStorageIndex.34 = INTEGER: 34                                                            
HOST-RESOURCES-MIB::hrStorageIndex.35 = INTEGER: 35                                                            
HOST-RESOURCES-MIB::hrStorageIndex.36 = INTEGER: 36                                                            
HOST-RESOURCES-MIB::hrStorageIndex.37 = INTEGER: 37                                                            
HOST-RESOURCES-MIB::hrStorageIndex.38 = INTEGER: 38                                                            
HOST-RESOURCES-MIB::hrStorageIndex.39 = INTEGER: 39                                                            
HOST-RESOURCES-MIB::hrStorageIndex.40 = INTEGER: 40                                                            
HOST-RESOURCES-MIB::hrStorageIndex.41 = INTEGER: 41                                                            
HOST-RESOURCES-MIB::hrStorageIndex.42 = INTEGER: 42                                                            
HOST-RESOURCES-MIB::hrStorageIndex.43 = INTEGER: 43                                                            
HOST-RESOURCES-MIB::hrStorageIndex.44 = INTEGER: 44                                                            
HOST-RESOURCES-MIB::hrStorageIndex.45 = INTEGER: 45                                                            
HOST-RESOURCES-MIB::hrStorageType.1 = OID: HOST-RESOURCES-TYPES::hrStorageRam                                  
HOST-RESOURCES-MIB::hrStorageType.3 = OID: HOST-RESOURCES-TYPES::hrStorageVirtualMemory                        
HOST-RESOURCES-MIB::hrStorageType.6 = OID: HOST-RESOURCES-TYPES::hrStorageOther                                
HOST-RESOURCES-MIB::hrStorageType.7 = OID: HOST-RESOURCES-TYPES::hrStorageOther                                
HOST-RESOURCES-MIB::hrStorageType.8 = OID: HOST-RESOURCES-TYPES::hrStorageOther                                
HOST-RESOURCES-MIB::hrStorageType.10 = OID: HOST-RESOURCES-TYPES::hrStorageVirtualMemory                       
HOST-RESOURCES-MIB::hrStorageType.31 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk                           
HOST-RESOURCES-MIB::hrStorageType.32 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk                           
HOST-RESOURCES-MIB::hrStorageType.33 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk                           
HOST-RESOURCES-MIB::hrStorageType.34 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk                           
HOST-RESOURCES-MIB::hrStorageType.35 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk                           
HOST-RESOURCES-MIB::hrStorageType.36 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.37 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.38 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.39 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.40 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.41 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.42 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.43 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.44 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageType.45 = OID: HOST-RESOURCES-TYPES::hrStorageNetworkDisk                         
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory                                                 
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory                                                  
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Memory buffers                                                  
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: Cached memory                                                   
HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: Shared memory                                                   
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: Swap space                                                     
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /                                                              
HOST-RESOURCES-MIB::hrStorageDescr.32 = STRING: /dev                                                           
HOST-RESOURCES-MIB::hrStorageDescr.33 = STRING: /boot/efi                                                      
HOST-RESOURCES-MIB::hrStorageDescr.34 = STRING: /dbfs                                                          
HOST-RESOURCES-MIB::hrStorageDescr.35 = STRING: /sys/fs/fuse/connections                                       
HOST-RESOURCES-MIB::hrStorageDescr.36 = STRING: /scandoc                                                       
HOST-RESOURCES-MIB::hrStorageDescr.37 = STRING: /data1                                                         
HOST-RESOURCES-MIB::hrStorageDescr.38 = STRING: /data2                                                         
HOST-RESOURCES-MIB::hrStorageDescr.39 = STRING: /data3                                                         
HOST-RESOURCES-MIB::hrStorageDescr.40 = STRING: /data4                                                         
HOST-RESOURCES-MIB::hrStorageDescr.41 = STRING: /data5                                                         
HOST-RESOURCES-MIB::hrStorageDescr.42 = STRING: /data6                                                         
HOST-RESOURCES-MIB::hrStorageDescr.43 = STRING: /data7                                                         
HOST-RESOURCES-MIB::hrStorageDescr.44 = STRING: /data8                                                         
HOST-RESOURCES-MIB::hrStorageDescr.45 = STRING: /mnt                                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 1024 Bytes                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 1024 Bytes                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 1024 Bytes                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.7 = INTEGER: 1024 Bytes                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.8 = INTEGER: 1024 Bytes                                           
HOST-RESOURCES-MIB::hrStorageAllocationUnits.10 = INTEGER: 1024 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.31 = INTEGER: 4096 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.32 = INTEGER: 4096 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.33 = INTEGER: 4096 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.34 = INTEGER: 4096 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.35 = INTEGER: 4096 Bytes                                          
HOST-RESOURCES-MIB::hrStorageAllocationUnits.36 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.37 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.38 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.39 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.40 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.41 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.42 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.43 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.44 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageAllocationUnits.45 = INTEGER: 1048576 Bytes                                       
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 12155540                                                        
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 14259856                                                        
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 12155540                                                        
HOST-RESOURCES-MIB::hrStorageSize.7 = INTEGER: 4839032                                                         
HOST-RESOURCES-MIB::hrStorageSize.8 = INTEGER: 0                                                               
HOST-RESOURCES-MIB::hrStorageSize.10 = INTEGER: 2104316                                                        
HOST-RESOURCES-MIB::hrStorageSize.31 = INTEGER: 59534244                                                       
HOST-RESOURCES-MIB::hrStorageSize.32 = INTEGER: 1519442
HOST-RESOURCES-MIB::hrStorageSize.33 = INTEGER: 39892
HOST-RESOURCES-MIB::hrStorageSize.34 = INTEGER: 120180154
HOST-RESOURCES-MIB::hrStorageSize.35 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.36 = INTEGER: 1400856
HOST-RESOURCES-MIB::hrStorageSize.37 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.38 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.39 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.40 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.41 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.42 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.43 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.44 = INTEGER: 1393359
HOST-RESOURCES-MIB::hrStorageSize.45 = INTEGER: 534204
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 11836056
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 11849536
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 235324
HOST-RESOURCES-MIB::hrStorageUsed.7 = INTEGER: 4839032
HOST-RESOURCES-MIB::hrStorageUsed.10 = INTEGER: 13480
HOST-RESOURCES-MIB::hrStorageUsed.31 = INTEGER: 50409441
HOST-RESOURCES-MIB::hrStorageUsed.32 = INTEGER: 48
HOST-RESOURCES-MIB::hrStorageUsed.33 = INTEGER: 2984
HOST-RESOURCES-MIB::hrStorageUsed.34 = INTEGER: 47065623
HOST-RESOURCES-MIB::hrStorageUsed.35 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.36 = INTEGER: 1256834
HOST-RESOURCES-MIB::hrStorageUsed.37 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.38 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.39 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.40 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.41 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.42 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.43 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.44 = INTEGER: 947160
HOST-RESOURCES-MIB::hrStorageUsed.45 = INTEGER: 497161