Archive

Posts Tagged ‘linux’

VIM cheatsheet

May 7th, 2011 rupert No comments
set nocompatible
set nu
set expandtab
 
"this will change tab to spaces
set ts=2 
set shiftwidth=2
set expandtab
 
set hlsearch
syntax on
 
"Use TAB to complete when typing words, else inserts TABs as usual.
"Uses dictionary and source files to find matching words to complete.
 
"See help completion for source,
"Note: usual completion is on <C-n> but more trouble to press all the time.
"Never type the same word twice and maybe learn a new spellings!
"Use the Linux dictionary when spelling is in doubt.
"Window users can copy the file to their machine.
function! Tab_Or_Complete()
  if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
    return "\<C-N>"
  else 
    return "\<Tab>"
  endif
endfunction
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
:set dictionary="/usr/dict/words"
 
set numberwidth=5
set cmdheight=2
"To map: imap ;f foobar => Type f; foobar will be inserted
 
"RSPEC Where ! is execute command. % is the current file
":!rspec %
 
"Map RSPEC test to ,t
":map ,t :w\|!rspec %<cr>
Categories: linux Tags:

Rails Note #13: RubyonRails + Oracle on Linux (i386 / x64)

December 11th, 2008 rupert No comments

In summary, install Oracle Instant Client and try to run sqlplus. If sqlplus connects to the oracle sid then go ahead and install the rails adapters for oracle. What is important to note here, is to install the oracle-instantclient for the architecture of your machine.. I have tested this on Debian Lenny (i386) and CentOS5 (x64)

1. Download from http://www.oracle.com/technology/software/tech/oci/instantclient/

a. oracle-instantclient-basic-10.2.0.4-1.i386
b. oracle-instantclient-devel-10.2.0.4-1.i386
c. oracle-instantclient-sqlplus-10.2.0.4-1.i386

2. Unzip everything to /opt/oracle/instantclient . You should have something like the ff:

[root@csapp1 instantclient]# ls -la
total 102704
drwxr-xr-x 3 root root     4096 Dec 10 21:54 .
drwxr-xr-x 3 root root     4096 Dec 10 22:03 ..
-rw-r--r-- 1 root root      228 Dec 10 21:52 BASIC_README
-r--r--r-- 1 root root  1609607 Dec 10 21:52 classes12.jar
-rwxr-xr-x 1 root root    67542 Dec 10 21:52 genezi
-r--r--r-- 1 root root     1525 Dec 10 21:52 glogin.sql
lrwxrwxrwx 1 root root       17 Dec 10 21:54 libclntsh.so -> libclntsh.so.10.1
-rwxr-xr-x 1 root root 21038613 Dec 10 21:52 libclntsh.so.10.1
-r-xr-xr-x 1 root root  3796601 Dec 10 21:52 libnnz10.so
-rwxr-xr-x 1 root root  1664116 Dec 10 21:52 libocci.so.10.1
-rwxr-xr-x 1 root root 72674185 Dec 10 21:52 libociei.so
-r-xr-xr-x 1 root root   138033 Dec 10 21:52 libocijdbc10.so
-r-xr-xr-x 1 root root  1435561 Dec 10 21:52 libsqlplusic.so
-r-xr-xr-x 1 root root   997409 Dec 10 21:52 libsqlplus.so
-r--r--r-- 1 root root  1555682 Dec 10 21:52 ojdbc14.jar
drwxr-xr-x 4 root root     4096 Dec 10 21:52 sdk
-r-xr-xr-x 1 root root     7773 Dec 10 21:52 sqlplus
-rw-r--r-- 1 root root      232 Dec 10 21:52 SQLPLUS_README
-rw-r--r-- 1 root root      516 Dec 10 21:53 tnsnames.ora
[root@csapp1 instantclient]#

3. Make a symbolic link for libclntsh.so.10.1 as shown above.

4. Create the Oracle Environment variables

export ORACLE_HOME=/opt/oracle/instantclient
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME

5. At this point, you should have oracle-instantclient properly installed. You can test by running sqlplus.

[root@csapp1 instantclient]# sqlplus
 
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Dec 11 11:47:40 2008
 
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

NOTE: Sometimes you will get a SEGMENTATION FAULT. If so, try to open a new shell with the environment variables loaded and do an sqlplus in a directory which is not /opt/oracle/instantclient.

6. Install the oracle adapter for rails

7. gem install ruby-oci8

8. gem install oracle_enhanced-adapter –source=”http://gems.rubyonrails.org/”

activerecord-oracle-adapter (1.0.0.9250)
activerecord-oracle_enhanced-adapter (1.1.8)

NOTE: Try to look for the latest gems, the source above is at the time of this writing so it might change.

9. Test using irb

[root@csapp1 instantclient]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'oci8'
=> true
irb(main):003:0>
Categories: debian, linux, oracle, rails, ruby Tags: , , ,

Installing Oracle11g x64 on CentOS5

July 26th, 2008 rupert No comments

FOR EDITING.. This is just a couple of notes from my Oracle testing a few weeks back that I forgot to post..

A. Installing

1. Check for rpm packages:

rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21 elfutils-libelf libaio-devel libgcc

NOTE: For 10g, you need libXp.so.6 installed. It seems the oracle installer is messed up with some i386 modules pointing to x86? Anyway, I was able to resolve the problem by installing the libXp.i386.rpm version.

2. install the necessary rpm packages:

rpm -ivh compat-db-4.2.52-5.1.x86_64.rpm 
rpm -ivh libgnome-2.16.0-6.el5.x86_64.rpm 
rpm -ivh sysstat-7.0.0-3.el5.x86_64.rpm 
rpm -ivh libaio-devel-0.3.106-3.2.x86_64.rpm 
rpm -ivh lm_sensors-2.10.0-3.1.x86_64.rpm
rpm -ivh beecrypt-devel-4.1.2-10.1.1.x86_64.rpm elfutils-devel-0.125-3.el5.x86_64.rpm net-snmp-devel-5.3.1-19.el5.x86_64.rpm elfutils-devel-static-0.125-3.el5.x86_64.rpm net-snmp-5.3.1-19.el5.x86_64.rpm net-snmp-libs-5.3.1-19.el5.x86_64.rpm

3. vim /etc/profile

ORACLE_BASE=/opt/oracle/product
ORACLE_SID=csdbora
ORACLE_HOME=/opt/oracle/product/11.1.0/db_1
 
export ORACLE_BASE ORACLE_SID ORACLE_HOME
 
PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

4. Create oracle Account

groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle
id oracle

uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)

5. Run modify_kernel.sh

cat >> /etc/sysctl.conf << EOF
kernel.shmall = 2097152
kernel.shmmax = 1073741824 
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1025 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
EOF

6. vim /etc/sysctl.conf and comment kernel.shmall and kernel.shmmax because if
you don’t then we will have double results

7. /sbin/sysctl -p

8. Create Directories:

mkdir -p /u01
mkdir -p /opt/oracle
mkdir -p /opt/oracle/product
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /opt/oracle
chmod -R 755 /u01
chmod -R 755 /opt/oracle
chmod -R 755 /opt/oracle/product

9. Run sh -v modify_shelllimits.sh

10. Add the ff lines in /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so

11. cp -rf /home/installers/linux.x64_11gR1_database.zip /opt/oracle

12. chown oracle:oinstall /opt/oracle/linux.x64_11gR1_database.zip

13. Clost all terminals and logout as root from desktop.

14. Login as oracle

15. Follow tutorial until installing oracle
Installing Oracle 11g on CentOS under VMWare on a Macbook.doc

To extract: cpio -idmv < 10201_database_linux_x86_64.cpio

vim /etc/redhat-release
Redhat 4

16. Run the 2 scripts after the dialog:

[root@cs5ora11g db1]# sh root.sh
Running Oracle 11g root.sh script…

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/11.1.0/db1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin …
Copying oraenv to /usr/local/bin …
Copying coraenv to /usr/local/bin …

Creating /etc/oratab file…
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

17. Open your firewall to 1158

18. Go to https://192.168.1.155:1158/em

- Login as SYSMAN:[password] (nickname+wife)

19. Install Oracle Instant Client for your distro [MacOS]

http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

a. Add exports to runsqlplus.sh
b. copy tnsnames.ora from centos to mac
c. add in firewall: 1521
d. sh runsqlplus.sh

20. do sqlplus
Enter user-name: SYSMAN@cybersof
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>

You are now connected successfully.

21. Check for oracle processes: ps -ef | grep ora

SQLPLUS DBINSTANCE:
oraclecybersof (LOCAL=NO)
 
 
ORACLE LISTENER:
/opt/oracle/product/11.1.0/db1/bin/tnslsnr LISTENER -inherit
 
ORACLE ENTERPRISE MANAGER:
oracle   14487     1  0 15:37 ?        00:00:00
/opt/oracle/product/11.1.0/db1/perl/bin/perl
/opt/oracle/product/11.1.0/db1/bin/emwd.pl dbconsole
/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc/sysman/log/emdb.nohup
oracle   14511 14487  2 15:37 ?        00:00:36
/opt/oracle/product/11.1.0/db1/jdk/bin/java -server -Xmx512M
-XX:MaxPermSize=1024M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40
-DORACLE_HOME=/opt/oracle/product/11.1.0/db1
-Doracle.home=/opt/oracle/product/11.1.0/db1/oc4j
-Doracle.oc4j.localhome=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc/sysman
-DEMSTATE=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc
-Doracle.j2ee.dont.use.memory.archive=true
-Djava.protocol.handler.pkgs=HTTPClient
-Doracle.security.jazn.config=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/jazn.xml
-Djava.security.policy=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/java2.policy
-Djavax.net.ssl.KeyStore=/opt/oracle/product/11.1.0/db1/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/opt/oracle/product/11.1.0/db1/oc4j/j2ee/home/config/jazn.security.props
-DEMDROOT=/opt/oracle/product/11.1.0/db1/cs5ora11g_csmlcc
-Dsysman.md5password=true -Drepapi.oracle.home=/opt/oracle/product/11.1.0/db1
-Ddisable.checkForUpdate=true
-Doracle.sysman.ccr.ocmSDK.websvc.keystore=/opt/oracle/product/11.1.0/db1/jlib/emocmclnt.ks
-Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar
/opt/oracle/product/11.1.0/db1/oc4j/j2ee/home/oc4j.jar -config
/opt/oracle/product/11.1.0/db1/oc4j/j2ee/OC4J_DBConsole_cs5ora11g_csmlcc/config/server.xml

22. Set Oracle Environment

# su - oracle
# vim ~/.bash_profile
ORACLE_BASE=/opt/oracle/product
ORACLE_SID=cybersof
ORACLE_HOME=/opt/oracle/product/11.1.0/db1
export ORACLE_BASE ORACLE_SID ORACLE_HOME
 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

23. Shutdown and Startup of Oracle

$ . oraenv
<enter your SID>
 
$ sqlplus "/ as sysdba"
SQL> startup
SQL> exit
 
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
 
$ cd $ORACLE_HOME/bin
./emctl start dbconsole

B. Creating Users

Login to https://192.168.1.155:1158/em
username:sysman
password: [nickname+wifey]
connect as “sysdba”

1. Creating admin user:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28301/admqs_administer_users.htm#CHDBDBGI

em > Setup > Administrators > Create

2. Create appdev user:
em > Server > Roles

http://download.oracle.com/docs/cd/B28359_01/server.111/b28301/admqs_administer_users.htm

CREATE USER "APPDEV" PROFILE "DEFAULT" IDENTIFIED BY "*******" DEFAULT TABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK
GRANT UNLIMITED TABLESPACE TO "APPDEV";
GRANT "CONNECT" TO "APPDEV";
GRANT "RESOURCE" TO "APPDEV";

Picture 1.png

Part II. Installing Oracle10g on CentOS5

1. Choose Advanced Installation”

Picture 1.png

2. If its just network prerequisite.. ignore it. It’s not a big deal.

Picture 2.png

3. ORACLE_HOME: /opt/oracle/product/10.2.0/db_1

Picture 3.png

4. ORACLE_SID: orcl, CHARSET: utf8

Picture 4.png

5. EM Installed…

Picture 6.png

6. ISQLPLUS

Picture 7.png

7. Run root.sh

Picture 9.png

output…

Picture 8.png

8. Other settings

Picture 10.png

9. Oracle Environment Variables

Picture 12.png

Categories: oracle Tags: , ,

Installing Mapserver on Debian (reprise)

March 28th, 2008 rupert No comments

As noted from my previous blog post regarding Mapserver on Debian, you don’t get AGG with Mapserver when installing directly from Debian packages. Thus, it would be better to install Mapserver by source. However, debian still helps because it would install all the necessary libraries needed for compiling mapserver. Read more…

Categories: debian, linux, mapserver Tags: , ,

Installing Firefox on Linux (Debian)

March 5th, 2008 rupert No comments

I read somewhere that Firefox was renamed to Iceweasel on Debian. Thus, I can’t install the Google Toolbar for it. So here are the steps for installing Firefox manually in a linux system. Read more…

Categories: debian, linux Tags: , ,