Cài đặt Oracle trên Linux
Bước 1: Tạo group và user
./create_user.sh
Bước 2: Copy bộ cài vào
/app/oracle/setup
Sau khi copy về thường là file nén. giải nén
unzip linux_11gR2_database_1of2.zip
unzip linux_11gR2_database_2of2.zip
Bước 3: Cấu hình tham số kernel
./ preconfig_parameter.sh
Bước 4: Cài đặt
Vào /app/oracle/setup/database chạy
./runInstall
Bước 5: Thiết lập biến môi trường
Su -
vi .bash_profile
ORACLE_BASE=/export/home/oracle
Export ORACLE_BASE
ORACLE_HOME=/export/home/oracle/product/10.2.0/db_1
Export ORACLE_HOME
ORACLE_SID=ORCL
export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin
export PATH
Bước 6: Thực hiện các lệnh
- Kiểm tra lisener đã lên chưa
lsnrctl status
lsnrctl start
1. Cài VMWare, máy ảo:
Cài VM với máy ảo mình ko hướng dẩn, hy vọng bạn làm được. Tôi sài VMWare 6. chắc VMWare 5 củng được thôi. ShareFolder giửa máy ảo và máy host: Tôi download tất cả mọi thứ bằng windows rồi share cho linux. Trong VMWare 6 có cái gọi là ShareFolder, có thể share mọi thứ giửa window với XP. Cái nầy hình như mới! Trong VMWare 5 ko có? Nếu bạn sài Version 5 chắc phải sài SAMBA để share Windows với Linux.
Chỉ nói sơ qua là khi cài linux bạn chú ý:
-RAM >=512 MB
-Ổ cứng: 10 GB
-Linux Swap: 1GB
-Phần Network Configuration: ko chọn default DHCP mà phải cho là static IP. Cho số IP cùng range với máy host.
-Chọn No firewall
-Package Group Selection: chọn
.Development Tools.
.Legacy Software Development
.System Tools: sysstat - The sar and iostat system monitoring commands
Clone: Sau khi cài xong Linux, bạn login vào kiểm tra xem có ok ko.Trước khi tiến hành cài oracle, bạn đừng nên cài oracle trực tiếp trên cái máy ảo Linux vứa mới tạo, mà nên tạo 1 cái máy thứ 2 là clone của máy thứ nhất. Clone có 2 kiểu clone: full clone và linked clone. full clone và 1 bản full copy của máy mà mình muốn clone. Cái nầy tốn ổ cứng lắm, nên chọn linked clone. Bây giờ cài oracle lên cái linked clone. Có cài bị hư thì xóa cái linked clone thôi, không phải cài linux lại từ đầu.
Create Groups and User Account
Cài Oracle cần như sau:
2 Groups: đặc tên là oinstall và dba
1 User accounttên là: oracle
note: Đúng ra đặt là Tí Tèo gì củng được, nhưng conventional, thấy thiên hạ cài Oracle hay đặt là vậy.
Login as root, run:
Code: Select all
# groupadd oinstall
# groupadd dba
# useradd -m -g oinstall -G dba oracle
Tạo password cho user: oracle
Run:
Code: Select all
# passwd oracle
Changing password for user oracle.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
note: UNIX password đòi phải có số, chử, dấu đặc biệt!
Một UNIX pasword thí dụ như là: P@ssw0rd
Kiểm tra lại, run:
Code: Select all
# id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
->user oracle nằm trong primary group oinstall và group dba
Create directories, group, user oracle
1. Tạo 1 thư mục /u01/app
2. Trao quyền owner cho user oracle
3. Trao quyền read, write mọi thứ trong /u01/app cho tất cả!
Run commands:
Code: Select all
# mkdir -p /u01/app
# chown -R oracle:oinstall /u01/app
# chmod -R 775 /u01/app
note: Tại sap phải đặc tên mấy cái đường dẩn lằn nhằn như thế?
Đúng ra thì củng chẳng bắt buột. Nhưng mà Oracle recomment thế đấy.
Có cả Document về oracle name convention
Set Enviroment for user oracle
Mở file /home/oracle/.bash_profile thêm vào:
Code: Select all
#environment for oracle
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
ORACLE_SID=EDU11
PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH CLASSPATH
note: Khi cài oracle là log vào bằng user oracle.
Kiểm tra, upgrade RPMs:
Bước nầy hơi rất rối tí. Oracle1 đòi hỏi các RPM phải có tối thiểu các Version sau:
make-3.81
binutils-2.17.50.0.6
gcc-4.1.1
libaio-0.3.106
libaio-devel-0.3.106
libstdc++-4.1.1
elfutils-libelf-devel-0.125
sysstat-7.0.0
compat-libstdc++-33-3.2.3
libgcc-4.1.1
libstdc++-devel-4.1.1
unixODBC-2.2.11
unixODBC-devel-2.2.11
Run command sau để xem mình đang có RPM Version nào?
Code: Select all
# rpm -q make binutils gcc libaio libaio-devel libstdc++ elfutils-libelf-devel sysstat compat-libstdc++ libgcc libstdc++-devel unixODBC-2.2.11 unixODBC-devel
(..gỏ trong 1 line)
Kết quả:
make-3.81-1.1
binutils-2.17.50.0.6-2.el5
gcc-4.1.1-52.el5
libaio-0.3.106-3.2
package libaio-devel is not installed
libstdc++-4.1.1-52.el5
elfutils-libelf-devel-0.125-3.el5
sysstat-7.0.0-3.el5
package compat-libstdc++ is not installed
libgcc-4.1.1-52.el5
libstdc++-devel-4.1.1-52.el5
package unixODBC is not installed
package unixODBC-devel is not installed
So sánh các RPMs.
Nêu thiếu cái nào thì phải cài mới vào. Version củ thì phải upgrade lên!
Các RPM có thể tìm thấy trong CD cài Linux, hay search trên google
Tôi copy các RPMs vào cái thư mục shares của VMWare, chạy các command sau:
Code: Select all
# rpm -ivh libaio-devel-0.3.106-3.2.i386.rpm
# rpm -ivh unixODBC-2.2.11-7.1.i386.rpm
# rpm -ivh unixODBC-devel-2.2.11-7.1.i386.rpm
# rpm -ivh compat-libstdc++-33-3.2.3-61.i386.rpm
note:
to install/cài mới: rpm -ivh package-file-name.rpm
to update/nâng cấp: rpm -Uvh package-file-name
xem info package có trong máy: rpm -qi package-name
xem info package file: rpm -qpi package-file-name
Config Linux Kernel Parameters
Dùng vi hay gedit(cái nầy giống notepad!) thêm các lines sau vào file /etc/sysctl.conf
Code: Select all
#This lines is for Oracle Installation
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 262144
Check lại:
Run:
Code: Select all
# sysctl -p
Setting Shell Limits for user oracle
todo:
1. Thêm vào file /etc/security/limits.conf các dòng sau:
(trên cái line # End of file)
Code: Select all
oracle soft nofile 63566
oracle hard nofile 63536
oracle soft nproc 16384
oracle hard nproc 16384
note: soft limit = hard limit setting
2. Verify file /etc/pam.d/system-auth, check xem có 2 lines sau:
Code: Select all
session required /lib/security/pam_limits.so
session required pam_limits.so
3. Disable SELinux
edit file /etc/selinux/config file, change line
Code: Select all
SELINUX=disabled
note: SELinux. Secure linux? Cái nầy là gì? Biết chết liền!
Nhưng nếu ko làm là bị lổi khi start sqlplus sau khi cài oracle!
Tôi mất 1 ngày để google cái lổi nầy! Pó tay!
Cuối cùng, phải post hỏi trên oracle forum
Unzip Source Oracle
Version 11gR2 khi download xuống chỉ có 1 file duy nhất là:
linux_11gR1_database.zip sized 1.801.302KB.
Mình có đặt nó trong 1 folder tên là shares share qua VMWare 6.
Xem Menu VM->Setting..>Tab Options->Shared Folders. Trong linux folder nầy nằm trong /mnt/hgfs
note: Down 1.8GB Oracle củng ngán hả? So sách mình lúc trước download hàng trăm GB của ephim.com mà sao không thấy ngán gì hết!
Run:
Code: Select all
# cd /mnt/hgfs/shares
# unzip linux_11gR1_database.zip
Khi unzip xong bạn sẻ có 1 folder mới /mnt/hgfs/shares/database.
Trong đó là toàn bộ source để cài oracle. Script chạy install là: runInstaller
note: trước khi chạy runInstaller, chắc ăn, nên reboot lại!
Cài Oracle11
Login vào Linux với user oracle.
Kiểm tra(echo) lại xem coi các Environment Vars có set, export ko?
Run:
Code: Select all
# cd /mnt/hgfs/shares/database
# ./runInstaller
Step 1: Select Installation Method:
-Chọn Basic Installation
-Global Database Name: EDU11
-Database Password
-Nhưng cái còn lại để default mặc định
-Click Next
note: Enterprise cần 3.3GB + DB 1.48GB = 4.8GB
Chọn Basic Install cho dể. Ai rành thì chọn Advanced.
Tôi chọn Basic Install. Khỏe!
Step 2: Specify Inventory directory and crendentials
-Click next
Step 3: Product-Specific Prereqisite Checks
-Step nầy, ai chuẩn bị ko tốt sẻ bị báo lổi, warning!
-Ai bị thì copy text trong cái textbox ra xem, cancel install,
tìm chổ nào có chử "failed"! fix lổi, rồi runInstaller lại.
-Tôi bị 1 lổi là RAM chỉ có 512MB, nên click Next được!
Step 4: Warning: Product-Specific Prereqisite Checks
-Click yes
Step 5: Oracle Configuration Manager Registration
-Nghèo như tôi thì làm gì có Customer Identification Number
CSI, click next!
Step 6: Summary
-click install
Step 7: Install run
Oracle beginn the install..wait...
Step 8: Database Configuration Assistant
-click ok
Step 9: Execute Configuration scripts
Step nầy phải chạy 2 cái scrips bằng user root.
-Chuột phải mở new Terminal
-Gỏ:
Code: Select all
$ su - root
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/oracle/product/11.1.0/db_1/root.sh
Khi bị hỏi: Enter the full pathname of the local direcory, thì nhấn Enter...
# exit <- quay về oracle
#exit <- close terminal
-tiếp tục với Oracle Install dialog box: click OK
Step 10: End of Installation
click exit and Yes!
xong, finish!
-- chia se mot bai cop nhat