Charles University Prague, Czech Republic
- MS in Computer Science (data engineering specialization) - 1997
- BS in Computer Science - 1994
Charles University Prague, Czech Republic
cint.exe> L vector
cint.exe> {vector<int> temps;}
cint.exe> {temps.push_back(6);}
cint.exe> {temps.push_back(4);}
cint.exe> {temps.push_back(5);}
cint.exe> {temps.size();}
(const unsigned int)3
cint.exe> {temps[0];}
(int)6
cint.exe> {temps[1];}
(int)4
cint.exe> {temps[2];}
(int)5
cint.exe>
So it works well, now there is time to try some algorithm
cint.exe> L algorithm
cint.exe> {sort(temps.begin(),temps.end());}
Error: Template Function value_type(first) is not defined in current scope algo.h(735)
!!!Dictionary position rewound... !!!Error recovered!!!
cint.exe>
It seems that there is some problem with STL lib coming with CINT in Windows. Looking at STL header files, I found that Function value_type is declared in _iterator.h surrounded by a condition for whatever reason
#if (G__GNUC>=3) #if (G__GNUC_VER>=3001) ... templateTo fix it is fairly simpleinline T* value_type(const vector ::iterator&) {return (T*)(0);} .. #endif #endif
d:\cint-5.16.19\cint.exe
cint : C/C++ interpreter (mailing list 'cint@root.cern.ch')
Copyright(c) : 1995~2005 Masaharu Goto (gotom@hanno.jp)
revision : 5.16.19, March 16, 2007 by M.Goto
No main() function found in given source file. Interactive interface started.
'h':help, 'q':quit, '{statements;}' or 'p [expr]' to evaluate
cint.exe> {#define G__GNUC 4}
cint.exe> {#define G__GNUC_VER 4001}
cint.exe> L vector
cint.exe> L algorithm
cint.exe> {vector<int> temps;}
cint.exe> {temps.push_back(6);}
cint.exe> {temps.push_back(4);}
cint.exe> {temps.push_back(5);}
cint.exe> {temps.size();}
(const unsigned int)3
cint.exe> {temps[0];}
(int)6
cint.exe> {temps[1];}
(int)4
cint.exe> {temps[2];}
(int)5
cint.exe> {sort(temps.begin(),temps.end());}
cint.exe> {temps[0];}
(int)4
cint.exe> {temps[1];}
(int)5
cint.exe> {temps[2];}
(int)6
cint.exe>
L that load files into interpreter, and file that list these loaded files.
cint.exe> L iostream cint.exe> files 0 fp=0x781c1bd0 lines=13 file="iostream" 1 fp=0x781c1bf0 lines=479 file="iostream.h" 2 fp=0x781c1c10 lines=11 *file="iosenum.h" 3 fp=0x781c1c30 lines=34 file="bool.h" 4 fp=0x781c1c50 lines=173 *file="_iostream"If we use
#include in curly bracket, we will get the same result
cint.exe> {#include <iostream>}
cint.exe> files
0 fp=0x781c1bf0 lines=13 file="iostream"
1 fp=0x781c1c10 lines=479 file="iostream.h"
2 fp=0x781c1c30 lines=11 *file="iosenum.h"
3 fp=0x781c1c50 lines=34 file="bool.h"
4 fp=0x781c1c70 lines=173 *file="_iostream"
U command unload a file, a C/C++ header file can include other header files, which in turn can include additional header files and so all. CINT is good enough and maintain this dependencies so if we unload one file, others referenced files may get unloaded also.
cint.exe> L string cint.exe> files 0 fp=0x781c1bd0 lines=11 file="string" 1 fp=0x781c1bf0 lines=72 file="_string" 2 fp=0x 0 lines=0 file="string.dll" 3 fp=0x781c1c10 lines=13 file="iostream" 4 fp=0x781c1c30 lines=479 file="iostream.h" 5 fp=0x781c1c50 lines=11 *file="iosenum.h" 6 fp=0x781c1c70 lines=34 file="bool.h" 7 fp=0x781c1c90 lines=173 *file="_iostream" cint.exe> U string cint.exe> filesreset
reset reset interpreter environment and unload all files
cint.exe> {int a=1;}
cint.exe> {a;}
(int)1
cint.exe> reset
cint.exe> {a;}
Error: Symbol a is not defined in current scope (tmpfile)(1)
!!!Dictionary position rewound... !!!Error recovered!!!
cint.exe> L vector
cint.exe> files
0 fp=0x781c1bd0 lines=11 file="vector"
1 fp=0x781c1bf0 lines=18 file="_vector"
2 fp=0x 0 lines=0 file="vector.dll"
3 fp=0x 0 lines=0 file="vectorbool.dll"
4 fp=0x781c1c10 lines=313 file="_vector.h"
5 fp=0x781c1c30 lines=282 file="function.h"
6 fp=0x781c1c50 lines=34 file="bool.h"
7 fp=0x781c1c70 lines=235 file="algobase.h"
8 fp=0x781c1c90 lines=55 file="_pair.h"
9 fp=0x781c1cb0 lines=17 file="_iterator"
10 fp=0x781c1cd0 lines=668 file="_iterator.h"
11 fp=0x781c1cf0 lines=6 file="stddef.h"
12 fp=0x781c1d10 lines=479 file="iostream.h"
13 fp=0x781c1d30 lines=11 *file="iosenum.h"
14 fp=0x781c1d50 lines=173 *file="_iostream"
15 fp=0x781c1d70 lines=177 file="defalloc.h"
16 fp=0x781c1d90 lines=34 file="new.h"
17 fp=0x781c1db0 lines=34 file="stdio.h"
18 fp=0x 0 lines=0 file="stdfunc.dll"
19 fp=0x781c1dd0 lines=14 file="stdlib.h"
20 fp=0x 476800 lines=19 file="limits.h"
-- Press return for more -- (input [number] of lines, Cont,Step,More)
cint.exe> reset
cint.exe> files
cint.exe>
d:\cint-5.16.19\cint.exe
cint.exe>{#include <iostream>
cint.exe>{cout << "Hello World\n";}
Hello World (class ostream)2085223112
C/C++ code shall be type inside curly bracket {...}, CINT doesn't allow to define function in interactive console
> { int func999() {return 999;} }
Limitation: Function can not be defined in a command line or a tempfile
You need to write it in a source file (tmpfile)(1)
!!!Dictionary position rewound... !!!Error recovered!!!
So we have to create separate file e.g.
# func999.cpp
int func999() {
return 999;
}
,load it in the console and call a function inside
cint.exe>L func999.cpp
cint.exe>{func999();}
Some of the most frequently used commands includes
L- load file in to the console U - unload the file file - show which files are currently loaded reset - reset memory of CINT console to initial state,unload all files q - quit CINT console
fun! zip#Read(fname,mode) ... exe "silent r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1) ... endfunto
fun! zip#Read(fname,mode) ... if fname =~ '.class$' exe "silent r! ".g:zip_unzipcmd." -o -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1) exe "silent r! jad -lnc -p ".s:Escape(fname,1) else exe "silent r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1) endif ... endfun2. download unzip.exe, jad.exe and put them in the PATH
C:\python ActivePython 2.5.2.2 (ActiveState Software Inc.) based on Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print 'hello world' hello world >>> print 1+2+3 6 >>> exit()Run a script in the interpreter
>>execfile('sample.py')
Create string from a template
>>> "my name is %s, my age is %d" % ("Goto",30)
'my name is Goto, my age is 30'
>>>
Ruby has the same function
irb(main):004:0> "my name is %s, my age is %d" % ["Goto",30] => "my name is Goto, my age is 30" irb(main):005:0>but there is nicer way to do it
irb(main):005:0> name,age = "Goto",31
=> ["Goto", 31]
irb(main):006:0> "my name is #{name}, my age is #{age}"
=> "my name is Goto, my age is 31"
Create a substring from a string
>>> s='hello world' >>> s[0] 'h' >>> s[0:10] #substring from a position(inclusive) until other (non inclusive) 'hello worl' >>> s[2:] #substring to end of string 'llo world' >>> s[:2] #substring from start until other (non inclusive) 'he' >>> s[-2:] #negative position indicates position from end of the string 'ld'The equivalent in Ruby would be
$ irb >> s="hello world" => "hello world" >> s[0] => 104 >> s[0..0] => "h" >> s[0..(10-1)] #unlike Python, Ruby includes the end position => "hello worl" >> s[2..-1] # -1 indicate relative position from end => "llo world" >> s[0..(2-1)] => "he" >> s[-2..-1] => "ld"Unlike Ruby, Python still throw
out of range exception for single indice operation
>>> s[20] Traceback (most recent call last): File "String is immutable", line 1, in IndexError: string index out of range >>> s[20:30] # this is OK as it consider as slice operation ''
>>> s[0:5] 'hello' >>> s[0:5]="bye" Traceback (most recent call last): File "In Ruby we can do", line 1, in TypeError: 'str' object does not support item assignment >>> s1 = "bye" + s[5:] # to achieve the same goal we need create string from other string >>> print s1 bye world
>> s[0..4]="bye" => "bye" >> print s bye world=> nilAs string is considered value object, create new string instead of changing an existing express that concept more clearly.
>>> y=('a',2)
>>> y[1]=1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> y
('a', 2)
example of list
>>> x=['a',2] >>> x[1]=1 >>> x ['a', 1]iterate over list or tuple
>>> items = ('a','b',2)
>>> for e in items:
... print e
...
a
b
2
Hash aka dictionary
>>> h = {1:'a',2:'b',3:'c'}
>>> h.__class__
<type 'dict'>
>>> h[3] = 'z'
>>> h
{1: 'a', 2: 'b', 3: 'z'}
>>>
iterate over dictionary
>>> for k,v in h.iteritems(): ... print "%d=>%s" % (k,v) ... 1=>a 2=>b 3=>z
h.items() also works well
>>> y = ('a',2)
>>> y.__class__
<type 'tuple'>
>>> y.__class__ == tuple
True
>>> z = tuple(y)
>>> z
('a', 2)
example of user defined class
>>> class Foo: ... def m(self): ... print self.__class__ ... >>> >>> Foo().m() __main__.Foo >>>Module
$ cat hello.py def say(whom): return "hello %s" % whomTo use method defined in a module, just import the module and call the function preceding by the module name plus '.'
>>> import hello
>>> hello.say('world')
'hello world'
It is also common to mix module methods into current name space, so we can call method without typing module name
>>> from hello import *
>>> say('moon')
'hello moon'
>>>
Parameters
*params and **params.
def foo(*numbers):
return sum(numbers)
print foo(23, 42) # prints: 65
The second form is name based, in which caller pass a list name,value pairs and calling function receives then as a hash map.
def bar(**options):
if "verbose" in options and options["verbose"]:
print "verbose is ON"
else:
print "verbose is OFF"
bar(verbose=True) # print: "verbose is ON"
bar(verbose=False) # print: "verbose is OFF"
bar(force=True) # print: "verbose is OFF"
... ... disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" diskLib.dataCacheMaxReadAheadSize = "0" diskLib.dataCacheMinReadAheadSize = "0" diskLib.dataCachePageSize = "4096" diskLib.maxUnsyncedWrites = "0" scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsi1.sharedBus = "VIRTUAL" ... ...Network setting
/etc/hosts # public 190.2.4.100 rac1 rac1-en0 190.2.4.101 rac2 rac2-en0 # private 9.2.4.100 rac1-priv rac1-en1 9.2.4.101 rac2-priv rac2-en1 # virtual 190.2.4.200 rac1-vip 190.2.4.201 rac2-vipCRS need a gateway assigned to a public network interface in order to reliably detect failure of NIC and node. It is important to use a IP of a live machine reachable from all nodes but it is not necessarily a gateway.
[root@rac1 ~]# rpm -q -a | grep rsh
rsh-0.17-25.4
rsh-server-0.17-25.4
[root@rac1 ~]# cat /etc/xinetd.d/rsh
# default: on
# description: The rshd server is the server for the rcmd(3) routine and, \
# consequently, for the rsh(1) program. The server provides \
# remote execution facilities with authentication based on \
# privileged port numbers from trusted hosts.
service shell
{
disable = no
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rshd
}
Configure RLOGIN
[root@rac1 ~]# cat /etc/xinetd.d/rlogin
# default: on
# description: rlogind is the server for the rlogin(1) program. The server \
# provides a remote login facility with authentication based on \
# privileged port numbers from trusted hosts.
service login
{
disable = no
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.rlogind
}
Start RSH and RLOGIN
[root@rac2 ~]# chkconfig rsh on [root@rac2 ~]# chkconfig rlogin on [root@rac2 ~]# service xinetd reloadCreate oracle account and enable RSH and RLOGIN for oracle on node rac1 and rac2
#Create the /etc/hosts.equiv file as the root user. [root@rac2 ~]# touch /etc/hosts.equiv [root@rac2 ~]# useradd oracle [root@rac1 ~]# useradd oracle [root@rac[1,2] ~]# cat /etc/hosts.equiv +rac1 oracle +rac2 oracle +rac1-priv oracle +rac2-priv oracle +rac1-vip oracle +rac2-vip oracle [root@rac[1,2] ~]# chmod 600 /etc/hosts.equiv [root@rac[1,2] ~]# chown root:root /etc/hosts.equivVerify RSH and RLOGIN
[oracle@rac2 ~]$ rsh rac1 “uname –a” [oracle@rac1 ~]$ rsh rac2 “uname –a” [oracle@rac1 ~]$ rlogin rac2 [oracle@rac2 ~]$ rlogin rac1Configure Network Time Protocol - NTP
[root@rac1 ~]# more /etc/ntp.conf server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 refid LCL [root@rac1 ~]# /etc/init.d/ntpd restart Shutting down ntpd: [ OK ] Starting ntpd: [ OK ] [root@rac1 ~]# chkconfig ntpd on [root@rac2 ~]# more /etc/ntp.conf server rac1 # remote clock [root@rac2 ~]# /etc/init.d/ntpd restart Shutting down ntpd: [ OK ] Starting ntpd: [ OK ] [root@rac2 ~]# chkconfig ntpd on [root@rac2 ~]# /usr/sbin/ntpdate -v -d rac1 # verify reference clock rac1Turn off firewall
[root@rac1 ~]# /etc/init.d/iptable stop [root@rac1 ~]# chkconfig iptable off [root@rac2 ~]# /etc/init.d/iptable stop [root@rac2 ~]# chkconfig iptable offInstall, configure cluster file system - OCFS2
[root@rac1 ~]# rpm -q -a | grep ocfs2 ocfs2-2.6.9-42.ELsmp-1.2.9-1.el4 ocfs2-tools-1.2.7-1.el4 ocfs2console-1.2.7-1.el4 [root@rac2 ~]# rpm -q -a | grep ocfs2 ocfs2-2.6.9-42.ELsmp-1.2.9-1.el4 ocfs2-tools-1.2.7-1.el4 ocfs2console-1.2.7-1.el4To create a configuration run ocfs2console and follow GUI menu
[root@rac2 ~]# /usr/sbin/ocfs2consoleDefine a configuration of two nodes rac1, rac2 using IP on private NIC en1 and specified port
[root@rac1 ~]#fdisk /dev/sdb ... #create single partition sdb1 ...Use ocfs2console=>task=>format /dev/sdb1
[root@rac[1,2] ~]#chkconfig --add o2cb [root@rac[1,2] ~]#chkconfig --add ocfs2 [root@rac[1,2] ~]#/etc/init.d/o2cb configure [root@rac[1,2] ~]#cat /etc/fstab: ... /dev/sdb1 /u02 ocfs2 rw,_netdev,datavolume,nointr,heartbeat=local 0 0 [root@rac[1,2] ~]#mkdir /u02 [root@rac[1,2] ~]#mount /u02Verify cluster file system by creating a directory on one node and check if it appears on other node.
[root@rac1~]#mkdir –p /u02/crsdata [root@rac1~]#mkdir –p /u02/oradata [root@rac2~]#ls –l /u02 crsdata oradataModify LINUX kernel setting to meet OCRS,and ORACLE requirements
[root@rac1]~]# vi /etc/sysctl.conf kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 # semaphores: semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.rmem_max=262144 net.core.wmem_default=262144 net.core.wmem_max=262144 [root@rac1~]# sysctl -p [root@rac1]~]# vi /etc/modprobe.conf options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180For the second node
[root@rac2~]# vi /etc/sysctl.conf kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 # semaphores: semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.rmem_max=262144 net.core.wmem_default=262144 net.core.wmem_max=262144 [root@rac2~]# sysctl -p [root@rac2]~]# vi /etc/modprobe.conf options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180Install Oracle Cluster Ready Service - CRS
[root@rac[1,2]~]#useradd oracle [root@rac[1,2]~]#groupadd oinstall [root@rac[1,2]~]#groupadd dba [root@rac[1,2]~]#usermod -g oinstall -G dba oracleCreate Oracle Cluster Registry - OCR and votedisk on cluster file system
[root@rac1~]#mkdir –p /u02/crsdata [root@rac1~]#touch /u02/crsdata/ocr.dbf [root@rac1~]#touch /u02/crsdata/votedisk.dbf [root@rac1~]#chown –R oracle /u02Copy installation software
[root@rac1~]#mkdir –p /u02/setup/clusterware10.2.0.1 [root@rac1~]#mkdir –p /u02/setup/oracle10.2.0.1 [root@rac1~]#mkdir –p /u02/setup/patch10.2.0.4Create home directory for crs and oracle
[root@rac1~]#mkdir –p /u01/crs [root@rac1~]#mkdir –p /u01/oracle [root@rac1~]#chown –R oracle /u01Run Oracle Universal Installer - OUI as oracle
[oracle@rac1~]$/u02/setup/clusterware/runInstaller