您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
Oracle安装之简单篇
安装准备包
linuxredhat5.8操作系统
oracle11g(以下是包名)
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
安装准备
配置IP,hosts,主机名。
备注hosts文件一定要与主机名对应。(如下)
127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.66.249 dbserver.cjl.com
配置oracle环境脚本
#!/bin/bash #查看内存大小 echo "Mem Check:swap >2G,MEM >2G" grep -i memtotal /proc/meminfo grep -i swaptotal /proc/meminfo #配置yum本地源 cat <<END >/etc/yum.repos.d/rhel.repo [local] [local]cal baseurl=file:///mnt/Server/ enabled=1 gpgcheck=0 END #挂载光盘并安装插件 mount /dev/cdrom /mnt yum -y groupinstall "Development Tools" yum -y install binutils compat-libstdc++-33 elfutils-* gcc gcc-c++* glibc* kernel-headers ksh libaio* libgcc #配置路由 cat <<END >> /etc/sysctl.conf fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 END sysctl -p #创建用户组和用户并授权 groupadd -g 500 oinstall groupadd -g 501 dba useradd -g oinstall -G dba oracle echo "123123" |passwd --stdin oracle mkdir /opt/oracle chown -R oracle:oinstall /opt/oracle chmod -R 775 /opt/oracle sudo mkdir /opt/tmp sudo chmod a+rw /opt/tmp #添加用户环境变量 cat <<END >>/home/oracle/.bash_profile umask 022 export ORACLE_BASE=/opt/oracle export ORACLE_HOME=\$ORACLE_BASE/product/11.2/db_1 export ORACLE_SID=orcl export LANG=zh_CN.UTF-8 export NLS_LANG="AMERICAN_AMERICA".ZHS16GBK export PATH=\$PATH:\$ORACLE_HOME/bin export DISPLAY=:0.0 END #添加认证模块 cat <<END >>/etc/pam.d/login session required /lib64/security/pam_limits.so session required pam_limits.so END #设置oracle限制 cat <<END >>/etc/security/limits.conf oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 END #oracle软堆栈限制 cat <<END >>/etc/profile if [ $USER = "oracle" ];then if [ \$SHELL = "/bin/ksh" ];then ulimit -p 16384 ulimit -p 65536 else ulimit -u 16384 -n 65536 fi fi END
解压Oracle11g的包到oracle用户的home目录
unzip -d /home/oracle linux.x64_11gR2_database_1of2.zip && unzip -d /home/oraclelinux.x64_11gR2_database_2of2.zip
允许用户oracle从本机访问
[root@dbserver ~]# xhost + access control disabled, clients can connect from any host
切换用户并进入解压目录运行安装
[root@dbserver ~]# su - oracle [oracle@dbserver ~]$ ls database [oracle@dbserver ~]$ cd database/ [oracle@dbserver database]$ ./runInstaller
运行root用户执行提示脚本
[root@dbserver ~]# /opt/oracle/oraInventory/orainstRoot.sh 更改权限/opt/oracle/oraInventory. 添加组的读取和写入权限。 删除全局的读取, 写入和执行权限。 更改组名/opt/oracle/oraInventory 到 oinstall. 脚本的执行已完成。 [root@dbserver ~]# /opt/oracle/product/11.2/db_1/root.sh Running Oracle 11g root.sh script... The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /opt/oracle/product/11.2/db_1 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. [root@dbserver ~]#
访问以上地址测试https://dbserver.cjl.com:1158/em/
oracle用户访问测试
[oracle@dbserver database]$ sqlplus sys as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 18 05:28:47 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show user; USER is "SYS" SQL>
图形界面添加数据库
如果重新启动还需web访问可用以下命令重新获取网址
[oracle@dbserver ~]$ emctl start dbconsole Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0 Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved. https://dbserver.cjl.com:1158/em/console/aboutApplication Starting Oracle Enterprise Manager 11g Database Control ........ started. ------------------------------------------------------------------ Logs are generated in directory /opt/oracle/product/11.2/db_1/dbserver.cjl.com_orcl/sysman/log
如果发现不能使用dbca命令时试试它
[oracle@dbserver ~]$ /opt/oracle/product/11.2/db_1/bin/dbca Xlib: connection to ":0.0" refused by server Xlib: No protocol specified [root@dbserver ~]# xhost + access control disabled, clients can connect from any host
启动数据库先启动监听
[oracle@dbserver ~]$ lsnrctl LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-SEP-2015 05:07:44 Copyright (c) 1991, 2009, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> start Starting /opt/oracle/product/11.2/db_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /opt/oracle/product/11.2/db_1/network/admin/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver.cjl.com)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 18-SEP-2015 05:07:50 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/product/11.2/db_1/network/admin/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver.cjl.com)(PORT=1521))) The listener supports no services The command completed successfully LSNRCTL> quit [oracle@dbserver ~]$ sqlplus sys as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 18 05:08:12 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter password: Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 839282688 bytes Fixed Size 2217992 bytes Variable Size 541067256 bytes Database Buffers 289406976 bytes Redo Buffers 6590464 bytes Database mounted. Database opened. SQL> show user; USER is "SYS" SQL> alter database open; alter database open * ERROR at line 1: ORA-01531: a database already open by the instance SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
关闭数据库
shutdown immediate
shutdown abort (上一条关闭不能执行,则执行这条强制关机)
关闭监听
lsnrctl stop
本文如出现错误请留言!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。