规划主机资源
2台linux主机
10.38.112.83 ctp-trade 部署交易主机 (trade)
10.38.112.84 ctp-db 部署分控、结算相关组件,还有柜台相关组件
更改主机名
配置SSH免密访问(RSA加密原理)
1、生成公钥和私钥ssh-keygen -t rsa
2、将私钥复制到目标主机home目录的对应用户 /home/trade/.ssh/authorized_keys
文件内
cp ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
scp /home/trade/.ssh/authorized_keys ctp-db:/home/trade/.ssh/authorized_keys
安装和优化数据库
安装数据库过程跳过
添加oracle用户
groupadd oinstall #创建用户组oinstall
groupadd dba #创建用户组dba
useradd -g oinstall -G dba -m oracle #创建oracle用户,并加入到oinstall和dba用户组
passwd oracle #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
配置ORACLE_BASE和ORACLE_HOME为以下路径
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
优化数据库
alter profile default limit password_life_time unlimited;--密码有效期设置为无限制
alter profile default limit failed_login_attempts unlimited;--2错误密码尝试次数设置为无限制
alter system set audit_trail=none scope=spfile;--3关闭审计
--修改自动统计信息收集作业
--检查作业为关闭状态
select client_name,status from dba_autotask_client;
--修改作业时间
select window_name, repeat_interval, duration, enabled from dba_scheduler_windows;
exec dbms_scheduler.disable( name =>'MONDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'MONDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=MON;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'MONDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(180,'minute'));
END;
exec dbms_scheduler.enable( name => 'MONDAY_WINDOW');
exec dbms_scheduler.disable( name =>'TUESDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'TUESDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=TUE;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'TUESDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(180,'minute'));
END;
exec dbms_scheduler.enable( name => 'TUESDAY_WINDOW');
exec dbms_scheduler.disable( name =>'WEDNESDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'WEDNESDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=WED;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'WEDNESDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(180,'minute'));
END;
exec dbms_scheduler.enable( name => 'WEDNESDAY_WINDOW');
exec dbms_scheduler.disable( name =>'THURSDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'THURSDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=THU;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'THURSDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(180,'minute'));
END;
exec dbms_scheduler.enable( name => 'THURSDAY_WINDOW');
exec dbms_scheduler.disable( name =>'FRIDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'FRIDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=FRI;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'FRIDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(180,'minute'));
END;
exec dbms_scheduler.enable( name => 'FRIDAY_WINDOW');
exec dbms_scheduler.disable( name =>'SATURDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'SATURDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=SAT;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'SATURDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(1200,'minute'));
END;
exec dbms_scheduler.enable( name => 'SATURDAY_WINDOW');
exec dbms_scheduler.disable( name =>'SUNDAY_WINDOW', force => TRUE);
BEGIN
dbms_scheduler.set_attribute(
name => 'SUNDAY_WINDOW',
attribute => 'repeat_interval',
value => 'freq=daily;byday=SUN;byhour=3;byminute=0;bysecond=0');
dbms_scheduler.set_attribute(
name => 'SUNDAY_WINDOW',
attribute => 'DURATION',
value => numtodsinterval(1200,'minute'));
END;
exec dbms_scheduler.enable( name => 'SUNDAY_WINDOW');
启用作业
execute DBMS_AUTO_TASK_ADMIN.enable();
--select client_name,status from dba_autotask_client;
alter system set processes=5000 scope=spfile;--5、修改最大连接数
alter system set open_cursors=20000 scope=spfile; --6、修改游标数
alter system set session_cached_cursors=300 scope=spfile;
alter system set db_writer_processes=4 scope=spfile;--7、设置dbwr进程数
alter system set "_undo_autotune"=false scope=spfile;--9、设置回滚段相关参数
alter system set undo_retention=1800 scope=spfile;
alter system set log_checkpoints_to_alert=TRUE scope=spfile;--11、设置redo log相关参数
alter database add logfile group 11 '+RedoLog/gfqhzj/onlinelog/thread1_redo11.dbf' size 500m;--#设置redo log文件16个,每个大小500M
--操作日志组为current:alter system switch logfile;
--操作日志组为active:alter system checkpoint;
alter database drop logfile group 1;
--alter database drop LOGFILE MEMBER 'file';
create or replace directory DUMPDIR as '/mnt';--12、设置dumpdir(根据实际情况设置)
alter system set optimizer_index_caching=90 scope=spfile;--13、设置SQL优化器相关参数
alter system set optimizer_index_cost_adj=10 scope=spfile;--15、重启数据库,检查设置是否生效。