扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
一、使用脚本初始化环境
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了定西免费建站欢迎大家使用!
脚本如下:(标红处修改对应的配置需求)
#!/bin/bash
#1.配置主机名/etc/hosts 并关闭防火墙及selinux
echo ' 172.168.0.xx linux.tk ' /etc/hosts
#注意修改为服务器的ip和主机名
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#2.安装相关软件包
yum -y install telnet vim lszrz gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel
elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat
unixODBC unixODBC-devel pcre-devel wget unzip
#3.配置内核参数
echo "fs.aio-max-nr = 1048576" /etc/sysctl.conf
echo "fs.file-max = 6815744" /etc/sysctl.conf
echo "kernel.shmmni = 4096" /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" /etc/sysctl.conf
echo "net.core.rmem_default = 262144" /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" /etc/sysctl.conf
echo "net.core.wmem_default = 262144" /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" /etc/sysctl.conf
sysctl -p
#4.oracle用户资源限制
echo "oracle soft nproc 2047" /etc/security/limits.conf
echo "oracle hard nproc 16384" /etc/security/limits.conf
echo "oracle soft nofile 4096" /etc/security/limits.conf
echo "oracle hard nofile 65536" /etc/security/limits.conf
#5.登录配置
echo "session required /lib64/security/pam_limits.so" /etc/pam.d/login
echo "session required pam_limits.so" /etc/pam.d/login
#改授权
echo "if [ $USER = 'oracle' ];then" /etc/profile
echo "if [ $SHELL = '/bin/ksh' ];then" /etc/profile
echo "ulimit -p 16384" /etc/profile
echo "ulimit -n 65536" /etc/profile
echo "else" /etc/profile
echo "ulimit -u 16384 -n 65536" /etc/profile
echo "fi" /etc/profile
echo "fi" /etc/profile
source /etc/profile
#6.创建用户组和用户
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
echo 'oracle' | passwd --stdin oracle
#7.创建相关目录
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app
#8.配置oracle用户环境变量
echo "ORACLE_SID=ora; export ORACLE_SID" /home/oracle/.bash_profile
#sid指定为现场的sid
echo "ORACLE_BASE= /u01/app/oracle ; export ORACLE_BASE" /home/oracle/.bash_profile
echo "ORACLE_HOME=$ORACLE_BASE/ product/11.2.0/dbhome_1 ; export ORACLE_HOME" /home/oracle/.bash_profile
echo "ORACLE_PATH=/u01/app/common/oracle/sql; export ORACLE_PATH" /home/oracle/.bash_profile
echo "ORACLE_TERM=xterm; export ORACLE_TERM" /home/oracle/.bash_profile
echo "TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN" /home/oracle/.bash_profile
echo "ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11" /home/oracle/.bash_profile
echo "PATH=.:${JAVA_HOME}/bin:${PATH}:$ORACLE_HOME/bin " /home/oracle/.bash_profile
echo "PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin " /home/oracle/.bash_profile
echo "export PATH " /home/oracle/.bash_profile
echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=$ORACLE_HOME/lib" /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib " /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib " /home/oracle/.bash_profile
echo "export LD_LIBRARY_PATH" /home/oracle/.bash_profile
echo "export LANG=en_US.UTF-8 " /home/oracle/.bash_profile
echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" /home/oracle/.bash_profile
echo "CLASSPATH=$ORACLE_HOME/JRE " /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib" /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib" /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib" /home/oracle/.bash_profile
echo "export CLASSPATH" /home/oracle/.bash_profile
echo "THREADS_FLAG=native; export THREADS_FLAG" /home/oracle/.bash_profile
echo "nls_date_format='yyyy-mm-dd hh24:mi:ss' " /home/oracle/.bash_profile
echo "export nls_date_format " /home/oracle/.bash_profile
echo "export TEMP=/tmp " /home/oracle/.bash_profile
echo "export TMPDIR=/tmp " /home/oracle/.bash_profile
echo "umask 022 " /home/oracle/.bash_profile
source ~/.bash_profile
二、上传或者下载oracle安装包并解压,例如放置在/opt/目录下
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
直接在目录解压,会在当前目录中生成database目录
三、修改应答文件安装数据库软件
修改前建议先备份下
cp /opt/database/response/*.rsp /opt/database/rspbak
3.1、生成修改响应文件(/opt/database/response/db_install.rsp)
备注:清空源文件,复制粘贴如下内容(标红处需要修改对应的设置需求):
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME= linux.tk
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION= /u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE= /u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:10.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
3.2、开始安装
1)、用oracle用户登录操作
# su - oracle
$ cd /opt/database
$ ./runInstaller -silent -responseFile /opt/database/response/db_install.rsp
2)、在安装过程中可以新开会话,使用tailf 命令查看进度
# tailf /u01/app/oraInventory/logs/installActions2022-XX-XX_03-28-06PM.log
提示安装结束,需要在root用户执行两个脚本,如下:
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
四、修改应答文件安装数据库实例(/opt/database/response/dbca.rsp)
安装实例前,需要新建一个实例存放的目录(/home/OracleData/),如下:
# mkdir /home/OracleData
# chown -R oracle:oinstall /home/OracleData/
4.1、修改应答文件
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "ora"
SID = "ora"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "***012"
SYSTEMPASSWORD = "***012"
DATAFILEDESTINATION = /home/OracleData/
RECOVERYAREADESTINATION = /u01/app/oracle/flash_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "2048"
4.2、建实例,登录oracle用户
# su - oracle
$ dbca -silent -responseFile /opt/database/response/dbca.rsp
此安装过程是有进度显示,不用tailf查看,不过也可以查看对应的log日志查看进度
4.3、删除实例
编辑应答文件
#vim /opt/database/response/del_dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "deleteDatabase"
[DELETEDATABASE]
SOURCEDB = "ora "
$ dbca -silent -responseFile del_dbca.rsp
五、启动监听,配置自启动等
5.1、启动监听
# su – oracle
$ lsnrctl start
查看状态 lsnrctl status
# netstat -tnulp | grep 1521
# ps -ef | grep ora_ | grep -v grep
5.2、设置自启动
修改vim /etc/oratab 如下
ora:/u01/app/oracle/product/11.2.0/dbhome_1: Y
5.3、修改dbstart文件
vim /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
将ORACLE_HOME_LISTNER=$1
修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
5.4、将dbstart加入开机自启动,/etc/rc.d/rc.local中增加
su - oracle -lc /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
赋权限 chmod +x /etc/rc.d/rc.local
5.3、登录数据库设置权限等
sqlplus / as sysdba
startup;
alter system register;
create user ora identified by ***012;
grant dba to ora;
exit
六、远程连接数据库
6.1、开放1521端口
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd –reload
firewall-cmd --list-ports
首先,否定楼上说法。静默安装甚至于用脚本结合响应文件实现静默自动安装都是可以实现的,你可以参照下面这篇文章作为入门。
静默安装指的是不需要值守和输入各项安装参数的安装方式,其实是将安全的参数都指定到一个文件里了,其实意义不大,因为Oracle的OUI安装并不复杂,而且你也不会大规模的安装很多个Oracle。
切入到oracle用户下
进入/u01/app/oracle/product/11.2.0/dbhome_1/assistants/dbca
目录,vim编辑静默安装文件dbca.rsp
主要配置[GENERAL][CREATEDATABASE]这2个模块下的配置即可
执行如下命令安装
dbca -silent -responseFile /u01/app/oracle/product/11.2.0/dbhome_1/assistants/dbca/dbca.rsp
安装完成,lsnrctl status检查监听吧。
此错误是因为安装Oracle的用户(一般是oracle用户),没有权限调用图形界面,只需退出oracle用户,在root下执行xhost +命令,然后再进入oracle用户重新运行./runInstaller即可 [root@wyzc ~]# xhost + [root@wyzc ~]# su - oracle。
oracle 11gR2
1、数据库安装环境准备
1)编辑/etc/sysctl.con
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 = 1048586
Enter the following command to change the current values of the kernel parameters:
# /sbin/sysctl -p
2)编辑/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
3)创建oracle用户,组
groupadd install;
groupadd oper;
groupadd dba;
useradd -g oinstall -G dba,oper oracle
passwd oracle
4) oracle相关 环境变量设置
.bash_profile文件中加入如下内容:
export ORACLE_SID=orcl
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2/db_1
PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
保存后使环境变量生效。
. .bash_profile
5)创建安装目录
# mkdir /opt/app
#chown -R oracle:oinstall /opt/app
2、准备静默安装响应文件
1)利用图形化界面生成rsp文件
运行到oracle 安装目录下
./runInstaller
到最后快filish的时候点击 Save Response File 按钮制定db.rsp文件存放路径;最后cancel安装界面。
2)如果不能执行图形化界面录制,可以通过编辑现有的rsp文件
打开安装文件路径找到response文件夹里面的 db_install.rsp文件。
根据文件提示修改相关内容,一般是安装组,ORACLE_HOME,ORACLE_BASE 路径等信息。
3、执行静默安装操作
1)开始静默安装
$ ./runInstaller -silent -noconfig -ignorePrereq -responseFile /home/oracle/db.rsp
2)查看安装过程
可以到/opt/app/oraInventory/logs 目录下查看安装进度。
tail -100f installActions2012-03-13_10-36-42AM.log
3)安装成功提示执行脚本
到最后提示:
/opt/app/oracle/oraInventory/orainstRoot.sh
/opt/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流