Wednesday, January 9, 2013

Installing Oracle RAC When SSH Is Listening On A Non-Default Port

It's not uncommon to see server environments where ssh is configured to listen on a non-default port (other than port 22). Though this has no consequence when installing a single instance Oracle DB.For clusterware or RAC installation this would make the OUI and runcluvfy to fail on the user equivalence if minor configuration changes are not made.
When ssh is running on a non-default port to ssh from one server to another the port must be specified, similar to
ssh -p 2020 remotehost
or an alias could be setup with ssh name and value with port such
alias ssh='ssh -p 2020'
and then simply use ssh remotehost.
It's even possible to create user equivalency manually for grid or oracle user using /usr/sbin/ssh-keygen and get pass-phraseless ssh access among the nodes considered for cluster installation by specifying the ssh port. However the sshUserSetup.sh script will fail as it tries create user equivalency as it uses /usr/bin/ssh in the script (without port) and this results in it being unable to copy the generated keys to nodes listed.
The user may be prompted for a password here since the script would be running SSH on host DB-01.
ssh: connect to host DB-01 port 22: Connection refused
Done with creating .ssh directory and setting permissions on remote host DB-01.
Creating .ssh directory and setting permissions on remote host DB-02
THE SCRIPT WOULD ALSO BE REVOKING WRITE PERMISSIONS FOR group AND others ON THE HOME DIRECTORY FOR grid. THIS IS AN SSH REQUIREMENT.
The script would create ~grid/.ssh/config file on remote host DB-02. If a config file exists already at ~grid/.ssh/config, it would be backed up to ~grid/.ssh/config.backup.
The user may be prompted for a password here since the script would be running SSH on host DB-02.
ssh: connect to host DB-02 port 22: Connection refused
Done with creating .ssh directory and setting permissions on remote host DB-02.
Copying local host public key to the remote host DB-01
The user may be prompted for a password or passphrase here since the script would be using SCP for host DB-01.
ssh: connect to host DB-01 port 22: Connection refused
lost connection
Done copying local host public key to the remote host DB-01
Copying local host public key to the remote host DB-02
The user may be prompted for a password or passphrase here since the script would be using SCP for host DB-02.
ssh: connect to host DB-02 port 22: Connection refused
lost connection
Done copying local host public key to the remote host DB-02
ssh: connect to host DB-01 port 22: Connection refused
ssh: connect to host DB-02 port 22: Connection refused
SSH setup is complete.
As mentioned earlier it's possible to manually create the user equivalency or even edit the script. But this will not make runcluvfy.sh or OUI pass the user equivalency test.
OUI failing even after creating user equivalency manually.

Running runcluvfy.sh will fail with
Checking user equivalence...
PRVF-4007 : User equivalence check failed for user "grid"
Check failed on nodes:
DB-01,DB-02
Alias on ssh as mentioned earlier is no use as these use the full path "/usr/bin/ssh" thus alias seem to get ignored. One of the other workaround tried was to create a script name ssh and call the original ssh executable with port and whatever parameter passed on to it.
cd /usr/bin
mv ssh sshi
and then create an file called ssh in /usr/bin with following text, assuming ssh runs on port 2020
/usr/bin/sshi -p 2020 $*
This managed to get the runcluvfy.sh working for local node but still failed checking pre-reqs on the remote node and didn't go into detail investigation into why it failed.
Finally raised an SR asking if it's possible to install Oracle RAC when ssh is listening on a non-default port and if so how to get runcluvfy.sh to pass the user equivalence.



Strangely Oracle's answer was to unblock the port 22 (run ssh on default port) and once installed change back to non-default port. SSH is only used during installation, upgrades, patches and etc not during "normal" database activities. But according to 220970.1 user equivalency must exists even after the installation as many assistants and scripts depends on it.
It was tested on a existing environment by changing the ssh port from 22 to 2020 and see if cluster stack would start without an error and all "seemed to be fine" (it wasn't an extensive test, just start and stop) but this approach didn't seem something good to have on a production system (changing ssh port every time some script fails due to missing user equivalency).
Oracle asked to trace the runcluvfy.sh comp nodecon and upload files and after looking at the output said "issue is similar to 4193093 and it's not a bug but an exception". Couldn't find anything on 4193093 so it must be some internal bug document. But still didn't resolve the issue at hand.
Used strace to get the system calls for the command executed by cluvfy to check user equivalency.
strace -o db01_output_ssh_p.log /usr/bin/ssh -p 2020 -o FallBackToRsh=no -o PasswordAuthentication=no -o StrictHostKeyChecking=yes -o NumberOfPasswordPrompts=0 DB-02 /bin/true
Looking at the output of the strace it could be seen the ssh is using the default port even though port change is specified in sshd_config (this is RHEL 5 server 2.6.18-308.24.1.el5).
connect(3, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("xxx.xxx.xx.xx")}, 16) = -1 ECONNREFUSED (Connection refused)
Oracle's answer was the above line shows that when port is not passed ssh still uses default port this is not a bug. But still if it's needed to pass a port to cluvfy then it must go through the product enhancement process. Not exactly what was needed for the problem at hand and not much help coming from the SR.
But the strace output did give an idea. Why is it ssh still using port 22 even when port 2020 is defined in the sshd_config? Answer is ssh configuration parameters are loaded from ~/.ssh/config file. This is already created as part of clusterware pre-req. All that's needed to get user equivalence working when ssh is listening on a non-default port is to specify the port in the user's (oracle and grid) .ssh/config file.
grid]$cat .ssh/config
Host *
        ForwardX11      no
        Port    2020
After this no need to specify the port (use ssh -p 2020) on the shell command and runcluvfy.sh runs without an error on user equivalence.
Check: User equivalence for user "grid"
  Node Name                             Status
  ------------------------------------  ------------------------
  DB-01                             passed
  DB-02                             passed
Result: User equivalence check passed for user "grid"
Confirmation that ssh is using the non-default port from the strace
connect(3, {sa_family=AF_INET, sin_port=htons(2020), sin_addr=inet_addr("xxx.xxx.xx.xx")}, 16) = 0
Bottom line is Oracle RAC can be installed when ssh is listening on a non-default port (something asked on the SR and Oracle didn't give an answer to). No changes are required on Oracle, simply add the ssh port to .ssh/config file.

Monday, January 7, 2013

Moving Stored Outlines From One Database To Another

Moving stored outlines from one database to another involves simply exporting the outline schema tables (outln.ol$,outln.ol$hints and outln.ol$nodes) from the source database to another. Since the outlines are global even if the user schema under which the outlines are created is not present in the destination database, any schema running the same sql in the destination database will use the store outline.(provided other outline related constraints are met. Refer 67536.1 and 132547.1) Stored outlines don't depend on the schema and once created all user schema running the same SQL could use the stored outline.
This post shows steps to transfer the earlier created outlines to a different database where the schema under which outlines were initially created is not present.
1. Export the current outlines
SQL> select owner,name from dba_outlines;

OWNER       NAME
----------- -------------
ASANGA      JDBC_OUTLINE
ASANGA      FULL_TABLE
Exporting with exp
exp system/std11g1db  file=outlns.dmp tables=\(outln.ol\$,outln.ol\$hints,outln.ol\$nodes\) statistics=none

Export: Release 11.1.0.7.0 - Production on Mon Jan 7 10:58:27 2013

Connected to: Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
Current user changed to OUTLN
. . exporting table                            OL$          2 rows exported
. . exporting table                       OL$HINTS         20 rows exported
. . exporting table                       OL$NODES         26 rows exported
Export terminated successfully without warnings.
2. The stored outlines are owned by user asanga but this user is missing in the destination database
SQL> select username from dba_users order by 1;

USERNAME
------------------------------
ANONYMOUS
BEAR
DBSNMP
DIP
EXFSYS
ORACLE_OCM
OUTLN
PERFSTAT
SYS
SYSTEM
TSMSYS
WMSYS
XDB
XS$NULL
It's assumed that at the destination database the application schema is named "bear".
3. Copy the generated dump file to the destination and import it into the destination database.
imp system/racse11g1db file=outlns.dmp full=y ignore=y

Import: Release 11.1.0.7.0 - Production on Mon Jan 7 11:31:05 2013

Connected to: Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
With the Real Application Clusters option

Export file created by EXPORT:V11.01.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
export client uses AL32UTF8 character set (possible charset conversion)
. importing SYSTEM's objects into SYSTEM
. importing OUTLN's objects into OUTLN
. . importing table                          "OL$"          2 rows imported
. . importing table                     "OL$HINTS"         20 rows imported
. . importing table                     "OL$NODES"         26 rows imported
Import terminated successfully without warnings.
4. Even though the user asanga is missing in the destination database, the stored outlines will be showed as owned by user asanga.
SQL> show user
USER is "SYS"

SQL> select  owner,name from dba_outlines;

OWNER    NAME
-------- --------------------
ASANGA   FULL_TABLE
ASANGA   JDBC_OUTLINE
and there will be no stored outlines under user_outlines views for user "bear".
SQL> conn bear/bear
Connected.
SQL> select name from user_outlines;

no rows selected
5. But if the same SQL is executed under the user bear schema the SQL will use the appropriate outline (it's assumed use stored outline is set).
SQL> select count(*) from big_table where p_id=1;

SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS OUTLINE'));
SQL_ID  80151fvm1d9af, child number 0
-------------------------------------
select count(*) from big_table where p_id=:"SYS_B_0"

Plan hash value: 599409829

-------------------------------------------------
| Id  | Operation          | Name      | E-Rows |
-------------------------------------------------
|   0 | SELECT STATEMENT   |           |        |
|   1 |  SORT AGGREGATE    |           |      1 |
|*  2 |   TABLE ACCESS FULL| BIG_TABLE |      2 |
-------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
      DB_VERSION('11.1.0.7')
      OPT_PARAM('_optimizer_extended_cursor_sharing' 'none')
      OPT_PARAM('_optimizer_extended_cursor_sharing_rel' 'none')
      OPT_PARAM('optimizer_index_cost_adj' 25)
      OPT_PARAM('optimizer_index_caching' 90)
      FIRST_ROWS(1000)
      OUTLINE_LEAF(@"SEL$1")
      FULL(@"SEL$1" "BIG_TABLE"@"SEL$1")
      END_OUTLINE_DATA
  */

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("P_ID"=:SYS_B_0)

Note
-----
   - outline "FULL_TABLE" used for this statement
   - Warning: basic plan statistics not available. These are only collected when:
       * hint 'gather_plan_statistics' is used for the statement or
       * parameter 'statistics_level' is set to 'ALL', at session or system level


6. User "bear" could be made to own the stored outline by creating a private outline and then refreshing the public outline with it.
SQL> create private outline myfulltable from full_table;
Outline created.

SQL> execute dbms_outln_edit.refresh_private_outline('MYFULLTABLE');
PL/SQL procedure successfully completed.

SQL> create or replace outline full_table from private MYFULLTABLE;
Outline created.
After this the full_table outline will appear when user_outline is queried in "bear" schema.
SQL> select name from user_outlines;

NAME
-----------
FULL_TABLE
Querying dba_outlines shows now the outline is owned by user "bear"
SQL> select owner,name from dba_outlines;

OWNER    NAME
-------- --------------------
ASANGA   JDBC_OUTLINE
BEAR     FULL_TABLE
7. Verify that stored outline is still used.
SQL> select count(*) from big_table where p_id=1;

SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS OUTLINE'));
SQL_ID  80151fvm1d9af, child number 0
-------------------------------------
select count(*) from big_table where p_id=:"SYS_B_0"

Plan hash value: 599409829

-------------------------------------------------
| Id  | Operation          | Name      | E-Rows |
-------------------------------------------------
|   0 | SELECT STATEMENT   |           |        |
|   1 |  SORT AGGREGATE    |           |      1 |
|*  2 |   TABLE ACCESS FULL| BIG_TABLE |      2 |
-------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
      DB_VERSION('11.1.0.7')
      OPT_PARAM('_optimizer_extended_cursor_sharing' 'none')
      OPT_PARAM('_optimizer_extended_cursor_sharing_rel' 'none')
      OPT_PARAM('optimizer_index_cost_adj' 25)
      OPT_PARAM('optimizer_index_caching' 90)
      FIRST_ROWS(1000)
      OUTLINE_LEAF(@"SEL$1")
      FULL(@"SEL$1" "BIG_TABLE"@"SEL$1")
      END_OUTLINE_DATA
  */

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("P_ID"=:SYS_B_0)

Note
-----
   - outline "FULL_TABLE" used for this statement
   - Warning: basic plan statistics not available. These are only collected when:
       * hint 'gather_plan_statistics' is used for the statement or
       * parameter 'statistics_level' is set to 'ALL', at session or system level

Related Post
Changing Execution Plan Using Stored Outline

Useful metalink notes
Stored Outline Quick Reference [ID 67536.1]
How to Transfer Stored Outlines from One Database to Another (9i and above) [ID 728647.1]

Friday, January 4, 2013

Blank VNC Screen

A new install RHEL 5 remote server handed over to install Oracle. Verified required Linux packages are installed and installed missing ones. Start VNC to run the web browser to directly download Oracle software (11.2.0.3) to server but VNC screen shown is blank.
Had already done the usual VNC configuration such as uncommenting
# Uncomment the following two lines for normal desktop:
 unset SESSION_MANAGER
 exec /etc/X11/xinit/xinitrc
in .vnc/xstartup but still no luck.


After some searching one suggestion was to install X windows system.
yum groupinstall "X Window System"
Run VNC again blank screen has disappeared but the desktop is still not "nice".

Installed gnome desktop
yum groupinstall "GNOME Desktop Environment"
and change the twm with gnome in .vnc/xstartup
#gnome-session &
twm &
No difference still the same desktop as before. Finally decided to installed KDE desktop
yum groupinstall "kde-desktop"
Finally the "nice" desktop.

It's not necessary to install X-windows and gnome desktop and then KDE. Installing KDE desktop when the blank screen is visible will resolve the blank screen issue.