Wednesday, January 20, 2010

OHS2 on Ubuntu (error loading shared libraries)

Trying to install the Oracle HTTP Server powered by Apache 2, I got the following errors:
/oracle/as/10.1.3/ohs/bin/apachectl startssl: execing httpd
/oracle/as/10.1.3/ohs/bin/httpd: error while loading shared libraries: libgdbm.so.2: cannot open shared object file: No such file or directory

That can be resolved by:
sudo ln -s /usr/lib/libgdbm_compat.so.3.0.0 /usr/lib/libgdbm.so.2

The next error on the opmn http log will be:
/oracle/as/10.1.3/ohs/bin/apachectl startssl: execing httpd
/oracle/as/10.1.3/ohs/bin/httpd: error while loading shared libraries: libdb-3.3.so: cannot open shared object file: No such file or directory

In order to resolve that, execute:
sudo ln -s /usr/lib/libdb-4.7.so /usr/lib/libdb-3.3.so

Oracle 10G R2 on Ubuntu 9.10 (ins_rdbms.mk link error)

Installing Oracle 10G release 2 on Ubuntu 9.10 (Karmic Koala) is pretty much the same as installing on 8.04, except for the extra packages needed. In this entry, I used
apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm libstdc++5
Problem with 9.10 is: libstdc++5 has been fased out and superseeded with libstdc++6.
When you try to install nevertheless, you'll get:
Package libstdc++5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package libstdc++5 has no installation candidate

Trying to go along with the installation will get you:

Error in invoking target 'all_no_orcl' of makefile 'ins_rdbms.mk'.

Workaround

The solution is simple: create a link to the V6 library:

sudo ln -s /usr/lib/libstdc++.so.6.0.13 /usr/lib/libstdc++.so.5

Fast!

I am, by the way, impressed about the speed of this install. I have the impression, this ext4 filesystsem is a lot faster than the 2-disk lvm I had on CentOS.

Sunday, January 17, 2010

Reaching out: the database as Web-browser

Many people may not know of the possibility to use the database as browser. Oracle dumped the RDBMS as database since the introduction of Oracle 8i, and made it some Jack-of-all-Trades. The browser capabilities were introduced even earlier, in release 7.3.3.

Why?

Indeed, you may want to ask: why? What use could this possibly have? Well, for one: gathering statistics about something you do not have direct access to. The weather, for example. Combined with PHP, you could deliver very sophisticated graphs on temperature, rain, moisture, etc, etc. In fact, I used it for such an application log time ago: prevent firefighters from getting asphyxiated by smoke from chemical fires by plotting a safe route to the fire.

METAR

OK, in order to have firefighters use safe access roads, I need to know the current wind direction - how to get that? Luckily, there's something called METAR (flyboy speak for Meteorological Aerodrome Report), and all (military) airfields provide one, as well as all automated weather stations, (weather-)ships and buoys.
The beauty of METAR is that it is released every half-hour, 24*7*365. I suspect the background of METAR was telex; these messages were distributed by telex, later by teletype machines. Just look how there pages are formatted:

ZCZC
SA171155 EHFS
METAR EHFS 171155Z AUTO 26015KT 9999NDV NCD 05/04 Q1016=

ZCZC
SA171325 EHAK
METAR EHAK 171325Z AUTO 13010KT 050V200 9999NDV SCT003/// OVC004///
04/04 Q1011=

ZCZC
SA171325 EHAM
METAR EHAM 171325Z 28015KT 9999 FEW012 07/05 Q1014 NOSIG=
Nowadays, these pages can be found on the internet. A couple of years ago, when I coded for this project, the teletype look-alike was still there. By now, those pages have to be "official", and carry links and graphical elements.

Decode

Let's take a look at a METAR, and take the last one from the previous example:
ZCZC
SA171325 EHAM
METAR EHAM 171325Z 28015KT 9999 FEW012 07/05 Q1014 NOSIG=

ZCZC is the attention signal, the (radio-)teletype "Start of Message" code. Is not a part of the METAR itself, but is a part of the communications protocol.
SA171325 EHAM SA used to signify this is a Surface Aviation observation, but the coding would differ from the METAR standard. Not sure what it signifies here. 171325 is the date (17th) and time (13:25) on which this message was released. Time is Zulu, or GMT.
EHAM is the international designation of the location, according to ICAO (International Civil Aviation Organization) standard. It just so happens to be Amsterdam Airport, Schiphol (or Ships Hell)
METAR Indicates this is METAR coded, as opposed to SA-format.
EHAM See above: designates origin.
171325Z See above: date and time (GMT)
28015KT Wind speed and direction: 15 Knots, from 280 degrees. North being 0 degrees, so this would be West-North-West-Western (WNWW), as West would be 270. Sometimes followed by G33, meaning Gusts of wind up to 33 knots.
9999 Visibility (in meters). 9999 is excellent, better than 10 Km. Sometimes entries like 1000SE 5000N: 1000 meters South East, 5000 meters in Northerly direction.
FEW012 Cloud indication: there are a few (12.5~25%) clouds from 1200 feet upwards. May be suffixed with type of cloud (like CB: cumulonimbus, or thunderstorm cloud)
07/05 Temperature readings (in Celsius): 07 is the current temperature, 05 is the thaw temperature. These can be used to deduct the Relative humidity. Possibly prefixed with the letter 'M' to indicate minus. Zero filled, two position numbers.
Q1014 Pressure in hPa. Current air pressure in Amsterdam is 1014 hPa. Zero filled, four position number.
NOSIG No Significant changes in weather. Civilian code; military use color codes.
= The End-of-Communication indicator. Used to be NNNN.

Eindhoven airport is a military airport; this is their METAR:
ZCZC
SA171425 EHEH
METAR EHEH 171425Z AUTO 27010KT 9999NDV SCT017 BKN020 07/04 Q1016
WHT WHT TEMPO BLU=
There's a nice table here, explaining the color codes.

Of course, there's much more with METAR. The internet has plenty examples, and this is always a nice start. At least, now I know where to look for wind direction, and possibly a forecast.

utl_http

In order to get the internet downloaded into the database, I use utl_http. Basically, the code consisted of only a few lines:
procedure weerrapport is
l_piece utl_http.html_pieces;
l_url1 varchar2(80) := 'http://www.knmi.nl/product/luchtv/nedactbe.htm';
l_url2 varchar2(80) := 'http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=EHLE';
l_tmp varchar2(32767);
l_line varchar2(256);
dummy boolean;
begin
l_piece := utl_http.request_pieces (l_url1, 10);
for i in 1..l_piece.count
-- Piece the lot together again...
loop
l_tmp := l_tmp||l_piece(i);
end loop;
-- Discard everything not in the BODY...
l_tmp := substr(l_tmp, instr(upper(l_tmp), '<BODY'),32676);
-- Get Deelen (EHDL) and Lelystad info (EHLE)
into_weer(l_tmp,'EHDL');
into_weer(l_tmp,'EHLE');
commit;
end weerrapport

Lots of unsafe programming here: I simply work on the basis (not an assumption, back then!) that the page returned will not exceed 20kB. Yes - that is 20kB, not 32kB, as I only fetch 10 pieces (of 2000 byte) of HTML code. By now, the page has increased in size, but it still is about 14kB.
Nevertheless, some mechanism to handle overflows should have been incorporated.

The into_weer procedure is simply a further stripping of unnecessary text, and saving the metar to the database:

procedure into_weer(p_string IN varchar2, p_station IN varchar2)
IS
l_line varchar2(256);
begin
if instr(upper(p_string),p_station) > 0
then
l_line := replace(substr(p_string,
instr(upper(p_string),p_station,1,2)
,256
),
chr(10),' ');
l_line := substr(l_line, 1, instr(upper(l_line),'ZCZC') - 1);
begin
insert into weer (bron, site, dag, metar) values
('KNMI', p_station, to_date(substr(l_line,6,6),'DDHH24MI'), l_line);
exception
when others then
NULL;
end;
end if;
end into_weer;

Again, very bad programming: an exception handler that hides any exception: "I do not wanna know about any mishaps"

Follow-up

Of course, there could be a follow-up: how to get from METAR to ordinary spoken weather forecast, or how to get from temperature and thew point to relative humidity. May be I will.

Special Characters - notes and comments

Reason for this entry is the rather disturbing observation, you can actually get different results from one and the same script.
The scenario is running a script, that uses embedded "special" characters (an €, in this case) and is executed using either the CLI version of SQL*Plus (sqlplus.exe), or the Windowed version (sqlplusw.exe).

Code Pages

It turns out that both versions use different MS Windows code pages: the Windowed version, sqlplusw.exe, picks up the code page of MS Windows, while the CLI version uses the code page of the CLI. I ended up with different binary values of the character.
By default, these differ on all non-US installations of MS Windows!

Debugging

In the course of the blog entries, I have mentioned, but never made a list of tell-tale signs. A troubleshooting list so to say. Here's a start:
  • Remember: there's always at least one way to screw up. There's no recipe, no Rule-of-Thumb, or whatever to make sure you'll never end up with weird glyphs.
    Unless you control the whole, single-user, system, that is...
  • If you see a small diamond in web browser, start hitting your web designer/builder: the page encoding is incorrect for the characters used.
    You can change the Character Set Coding in most browsers as workaround.
  • If you see inverted ('"upside-down") question marks, your Oracle infrastructure is to blame: somewhere along the line, character set conversion takes place, for which the "to-character set" does not have a glyph defined (e.g. ISO8859P1 does not have a glyph for the Euro-sign)


[add Apr 2011] A rather good note on this is Doc ID 158577.1 on Metalink.

Wednesday, January 13, 2010

Ubuntu 9.10 (and Oracle's support for it)

It's official... CentOS is exit, I'm now running Ubuntu 9.10 (or Karmic Koala).

Of course, I'll set up Oracle again, which appears to be very easy, as Oracle provided a Debian (and thus Ubuntu) repository. This should allow Debian and Ubuntu users to install Oracle by using Synaptic Package Manager. Point an shoot installs... I am curious!

Add the repository

You do have to make Ubuntu aware of the fact Oracle is a source of software, too. For that, you need to add the location of the repository to your configuration. This is accomplished by:

frank@cs-frank03:~$ sudo gedit /etc/apt/sources.list
Scroll to the bottom of the file, and add:
# Oracle stuff
deb http://oss.oracle.com/debian unstable main non-free

After that, update the libraries to allow Software Center to show Oracle, enter:

frank@cs-frank03:~$ sudo apt-get update

Now, fire up Synaptic, and click on the 'Origin' button; you should see oss.oracle.com/main listed. Point at it, and you will see XE (in two flavours) and the XE client.

Now, if only I just wanted XE...

yum


For non-Debian, there's support for yum as well; check it out!

Tuesday, January 12, 2010

More APEX notes

A very, very quick way of housekeeping:

BEGIN
APEX_INSTANCE_ADMIN.REMOVE_WORKSPACE ('&workspace_name','Y','Y');
END;
/

It will drop your code, database accounts, and tablespace associated with it.

If you ever want to create a workspace, and do some basic housekeeping:

set echo off verify off
accept apex_short_name prompt 'Enter the short APEX applicaton name: '
prompt ...Creating the APEX tablespace...
--
create tablespace &apex_short_name
datafile '/oracle//&apex_short_name.01.dbf'
size 10m
autoextend on
next 5m
maxsize 1000m
extent management local
uniform size 64k;
-- User and grants
prompt ...Creating user and granting rights...
--
grant connect, resource
to &apex_short_name._owner identified by &apex_app_db_password;
grant execute on dbms_pipe to &apex_short_name._owner;
alter user &apex_short_name._owner default atblespace &apex_short_name;
alter user &apex_short_name._owner quota unlimited on &apex_short_name;
-- APEX Workspace and schema
prompt ...Creating APEX Workspace &apex_short_name
BEGIN
APEX_INSTANCE_ADMIN.ADD_WORKSPACE (
p_workspace => '&apex_short_name',
p_primary_schema => '&apex_short_name._owner',
p_additional_schemas => null);
END;
/
--
prompt ...Creating APEX Workspace administrator account...
--
begin
wwv_flow_api.set_security_group_id(
p_security_group_id=>APEX_UTIL.FIND_SECURITY_GROUP_ID('&apex_short_name'));
end;
/

begin
wwv_flow_fnd_user_api.create_fnd_user (
p_user_name => '&apex_short_name._ADMIN',
p_web_password => '&apex_short_name._ADMIN',
p_group_ids => '',
p_developer_privs=> 'ADMIN:CREATE:DATA_LOADER:EDIT:HELP:MONITOR:SQL',
p_default_schema=> '&apex_short_name._OWNER',
p_account_locked=> 'N',
p_account_expiry=> to_date('201001011300','YYYYMMDDHH24MI'),
p_failed_access_attempts=> 0,
p_change_password_on_first_use=> 'N',
p_first_password_use_occurred=> 'Y',
p_allow_access_to_schemas => '');
end;
/

commit;

For a given value of "abc" for apex_short_name, this will create:
  • a tablespace ABC, with an associated datafile abc01.dbf
  • a database account abc_owner with a password of your choice
  • an APEX workspace abc, with an associated abc_owner schema
  • an APEX Workspace administrator abc_ADMIN, with a password abc_ADMIN

Mind you: APEX Passwords are case sensitive; account names are not.

Monday, January 11, 2010

RSA-768 cracked

Today I read the announcement, RSA-768 is factorized, that is, the prime numbers of which the 232-digit number consists, are known.
English, and original, announcement, and a Dutch comment.

It may have taken a lot of time, but it just shows: nothing is secret. I previously blogged about SHA1 and MD-5 being broken, and actually being used for forgery.

Nice date format


Today is (was) 54 decimal.