Linux下安装Oracle 11
此为参照CU论坛上的高人写的文章并结合自身环境增加了点细节性的东西
操作系统 CentOS 4.2 2.6.11.8内核 安装准备下载Oracle11安装包
内存最少1G 硬盘空间最6G 交换分区最少1024M,如果不够就用dd命令扩容一个如:dd if=/dev/zero of=/.swap bs=1k count=1024000 创建文件
chmod 600 /.swap 设置权限 mkswap /.swap 设定文件 swapon /.swap 生效文件安装如下软件
binutils-2.17.50.0.6-2.el5
compat-libstdc++-33-3.2.3-61 elfutils-libelf-0.125-3.el5 elfutils-libelf-devel-0.125 glibc-2.5-12 glibc-common-2.5-12 glibc-devel-2.5-12 gcc-4.1.1-52 gcc-c++-4.1.1-52 libaio-0.3.106 libaio-devel-0.3.106 libgcc-4.1.1-52 libstdc++-4.1.1 libstdc++-devel-4.1.1-52.e15 make-3.81-1.1 sysstat-7.0.0 unixODBC-2.2.11 unixODBC-devel-2.2.11做个链接(老版本要,Oracle11不要)
ln -s /usr/lib/libstdc++.so.6.0.3 /usr/lib/libstdc++.so.5在sysctl.conf文件中加入下列:
kernel.shmall = 2097152
kernel.shmmax = 2147483648 -- (以字节为单位,物理内存数量*1024*1024*2, 为内存的2倍) 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=8388608 net.core.rmem_max=8388608 net.core.wmem_default=262144 net.core.wmem_max=262144 保存退出 sysctl -p使其生效设置Shell Limits(系统资源限制),提高软件的运行效率
在/etc/security/limits.conf文件中加入下列红色行:
oracle soft nofile 65536
oracle hard nofile 65536 oracle soft nproc 16384 oracle hard nproc 16384在/etc/pam.d/login文件中加入下列行,如果里面没有的话:
session required /lib/security/pam_limits.so
session required pam_limits.so在/etc/profile后加入以下语句:
vi /etc/profile
if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi 创建dba/oper/oinstall组 /usr/sbin/groupadd dba /usr/sbin/groupadd oper /usr/sbin/groupadd oinstall--创建oracle用户并设置用户所属组
/usr/sbin/usermod -g oinstall -G dba oracle /usr/sbin/useradd -g oinstall -G dba oracle passwd oracle # id oracle uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba) --创建相关安装目录 mkdir -p /opt/oracle/product mkdir -p /opt/oracle/product/OraHome mkdir -p /opt/oraInventory #(the default inventory folder) mkdir -p /opt/oracle/oradata #(change the right file owner) mkdir -p /var/opt/oracle --设置目录所有者和权限chown -R oracle.oinstall /opt/oracle
chown -R oracle.oinstall /opt/oracle/oradata chown -R oracle.oinstall /opt/oracle/product/OraHome chown -R oracle.dba /opt/oraInventory chown oracle.dba /var/opt/oracle chmod -R 775 /opt/oracle chmod -R 755 /var/opt/oracle 设置安装环境变量 # su - oracle --su到oracle用户下, 更改用户的一些配置 $vi /home/oracle/.bash_profile 添加以下参数,主要是配置oracle软件运环境参数 # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fiexport ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/OraHome export ORACLE_SID=orcl export ORACLE_OWNER=oracle export ORACLE_TERM=vt100 export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib export CLASSPATH PATH=$PATH:/usr/sbin; export PATH PATH=$PATH:/usr/bin; export PATH 注意:11g:ORA_NLS33=$ORACLE_HOME/nls/admin/data
10g:ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data 9i:ORA_NLS33=/oracle/app/ora92/ocommon/nls/admin/data保存退出
--执行以下命令让配置马上生效或以oracle用户登录使设置生效 $ source $HOME/.bash_profile安装Oracle
首先要进入X界面
然后unzip解压压缩包 再进入目录下执行 ./runInstaller_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
( 配置这一步 出错了... )
安装过程和Windows下安装软件一样根据提示下一步下一步安装 在前几步会提示要检测你的系统硬件和软件是否达标,如果有不合规格的会提示报错要求改正 根据提示信息,将所有设置都设置好,所缺软件都装好,就可以了 [oracle@localhost database]$ ./runInstaller Starting Oracle Universal Installer...Checking Temp space: must be greater than 80 MB. Actual 141856 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1023 MB Passed Checking monitor: must be configured to display at least 256 colors >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<Some requirement checks failed. You must fulfill these requirements before
continuing with the installation,at which time they will be rechecked.
Continue? (y/n) [n] y
Rechecking installer requirements.... Preparing to launch Oracle Universal Installer from /tmp/OraInstall2009-02-15_06-12-44AM. Please wait ... DISPLAY not set. Please set the DISPLAY and try again. Depending on the Unix Shell, you can use one of the following commands as examples to set the DISPLAY environment variable: - For csh: % setenv DISPLAY 192.168.1.128:0.0 - For sh, ksh and bash: $ DISPLAY=192.168.1.128:0.0; export DISPLAY Use the following command to see what shell is being used: echo $SHELL Use the following command to view the current DISPLAY environment variable setting: echo $DISPLAY - Make sure that client users are authorized to connect to the X Server. To enable client users to access the X Server, open an xterm, dtterm or xconsole as the user that started the session and type the following command: % xhost + To test that the DISPLAY environment variable is set correctly, run a X11 based program that comes with the native operating system such as 'xclock': % <full path to xclock.. see below> If you are not able to run xclock successfully, please refer to your PC-X Server or OS vendor for further assistance. Typical path for xclock: /usr/X11R6/bin/xclock [oracle@localhost database]$_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
不过有时候装好了它也会定在那个地方不走了 在确定好所有的设置正确和软件都装好了 可以用./runInstaller -ignoreSysPrereqs跳过检测 注意,安装过程中,尽量不要去更改SID,把默认的SID和一些其它信息记录下来,可以省去后面的很多麻烦安装完毕后,以root身份进入系统 运行
ORACLE_HOME下面的root.sh 完成最后的安装 Oracle的启动设置确定/etc/oratab文件设置每个实例的重启标志为“Y”:
vim /etc/oratab orcl:/opt/oracle/product/OraHome:Y打开ORACLE_HOME/network/admin/sqlnet.ora添加:
SQLNET.AUTHENTICATION_SERVICE=(NTS)关闭selinux
启动EM控制台
su -oracle
ORACLE_HOME/bin/emctl start dbconsole (就可以访问https://localhost:1158/em的企业控制台) ORACLE_HOME/bin/lsnrctl start ORACLE_HOME/bin/dbstartOracle 常用操作命令
1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。 2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i; 3、SQL>connect / as sysdba ;(as sysoper)或connect internal/oracle AS SYSDBA ;(scott/tiger) conn sys/change_on_install as sysdba; 4、SQL>startup; 启动数据库实例 5、 查看当前的所有数据库: select * from v$database;select name from v$database;
desc v$databases; 查看数据库结构字段7、怎样查看哪些用户拥有SYSDBA、SYSOPER权限:
SQL>select * from V_$PWFILE_USERS;
Show user;查看当前数据库连接用户8、进入test数据库:database test;
9、查看所有的数据库实例:select * from v$instance;
如:ora9i
10、查看当前库的所有数据表:
SQL> select TABLE_NAME from all_tables; select * from all_tables; SQL> select table_name from all_tables where table_name like ‘u’;TABLE_NAME———————————————default_auditing_options
11、查看表结构:desc all_tables;
12、显示CQI.T_BBS_XUSER的所有字段结构:
desc CQI.T_BBS_XUSER;13、获得CQI.T_BBS_XUSER表中的记录:
select * from CQI.T_BBS_XUSER;14、增加数据库用户:(test11/test)
create user test11 identified by test default tablespace users Temporary TABLESPACE Temp;15、用户授权:
grant connect,resource,dba to test11; grant sysdba to test11; commit; 16、更改数据库用户的密码:(将sys与system的密码改为test.)alter user sys indentified by test;
alter user system indentified by test;