Differences between revisions 35 and 36
Revision 35 as of 2017-03-23 16:36:57
Size: 13296
Editor: ?GiuseppeSacco
Comment: Added a note about memlock in limits.conf and hugepages in sysctl.conf
Revision 36 as of 2017-03-23 16:52:12
Size: 13294
Editor: ?GiuseppeSacco
Comment: lowered the hugepages values in order to keep a simpler example
Deletions are marked like this. Additions are marked like this.
Line 84: Line 84:
oracle soft memlock 1677721
oracle hard memlock 1677721
oracle soft memlock 204800
oracle hard memlock 204800
Line 90: Line 90:
 . the last two lines -- about memlock -- are required only if you use hugepages. The number here is 1.6Gb since it has to be writter in kilobytes.  . the last two lines -- about memlock -- are required only if you use hugepages. The number here is 400mb since it has to be written in kilobytes.

Translation(s): English - ?Português

Work in progress

Oracle

# Oracle XE Debian repository
deb http://oss.oracle.com/debian unstable main non-free
  • Please, keep in mind that I'm no Oracle specialist, this is a minimalist guideline to try help people during this process (hopefully with less pain). I documented the steps and made different comments and references with regards to what I found on the Internet. There are probably different (and better) ways to install and deploy Oracle and I'll be more than happy to add such info (or to see somebody else do it). The main goal is to make a tutorial more Debian way. I really hope this helps. :-)

Preparations

  • One of the hard things if you're a first time adventurer in Oracle (or if there's a long time since of you last mess with it), is to know how the system works in terms of partitions and file system space.
  • Both 10g and 11g needs a few special things:
    • At least 1.5GiB of space for the zip files containing the database, installer and documentation, I put those in  /srv/oracle 

    • At least 1.5GiB of space for the installed binaries and resources, that should appear under /opt

    • Some free space for the databases, they usually go under /u01, /u02 and sequentially. Oracle documentation says you can choose whatever letter you want and a fixed width number, it could be /z0001.

    • Regarding swap space, for some bizarre reason Oracle 10g asked for 12GiB and Oracle 11g asked for 15GiB. I did one installation with less, but our team decided to reinstall it with the requested amount.
  • Although there is a graphical installer you don't need to install X Window System on the server. You can use X11Forwarding or use the Oracle Silent Install. First, I'm documenting graphical install via SSH (using X11 forwarding).

Creating users and groups

  • Personally, I decided to create system users and groups because they take care of a service (Oracle database and family of applications). You'll find several articles creating regular groups and users, this should be equivalent just with a different point of view in terms of organization and philosophy. :-)

# addgroup --system oinstall
# addgroup --system dba
# adduser --system --ingroup oinstall --shell /bin/bash oracle
# adduser oracle dba

Oracle requirements (sysctl and security limits)

sysctl

  • Usually you'll find articles recommending you edit  /etc/sysctl.conf , I would recommend you to create a file  /etc/sysctl.d/local-oracle.conf  with the following contents:

fs.file-max = 65536
fs.aio-max-nr = 1048576
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
# (Oracle recommends total machine Ram -1 byte)
kernel.shmmax = 2147483648
kernel.shmall = 2097152
kernel.shmmni = 4096
net.ipv4.ip_local_port_range = 1024 65000
vm.hugetlb_shm_group = 111
vm.nr_hugepages = 64
  • I didn't find recommendations of vm in the Oracle docs, but several articles spoke about it and the installer failed without it. The value for vm.hugetlb_shm_group should be the gid number of the dba group. The value required for vm.nr_hugepages might be higher, depending on how large is your SGA and if that SGA use hugepages. Every hugepage is 2kb large.

  • To load the sysctl configuration you can run sysctl or reboot the machine

# sysctl -p /etc/sysctl.d/local-oracle.conf

security limits

  • Edit  /etc/security/limits.conf , my recommendation is to create a file  /etc/security/limits.d/local-oracle.conf  with the following contents:

oracle          soft    nproc           2047
oracle          hard    nproc           16384
oracle          soft    nofile          1024
oracle          hard    nofile          65536
oracle          soft    memlock         204800
oracle          hard    memlock         204800
  • Those are not magical numbers, I took them from the Oracle® Database Quick Installation Guide.

  • the last two lines -- about memlock -- are required only if you use hugepages. The number here is 400mb since it has to be written in kilobytes.
  • Usually, on a regular Debian 6 installation, you just have to enable  pam_limits.so  in /etc/pam.d/su, but make sure it is active for  /etc/pam.d/{login,sshd,su} 

Nasty hacks

  • Yes, it's required, believe me, I tried to install without it. :-)

# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/basename /bin/basename
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
  • awk is used by the final scripts to parse username/groups and change permissions, it works without it, but better be safe than sorry. Do not remove this symbolic link after installation as several commonly used utilities require it.

  • basename and rpm are used during installation.

  • lib64 is needed by binaries from Oracle RPM packages in multiarch systems.

Directory Structure

Create a directory structure required to install Oracle DataBase.

# mkdir -p /opt/oracle/product/12.1.0.2
# mkdir -p /opt/oraInventory
# chown -R oracle:dba /opt/oracle/
# chown -R oracle:dba /opt/oraInventory

Oracle on Debian (amd64)

Initial steps

We need to install some packages

  • Oracle 10g on Debian Squeeze:

    aptitude install build-essential gcc-multilib ia32-libs libaio1 libstdc++5 rpm xauth unzip
  • Oracle 12c on Debian Sid:

    apt-get install build-essential binutils libcap-dev gcc g++ libc6-dev ksh libaio-dev make libxi-dev libxtst-dev libxau-dev libxcb1-dev sysstat rpm xauth unzip
  • build-essential gcc-multilib ia32-libs libaio1 libstdc++5 rpm are dependencies of Oracle either direct or indirect because of 32-bit and 64-bit mess. And yes, I tried to install without any extra packages and only installed what was necessary to fix a given problem.

  • xauth will make the X11 forwarding magic happen.

Unzip the Oracle files

Unzip the Oracle files in the user's $HOME directory.

oracle@oracle:~$ unzip linuxamd64_12XXX_database_1of2.zip 
oracle@oracle:~$ unzip linuxamd64_12XXX_database_2of2.zip

Environment variables

For example:

oracle@oracle:~# export ORACLE_HOSTNAME=localhost
oracle@oracle:~# export ORACLE_OWNER=oracle
oracle@oracle:~# export ORACLE_BASE=/opt/oracle
oracle@oracle:~# export ORACLE_HOME=/opt/oracle/product/12.1.0.2/dbhome_1
oracle@oracle:~# export ORACLE_UNQNAME=orcl
oracle@oracle:~# export ORACLE_SID=orcl
oracle@oracle:~# export PATH=$PATH:$ORACLE_HOME/bin
oracle@oracle:~# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/bin/lib:/lib/x86_64-linux-gnu/:/usr/lib64
  • ORACLE_OWNER: User with permission on Oracle files.
  • ORACLE_BASE: Directory that will store the distinct Oracle Services.
  • ORACLE_HOME: Directory that will store the Oracle database.
  • ORACLE_UNQNAME: Unique name of database.
  • ORACLE_SID: Service Identifier of Listener.
  • PATH: Path to binary files.
  • LD_LIBRARY_PATH: Path to library.

Installation

  • You must run the installer as the oracle user.
  • If you'll use the installer via SSH with X11 forwarding, you either have to login directly as  oracle  user or using xauth to transport the authentication from the user that logins in thru SSH and the  oracle  user.

    • You may have noticed that a system user (as the one I created in this article) doesn't have a password. To login directly as oracle you could use SSH keys to login or simply  passwd oracle . Don't forget to enable X11Forwarding in configuration files or use:

$ ssh -XC $SOMEUSER@orclserver.example.org
  • If you decided to create a different non-privileged user to login via SSH (or if you are using root) you should use:

$ ssh -XC $SOMEUSER@orclserver.example.org

$ xauth list
orclserver/unix:10  MIT-MAGIC-COOKIE-1  abcdef0123456789abcdef0123456789

$ su - oracle
$ xauth add orclserver/unix:10  MIT-MAGIC-COOKIE-1  abcdef0123456789abcdef0123456789
  • Once you are the  oracle  user with the proper xauth permissions, just run the installer. As you are installing on Debian and it is not certified by Oracle, you need to tell the installer to ignore some checks or pre-requisites using -IgnoreSysPreReqs. If you want to see all the options you can use -help.

$ /path/to/oracle/database/runInstaller -IgnoreSysPreReqs
  • From this point on, it's up to you and your DBA. Just for the record, here are the values we used:
    • Inventory directory: /opt/oracle/oraInventory
    • OS group name: oinstall
    • Standard Edition
    • Installation Name: OraDb10g_home1

    • Path: /opt/oracle/product/10.2.0/db_1
  • You'll hit a problem about the  collect . I couldn't fix it, but I found some places mentioned it is just for certified systems and won't affect the install, just hit the  Continue  button and finish the installation.

  • The rest is pretty straightforward as Oracle will tell you what to do (including running a pair of shell scripts to fix permissions and copy some binaries into /usr/local/bin

Common problems

gcc-multilib: linking pthread problems

  • Problem

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/.../libpthread.a when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching for -lpthread
/usr/bin/ld: cannot find -lpthread

INFO: collect2: ld returned 1 exit status

INFO: make: *** [ctxhx] Error 1

INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'install' of makefile '/opt/oracle/product/10.2.0/db_1/ctx/lib/ins_ctx.mk'.
  • Solution: install gcc-multilib and its dependencies.

First steps

Start Oracle

oracle@debian-sid:~$ . /usr/local/bin/oraenv
oracle@debian-sid:~$ dbstart $ORACLE_HOME

Start Oracle on Systemd

Create daemon  "/etc/systemd/system/oracle.service" , that will set up database services.

[Unit]
Description=Oracle 12c DataBase
Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs.target remote-fs.target
After=syslog.target network.target

[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
LimitNPROC=16384
LimitSTACK=10485760
Type=forking
Environment="ORACLE_HOME=/opt/oracle/product/12.1.0.2/dbhome_1"
ExecStart=/bin/su oracle -c '/opt/oracle/product/12.1.0.2/dbhome_1/bin/dbstart $ORACLE_HOME'

[Install]
WantedBy=multi-user.target

Updates changes made to service files of system, enables Oracle service and starts it up. Note that limits are compulsory since systemd ignore limits.conf defined earlier, moreover note that limitSTACK use a different measure unit compared to ulimit, so it should be converted from the value in limits.conf.

root@oracle:~# systemctl daemon-reload
root@oracle:~# systemctl enable oracle
root@oracle:~# systemctl start oracle

Add Users

Let say you need a couple of users scott and foo with passwords tiger and bar in order to run the DBD::Oracle Perl module tests. You can add those users running the following steps:

oracle@debian-sid:~$ sqlplus SYS AS SYSDBA
SQL> CREATE USER c##scott IDENTIFIED BY tiger;
User created.
SQL> GRANT ALL PRIVILEGES TO c##scott;
Grant succeeded.
SQL> CREATE USER c##foo IDENTIFIED BY bar;
User created.
SQL> GRANT ALL PRIVILEGES TO c##foo;
Grant succeeded.

References

There is a great reference document that helped clearing up some doubts with regards to what should I add or not in terms of configuration, it is an official Oracle documentation called Oracle® Database Quick Installation Guide, it briefly documents the aspects of installation in Linux x86-64 (amd64):


CategoryProprietarySoftware