标签:允许 buffers inactive ade cannot ati files grep art
一、安装前准备工作
1、修改主机名
#vi /etc/hosts //并添加内网IP地址对应的hostname,如下
127.0.0.1 localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.8.151 linux-test
2、修改standby数据库的/etc/sysconfig/iptables文件,开通1521端口:
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
3、重启iptables服务:
# service iptables restart
二、安装步骤:
1、安装yum:
# ln -sf /media/RHEL_6.4\ x86_64\ Disc\ 1/ rhel
# vi /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///root/rhel/
enabled=1
gpgcheck=0
gpgkey=file:///root/rhel/
2、安装oracle必须的包:(将pdksh-5.2.14-36.el5.x86_64.rpm包上传至/root/目录下)
# yum -y install gcc-c++*
# yum -y install libaio-devel*
# yum -y install elfutils-libelf-devel*
# rpm -ivh pdksh*
# cd /root/rhel/Packages
# rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
3、修改内核参数
# vi /etc/sysctl.conf 在文件最后增加:
16G内存建议值:
fs.aio-max-nr = 1048576
fs.file-max = 6553600
kernel.shmall = 8388608
kernel.shmmax = 9663676416
kernel.shmmni = 4096
kernel.sem = 2010 285420 100 142
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
(参考值:
fs.aio-max-nr = 1048576
fs.file-max = 6553600
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
)
参数详解如下:
fs.aio-max-nr = 1048576 //同时可以拥有的的异步IO请求数目。1048576 即 1024*1024 也就是 1024K 个。
fs.file-max = 6553600 //系统允许打开的文件数。
kernel.shmall = 4194304 //设置共享内存总页数。这个值太小有可能导致数据库启动报错。这个是8G的值,如果大于8G需要调整。
计算公式为:内存(G)*1024*1024*1024/4096,4096为getconf PAGE_SIZE得到分页大小。
kernel.shmmax = 2147483648 //Linux进程可以分配的单独共享内存段的最大值。一般设置为内存总大小的一半。
这个值的设置应该大于SGA_MAX_TARGET或MEMORY_MAX_TARGET的值,
因此对于安装Oracle数据库的系统,shmmax的值应该比内存的二分之一大一些。
kernel.shmmni = 4096 //设置系统级最大共享内存段数量。推荐最小值为4096。
kernel.sem = 610 86620 100 142 //从左到右分别为SEMMSL、SEMMNS、SEMOPM和SEMMNI。
1)SEMMSL:设置每个信号灯组中信号灯最大数量,推荐的最小值是250。
对于系统中存在大量并发连接的系统,推荐将这个值设置为PROCESSES初始化参数加10。
2)SEMMNS:设置系统中信号灯的最大数量。操作系统在分配信号灯时不会超过LEAST(SEMMNS,SEMMSL*SEMMNI)。
事实上,如果SEMMNS的值超过了SEMMSL*SEMMNI是非法的,因此推荐SEMMNS的值就设置为SEMMSL*SEMMNI。
Oracle推荐SEMMNS的设置不小于32000,假如数据库的PROCESSES参数设置为600,则SEMMNS的设置应为:
SQL> select (600+10)*142 from dual;
(600+10)*142
------------
86620
3)SEMOPM:设置每次系统调用可以同时执行的最大信号灯操作的数量。
由于一个信号灯组最多拥有SEMMSL个信号灯,因此有推荐将SEMOPM设置为SEMMSL的值。
Oracle验证的10.2和11.1的SEMOPM的配置为100。
4)SEMMNI:设置系统中信号灯组的最大数量。Oracle10g和11g的推荐值为142。
net.ipv4.ip_local_port_range = 1024 65000 //ip_local_port_range表示端口的范围,为指定的内容
net.core.rmem_default = 262144 //表示接收套接字缓冲区大小的缺省值(以字节为单位)。
net.core.rmem_max = 4194304 //表示接收套接字缓冲区大小的最大值(以字节为单位)。
net.core.wmem_default = 262144 //表示发送套接字缓冲区大小的缺省值(以字节为单位)。
net.core.wmem_max = 1048586 //表示发送套接字缓冲区大小的最大值(以字节为单位。
最后输入下面的命令,让内核参数生效:
# /sbin/sysctl -p
sysctl -p 报错解决方法如下:
modprobe bridge
lsmod | grep bridge
sysctl -p
3、修改用户的限制文件
# vi /etc/security/limits.conf 在文件后增加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
# vi /etc/pam.d/login 文件,(64位系统时,千万别写成/lib/security/pam_limits.so,否则导致无法登录)增加如下:
session required /lib64/security/pam_limits.so
session required pam_limits.so
# vi /etc/profile (在unset -f pathmunge下一行)增加如下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
4、建立用户组及用户
# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba -d /home/oracle oracle
# passwd oracle //设置oracle密码
5、创建目录及修改权限:
# mkdir -p /home/oracle/app
# mkdir -p /home/oracle/app/oracle
# mkdir -p /home/oracle/app/oracle/product
# mkdir -p /home/oracle/app/oracle/product/11.2.0 //数据库系统安装目录
# mkdir -p /home/oracle/app/oracle/product/11.2.0/dbhome_1
# mkdir -p /home/oracle/backup //数据备份目录
# mkdir -p /home/oracle/oraInventory //清单目录
# chown -R oracle:oinstall /home/oracle/app
# chown -R oracle:oinstall /home/oracle/backup
# chown -R oracle:oinstall /home/oracle/oraInventory
# chmod -R 775 /home/oracle/app
6、设置并刷新环境变量:
# su - oracle
$ vi /home/oracle/.bash_profile
umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=xtwl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
$ source ~/.bash_profile
7、解压安装包:(将oracle软件上传至/home/oracle目录下)
# su - oracle
$ unzip p10404530_112030_Linux-x86-64_1of7.zip
$ unzip p10404530_112030_Linux-x86-64_2of7.zip
8、安装oracle软件:
$ cp -R /home/oracle/database/response /home/oracle //复制一份模板
$ cd /home/oracle/response
$ vi db_install.rsp //修改安装应答文件
三个文件作用分别是:
db_install.rsp:安装应答
dbca.rsp:创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置应答
特别是组件配置事后请用如右语句查询核实(select comp_id, comp_name, version, status from dba_registry)
配置安装应答文件db_install.rsp,如下:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=nmgdboracle //通过hostname命令获取
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/home/oracle/app
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=true
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.3.0,oracle.oraolap:11.2.0.3.0,oracle.rdbms.dm:11.2.0.3.0,oracle.rdbms.dv:11.2.0.3.0,oracle.rdbms.lbac:11.2.0.3.0,oracle.rdbms.rat:11.2.0.3.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=xtwl
oracle.install.db.config.starterdb.SID=xtwl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=10240 //物理内存的60%左右
oracle.install.db.config.starterdb.password.ALL=oracle //注意修改
oracle.install.db.config.starterdb.control=DB_CONTROL
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true //一定要是true
$cd /home/oracle/database
$./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp //了解安装进度 tail -f /home/oracle/oraInventory/logs/installActions*log
//当安装界面出现如下信息的时候
The installation of Oracle Database 11g was successful.
Please check ‘/home/oracle/oraInventory/logs/silentInstall2016-02-04_09-21-13AM.log‘ for more details.
As a root user, execute the following script(s):
1. /home/oracle/oraInventory/orainstRoot.sh
2. /home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh
Successfully Setup Software.
//在新打开的root登录的窗口中执行下面的脚本
#/home/oracle/oraInventory/orainstRoot.sh
#/home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh
//执行完上面的脚本后回到安装界面按下Enter键以继续
9、配置oracle监听:
$cd /home/oracle/response
$netca /silent /responsefile /home/oracle/response/netca.rsp
成功运行后,在/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin目录下生成sqlnet.ora和listener.ora两个文件。
通过 netstat -tlnp 命令,看到
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 22494/tnslsnr
说明监听器已经在1521端口上开始工作了
10、安装oracle数据库
$cd /home/oracle/response
$vi dbca.rsp //修改创建数据库应答文件
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
#-----------------------*** End of GENERAL section ***------------------------
GDBNAME = "xtwl"
SID = "xtwl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
DATAFILEDESTINATION = /home/oracle/app/oradata
#RECOVERYAREADESTINATION=/home/oracle/backup //该项参数设置无效,默认恢复表空间仍然是$ORACLE_BASE/flash_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "10240" //物理内存的60%左右
#-----------------------*** End of CREATEDATABASE section ***------------------------
$dbca -silent -responseFile /home/oracle/response/dbca.rsp (静默卸载:dbca -silent -deleteDatabase -sourcedb xtwl -sid xtwl)
看到下面语句说明创建成功
Look at the log file "/home/oracle/app/cfgtoollogs/dbca/xtwl/xtwl.log" for further details.
查看创建情况
$cat /home/oracle/app/cfgtoollogs/dbca/xtwl/xtwl.log
建库后实例检查:
$ps -ef | grep ora_ | grep -v grep
oracle 39754 1 0 10:20 ? 00:00:00 ora_pmon_xtwl
oracle 39756 1 0 10:20 ? 00:00:00 ora_vktm_xtwl
oracle 39760 1 0 10:20 ? 00:00:00 ora_gen0_xtwl
oracle 39762 1 0 10:20 ? 00:00:00 ora_diag_xtwl
oracle 39764 1 0 10:20 ? 00:00:00 ora_dbrm_xtwl
oracle 39766 1 0 10:20 ? 00:00:00 ora_psp0_xtwl
oracle 39768 1 0 10:20 ? 00:00:00 ora_dia0_xtwl
oracle 39770 1 0 10:20 ? 00:00:00 ora_mman_xtwl
oracle 39772 1 0 10:20 ? 00:00:00 ora_dbw0_xtwl
oracle 39774 1 0 10:20 ? 00:00:00 ora_lgwr_xtwl
oracle 39776 1 0 10:20 ? 00:00:00 ora_ckpt_xtwl
oracle 39778 1 0 10:20 ? 00:00:00 ora_smon_xtwl
oracle 39780 1 0 10:20 ? 00:00:00 ora_reco_xtwl
oracle 39782 1 0 10:20 ? 00:00:00 ora_mmon_xtwl
oracle 39784 1 0 10:20 ? 00:00:00 ora_mmnl_xtwl
oracle 39786 1 0 10:20 ? 00:00:00 ora_d000_xtwl
oracle 39788 1 0 10:20 ? 00:00:00 ora_s000_xtwl
oracle 39798 1 0 10:20 ? 00:00:00 ora_qmnc_xtwl
oracle 39813 1 0 10:20 ? 00:00:00 ora_cjq0_xtwl
oracle 39815 1 0 10:20 ? 00:00:00 ora_q000_xtwl
oracle 39817 1 0 10:20 ? 00:00:00 ora_q001_xtwl
查看监听状态
$lsnrctl status
三、参数修改:
需要手动备份spfile文件:
cp $ORACLE_HOME/dbs/spfilextwl.ora $ORACLE_HOME/dbs/spfilextwl_bak.ora
1、修改最大连接数:
sql> show parameter processes;
sql> alter system set processes=2000 scope = spfile;
2、禁止回收站功能:
SQL> show parameter recyclebin;
SQL> alter system set recyclebin=off scope=spfile;
3、关闭审计功能:
SQL> show parameter audit;
SQL> alter system set audit_trail=NONE scope=spfile;
4、修改用户密码用不过期:
SQL> select * from dba_profiles s where s.profile=‘DEFAULT‘ and resource_name=‘PASSWORD_LIFE_TIME‘;
PROFILE RESOURCE_NAME RESOURCE
------------------------------ -------------------------------- --------
LIMIT
----------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD
180
SQL> alter profile default limit password_life_time unlimited;
Profile altered.
SQL> select * from dba_profiles s where s.profile=‘DEFAULT‘ and resource_name=‘FAILED_LOGIN_ATTEMPTS‘;
PROFILE RESOURCE_NAME RESOURCE
------------------------------ -------------------------------- --------
LIMIT
----------------------------------------
DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD
10
SQL> alter profile default limit failed_login_attempts unlimited;
Profile altered.
5、修改控制文件里可重复使用的记录所能保存的最小天数:(一般设置为45天)
SQL> show parameter control;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /home/oracle/app/oradata/xtwl/control01.ctl, /home/oracle/app/flash_recovery_area/xtwl/control02.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
SQL> alter system set control_file_record_keep_time=45 scope=spfile;
System altered.
6、设置数据库为自动内存管理模式:
(1)修改数据库为自动内存管理模式:
SQL> alter system set memory_target=10240M scope=spfile; //物理内存的60%左右。
System altered.
SQL> alter system set memory_max_target=10240M scope=spfile; //物理内存的60%左右。
System altered.
SQL> alter system set sga_target=0 scope=spfile;
System altered.
SQL> alter system set sga_max_size=7168M scope=spfile; //实例内存的70%左右,即memory_max_target*70%,也即物理内存*60%*70%。
System altered.
SQL> alter system set pga_aggregate_target=0 scope=spfile;
System altered.
SQL> alter system set pre_page_sga=FALSE scope=spfile;
System altered.
(2)重启数据库:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 2254802944 bytes
Fixed Size 2215344 bytes
Variable Size 1073742416 bytes
Database Buffers 1174405120 bytes
Redo Buffers 4440064 bytes
Database mounted.
Database opened.
(3)查看各个内存参数设置:
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 7G
sga_target big integer 0
SQL> show parameter pga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target big integer 0
SQL> show parameter memory;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
memory_max_target big integer 10G
memory_target big integer 10G
shared_memory_address integer 0
四、修改redo log组以及大小:--为防止日志频繁切换,引起数据库性能低下问题。
1、创建redo日志存放目录:
$ mkdir -p /home/oracle/app/oradata/xtwllog/
$ chmod 750 /home/oracle/app/oradata/xtwllog/
2、查询日志信息:
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
1 50 ACTIVE
2 50 CURRENT
3 50 ACTIVE
3、查询日志目录:
SQL> select * from v$logfile order by group#;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------ ----------------
1 ONLINE /home/oracle/app/oradata/xtwl/redo01.log NO
2 ONLINE /home/oracle/app/oradata/xtwl/redo02.log NO
3 ONLINE /home/oracle/app/oradata/xtwl/redo03.log NO
4、新增两组日志组,每组500M:
SQL> alter database add logfile group 4 ‘/home/oracle/app/oradata/xtwllog/redo04.log‘ size 500M;
Database altered.
SQL> alter database add logfile group 5 ‘/home/oracle/app/oradata/xtwllog/redo05.log‘ size 500M;
Database altered.
5、查询4、5两组日志是否成功添加:
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
1 50 INACTIVE
2 50 CURRENT
3 50 INACTIVE
4 500 UNUSED
5 500 UNUSED
6、删除日志组1:
SQL> alter database drop logfile group 1;
Database altered.
7、删除日志组2报错:
SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01623: log 2 is current log for instance xtwl (thread 1) - cannot drop
ORA-00312: online log 2 thread 1: ‘/home/oracle/app/oradata/xtwl/redo02.log‘
8、需要手动切换日志多次,使新建的日志组能够应用:
SQL> alter system switch logfile;
System altered.
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
2 50 ACTIVE
3 50 INACTIVE
4 500 CURRENT
5 500 UNUSED
SQL> alter system switch logfile;
System altered.
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
2 50 ACTIVE
3 50 INACTIVE
4 500 ACTIVE
5 500 CURRENT
9、使用alter system checkpoint将Active的日志状态置为INACTIVE:
SQL> alter system checkpoint;
System altered.
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
2 50 INACTIVE
3 50 INACTIVE
4 500 INACTIVE
5 500 CURRENT
10、删除原2,3日志组:
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
11、新增1,2,3日志组,每组500M:
SQL> alter database add logfile group 1 ‘/home/oracle/app/oradata/xtwllog/redo01.log‘ size 500M;
Database altered.
SQL> alter database add logfile group 2 ‘/home/oracle/app/oradata/xtwllog/redo02.log‘ size 500M;
Database altered.
SQL> alter database add logfile group 3 ‘/home/oracle/app/oradata/xtwllog/redo03.log‘ size 500M;
Database altered.
SQL> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ----------------
1 1 500 UNUSED
2 1 500 UNUSED
3 1 500 UNUSED
4 1 500 INACTIVE
5 1 500 CURRENT
12、多次执行切换日志操作,使新建的日志组都能正常应用:
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> SELECT group#, members, bytes/1024/1024 byte_mb, status FROM v$log;
GROUP# MEMBERS BYTE_MB STATUS
---------- ---------- ---------- ----------------
1 1 500 ACTIVE
2 1 500 ACTIVE
3 1 500 CURRENT
4 1 500 INACTIVE
5 1 500 ACTIVE
SQL> select * from v$logfile order by group#;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------ ----------------
1 ONLINE /home/oracle/app/oradata/xtwllog/redo01.log NO
2 ONLINE /home/oracle/app/oradata/xtwllog/redo02.log NO
3 ONLINE /home/oracle/app/oradata/xtwllog/redo03.log NO
4 ONLINE /home/oracle/app/oradata/xtwllog/redo04.log NO
5 ONLINE /home/oracle/app/oradata/xtwllog/redo05.log NO
13、删除原redo日志文件,释放磁盘空间:
$ rm /home/oracle/app/oradata/xtwl/redo0*.log
五、修改数据库为归档日志模式:
1、新建归档日志存放目录:
$ mkdir -p /home/oracle/app/archlog
$ chmod 750 /home/oracle/app/archlog
2、停止数据库:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
3、启动数据库到mount状态:
SQL> startup mount
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 1023412336 bytes
Database Buffers 570425344 bytes
Redo Buffers 7360512 bytes
Database mounted.
4、修改日志模式为归档模式:
SQL> alter database archivelog;
Database altered.
5、修改归档日志格式:
SQL> alter system set log_archive_format=‘xtwldb_%t_%s_%r.log‘ scope=spfile;
System altered.
6、修改归档日志路径:
SQL> alter system set log_archive_dest1=‘location=/home/oracle/app/archlog‘ scope=spfile;
System altered.
7、打开数据库:
SQL> alter database open;
Database altered.
8、重启数据库使各参数生效:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 570427504 bytes
Database Buffers 1023410176 bytes
Redo Buffers 7360512 bytes
Database mounted.
Database opened.
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZoneJ/article/details/50680857
标签:允许 buffers inactive ade cannot ati files grep art
原文地址:https://www.cnblogs.com/momoyan/p/9128297.html