Centos 6.10 安装oracle10.2.0.1

news2024/12/23 6:22:44

由于阿里云机房要下架旧服务器,单位未购买整机迁移服务,且业务较老不兼容Oracle11g,所以新购买一台新服务器进行安装Oracle10.2.0.1 ,后续再将数据迁移到新服务器上。

对外ip

内部ip

数据库版本

操作系统版本

实例名

源库

115.28.242.253

192.168.0.10

Oracle10.2.0.1

Centos6.9 x86_64

cq

目标库

120.46.146.123

192.168.0.35

Oracle10.2.0.1

Centos6.9 x86_64

一.安装前准备

1.1.查询源库信息

1.1.1.查看服务器配置

确保新服务器配置等于或高于旧服务器。

1.1.2.1.查看操作系统版本
[root@cq ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
1.1.2.2.查看磁盘空间
[root@cq ~]# df -Th
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/vda1      ext4    40G  4.4G   33G  12% /
tmpfs          tmpfs  3.9G     0  3.9G   0% /dev/shm
/dev/vdb       ext4   493G  446G   22G  96% /opt
1.1.2.3.cpu配置
[root@cq ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 79
Model name:            Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
Stepping:              1
CPU MHz:               2499.996
BogoMIPS:              4999.99
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              40960K
NUMA node0 CPU(s):     0-3
1.1.2.4.内存配置
[root@cq ~]# awk '/MemTotal/{print $2}' /proc/meminfo  K
8193112   --单位

或 

[root@cq ~]# free -g
             total       used       free     shared    buffers     cached
Mem:             7          6          1          3          0          4
-/+ buffers/cache:          1          6
Swap:           15          0         15
1.1.2.5.磁盘IO速度监控
--磁盘IO速度监控 每间隔3秒监控3次
[root@cq ~]# iostat 3 3
Linux 2.6.32-696.16.1.el6.x86_64 (cq) 	05/10/2024 	_x86_64_	(4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7.42    0.00    0.46    3.94    0.00   88.18

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
vda               0.45         0.83         5.53   17854722  118882528
vdb             299.55     13416.03      2750.53 288563271330 59160700608

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.35    0.00    1.00   18.90    0.00   74.75

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
vda               0.00         0.00         0.00          0          0
vdb             711.00     67051.00       131.33     201153        394

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.71    0.00    0.84    7.28    0.00   82.18

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
vda               1.00         0.00        10.67          0         32
vdb             265.00     19712.00        68.67      59136        206

1.1.2.查看数据库信息

1.1.2.1.统计数据量

由于该库数据量较小,该步骤省略。该步骤只适用于数据量大的场景。

--查看数据文件总大小
select sum(bytes)/1024/1024/1024 as "size(G)" from dba_data_files;
   size(G)
----------
156.899414

--查看总大小
select round(sum(bytes) / 1024 / 1024 / 1024, 2) || 'G'
  from dba_segments
 where owner not in ('MDSYS', 'OUTLN', 'CTXSYS', 'OLAPSYS', 'HR', 'SYSTEM',
        'EXFSYS', 'SCOTT', 'DBSNMP', 'ORDSYS', 'SYSMAN', 'OE', 'PM', 'SH',
        'XDB', 'ORDDATA', 'IX', 'SYS', 'WMSYS') ;
或
select round(sum(bytes) / 1024 / 1024 / 1024, 2) || 'G'
  from dba_segments;

 ROUND(SUM(BYTES)/1024/1024/1024,2)||'G'
-----------------------------------------
155.52G       
1.1.2.2.清理业务数据

需和开发 直属领导同意。对于占用空间大的表采用方案如下:

1、删除表数据。

2、备份时加参数排除,即不备份对业务来说不重要的表。

--查看表大小超过10G的大表
col owner for a40
col TABLE_NAME for a60
set linesize 999 pagesize 999
select * from (SELECT OWNER,TABLE_NAME,SUM(tabsize) table_size from (
 SELECT owner,SEGMENT_NAME as table_name,SUM(BYTES)/1024/1024/1024 as tabsize FROM DBA_SEGMENTS WHERE (OWNER,SEGMENT_NAME) IN (
 SELECT OWNER,TABLE_NAME FROM DBA_TABLES WHERE OWNER NOT IN  ('SYS','SYSTEM','DBSNMP'))
 GROUP BY SEGMENT_NAME,owner
 union ALL
 select lob.owner,lob.table_name,sum(seg.bytes)/1024/1024/1024 as tabsize from dba_lobs lob,dba_segments seg 
 where lob.segment_name=seg.segment_name and lob.OWNER NOT IN  ('SYS','SYSTEM','DBSNMP') group by lob.owner,lob.table_name
 ) 
 GROUP BY OWNER,TABLE_NAME ORDER  BY 3 DESC)
 where table_size>10 ;

--查询库中记录数大于2千万的所有表,当前用户拥有select any table权限
select table_name, num_rows from dba_tables t where t.owner = upper('hr') and num_rows > 20000000;
或
select table_name, num_rows from all_tables t where t.owner = upper('hr') and num_rows > 20000000;
1.1.2.3.停止监听
--停止监听
su - oracle
[oracle@top130 ~]$ lsnrctl status
[oracle@top130 ~]$ lsnrctl stop
[oracle@top130 ~]$ lsnrctl stop
1.1.2.4.开启防火墙
--开启防火墙
systemctl start firewalld
systemctl status firewalld
firewall-cmd --list-ports
1.1.2.5.停止会话

查询会话,如果有业务会话给干掉

--查看不同用户的连接数
select username,count(username) from v$session where username is not null group by username;

USERNAME		       COUNT(USERNAME)
------------------------------ ---------------
CQUSER					5
DEV					    78
SYS					     1


--查询用户会话
select username,serial#, sid from v$session where username is not null;
select username,status,schemaname,osuser,process,machine,port,program,serial#, sid from v$session where username is not null;

--删除相关用户会话
alter system kill session 'sid,serial#';

补充:
--源库杀用户连接 不建议 该步骤慎重 该文档未进行该操作  该方法迫不得已不用
ps -ef|grep LOCAL=NO|awk '{print $2}'|xargs kill -9

1.1.3.查看源库配置

保证新库和源库所有配置相同。

1.1.3.1.查看数据库参数
--数据库的创建日期和归档方式    
SELECT to_char(created,'yyyy-mm-dd'), log_mode, log_mode FROM V$database; 
TO_CHAR(CR LOG_MODE	LOG_MODE
---------- ------------ ------------
2022-08-02 ARCHIVELOG	ARCHIVELOG


--查数据库版本
SELECT version FROM product_component_version WHERE substr(product, 1, 6) = 'Oracle'; 
VERSION
--------------------------------------------------------------------------------------------------------------------------------
10.2.0.1.0


--查看实例名
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
cq

SQL> show parameter name

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert		     string
db_name 			     string	 cq
db_unique_name			     string	 cq
global_names			     boolean	 FALSE
instance_name			     string	 cq
lock_name_space 		     string
log_file_name_convert		     string
service_names			     string	 cq


-- 查看数据库字符集
set linesize 999
col value for a60
select * from nls_database_parameters where PARAMETER in ('NLS_CHARACTERSET','NLS_NCHAR_CHARACTERSET');
PARAMETER		       VALUE
------------------------------ ------------------------------------------------------------
NLS_CHARACTERSET	       ZHS16GBK
NLS_NCHAR_CHARACTERSET	 AL16UTF16


select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK

-- 查看数据库配置参数
set lin 1000 pagesize 999
col NAME for a30
col value for a40
col DISPLAY_VALUE for a40
SELECT name,value,display_value FROM v$parameter
WHERE name IN(
'processes',
'sessions',
'memory_target',
'memory_max_target',
'sga_max_size',
'sga_target',
'pga_aggregate_target'
);
NAME			                   VALUE					DISPLAY_VALUE
-----------------------      ------- ---------------------------------------- ----------------------------------------
processes		                 1000					    1000
sessions		                 1450					    1450
sga_max_size		             4294967296				4G
sga_target		               4294967296				4G
pga_aggregate_target	       1073741824				1G
1.1.3.2.查看用户
--查看用户
USERNAME		       DEFAULT_TABLESPACE	      TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
BACKUPKEVIN		       USERS			        TEMP
TESTSSS 		         USERS			        TEMP
YUNTEST 		         USERS			        TEMP
CQTEST			         CQSCHEMA 		      TEMP
CQUSER			         CQSCHEMA 		      TEMP
DEV			             CQSCHEMA 		      TEMP
TEST			           CQSCHEMA 		      TEMP
DMSYS			           SYSAUX			        TEMP
TSMSYS			         USERS			        TEMP

9 rows selected.


--查看用户使用了哪些表空间
select distinct tablespace_name from dba_segments where owner in ('TOPICIS','XFYQ','DSJ','WLSJ');
1.1.3.3.查Role(角色)

由于没有自定义角色,所以不用生成创建角色的sql。

SELECT * FROM  DBA_ROLE_PRIVS WHERE GRANTEE IN ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS') order by grantee;

GRANTEE 		       GRANTED_ROLE		      ADM DEF
------------------------------ ------------------------------ --- ---
BACKUPKEVIN		       DBA			          NO  YES
CQTEST			       CONNECT			        YES YES
CQTEST			       DBA			            YES YES
CQTEST			       RESOURCE 		        YES YES
CQUSER			       CONNECT			        NO  YES
CQUSER			       DBA			            NO  YES
DEV			           CONNECT			        NO  YES
DEV			           DBA			            NO  YES
TEST			         CONNECT			        YES YES
TEST			         DBA			            YES YES
TESTSSS 		       CONNECT			        YES YES
TESTSSS 		       DBA			            YES YES
TSMSYS			       RESOURCE 		        NO  YES
YUNTEST 		       CONNECT			        YES YES
YUNTEST 		       DBA			            YES YES

15 rows selected.

如果有有自定义角色,生成创建角色的sql,不含系统角色

--查询用户拥有的非系统角色  
SELECT * FROM dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC');

--批量创建非系统角色
select 'create role '|| granted_role||';' from dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC');

--查询非系统角色拥有的角色
select * from dba_role_privs where grantee in  (SELECT granted_role FROM dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC'));

--批量生成非系统角色拥有的角色
select 'grant '||granted_role||' to '||grantee||';' from dba_role_privs where grantee in  (SELECT granted_role FROM dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC'));

--查看非系统角色拥有的对象权限
 select * from dba_sys_privs where grantee in  (SELECT granted_role FROM dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC'));

 --批量生成非系统角色拥有的对象权限
 select 'grant '||PRIVILEGE ||' to '||grantee||';' from dba_sys_privs where grantee in  (SELECT granted_role FROM dba_role_privs where grantee in ('ENTSERVICE') and granted_role not in ('ADM_PARALLEL_EXECUTE_TASK' ,'APEX_ADMINISTRATOR_ROLE' ,'AQ_ADMINISTRATOR_ROLE' ,'AQ_USER_ROLE' ,'AUTHENTICATEDUSER' ,'CONNECT' ,'CSW_USR_ROLE' ,'CTXAPP' ,'CWM_USER' ,'DATAPUMP_EXP_FULL_DATABASE' ,'DATAPUMP_IMP_FULL_DATABASE' ,'DBA' ,'DBFS_ROLE' ,'DELETE_CATALOG_ROLE' ,'EJBCLIENT' ,'EXECUTE_CATALOG_ROLE' ,'EXP_FULL_DATABASE' ,'GATHER_SYSTEM_STATISTICS' ,'GLOBAL_AQ_USER_ROLE' ,'HS_ADMIN_EXECUTE_ROLE' ,'HS_ADMIN_ROLE' ,'HS_ADMIN_SELECT_ROLE' ,'IMP_FULL_DATABASE' ,'JAVADEBUGPRIV' ,'JAVAIDPRIV' ,'JAVASYSPRIV' ,'JAVAUSERPRIV' ,'JAVA_ADMIN' ,'JAVA_DEPLOY' ,'JMXSERVER' ,'LOGSTDBY_ADMINISTRATOR' ,'MGMT_USER' ,'OEM_ADVISOR' ,'OEM_MONITOR' ,'OLAP_DBA' ,'OLAP_USER' ,'OLAP_XS_ADMIN' ,'ORDADMIN' ,'OWBCLIENT' ,'OWB_DESIGNCENTER_VIEW' ,'OWB_USER' ,'RECOVERY_CATALOG_OWNER' ,'RESOURCE' ,'SCHEDULER_ADMIN' ,'SELECT_CATALOG_ROLE' ,'SPATIAL_CSW_ADMIN' ,'SPATIAL_WFS_ADMIN' ,'WFS_USR_ROLE' ,'WM_ADMIN_ROLE' ,'XDBADMIN' ,'XDB_SET_INVOKER' ,'XDB_WEBSERVICES' ,'XDB_WEBSERVICES_OVER_HTTP' ,'XDB_WEBSERVICES_WITH_PUBLIC'));
1.1.3.4.查Profile(配置文件)
select username,profile from dba_users;

USERNAME		       PROFILE
------------------------------ ------------------------------
SYS			       DEFAULT
TESTSSS 		       DEFAULT
BACKUPKEVIN		       DEFAULT
YUNTEST 		       DEFAULT
DEV			       DEFAULT
CQTEST			       DEFAULT
CQUSER			       DEFAULT
TEST			       DEFAULT
SYSTEM			       DEFAULT
OUTLN			       DEFAULT
MGMT_VIEW		       DEFAULT
MDSYS			       DEFAULT
ORDSYS			       DEFAULT
EXFSYS			       DEFAULT
DMSYS			       DEFAULT
DBSNMP			       MONITORING_PROFILE
WMSYS			          DEFAULT
CTXSYS			       DEFAULT
ANONYMOUS		       DEFAULT
SYSMAN			       DEFAULT
XDB			           DEFAULT
ORDPLUGINS		       DEFAULT
SI_INFORMTN_SCHEMA	       DEFAULT
OLAPSYS 		       DEFAULT
SCOTT			         DEFAULT
TSMSYS			       DEFAULT
MDDATA			       DEFAULT
DIP			           DEFAULT

28 rows selected.
1.1.3.5.查dblink
select * from dba_db_links where username in ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS');

无返回

1.1.4.锁定业务用户

--查看用户  和现场负责人确定哪些是业务用户,哪些是需要迁的用户
set lin1000 pagesize 999
select username,default_tablespace,temporary_tablespace from dba_users where username not in ('SYS','SYSTEM','HR','OUTLN','MGMT_VIEW','FLOWS_FILES','MDSYS','ORDSYS','EXFSYS','DBSNMP','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','SCOTT','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR');

USERNAME		       DEFAULT_TABLESPACE	      TEMPORARY_TABLESPACE
------------------------------ ------------------------------ ------------------------------
BACKUPKEVIN		       USERS			      TEMP
TESTSSS 		         USERS			      TEMP
YUNTEST 		         USERS			      TEMP
CQTEST			         CQSCHEMA 		    TEMP
CQUSER			         CQSCHEMA 		    TEMP
DEV			             CQSCHEMA 		    TEMP
TEST			           CQSCHEMA 		    TEMP
DMSYS			           SYSAUX			      TEMP
TSMSYS			         USERS			      TEMP

9 rows selected.

--锁定业务用户
select username,account_status,lock_date from dba_users where username in ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS');
USERNAME		       ACCOUNT_STATUS			LOCK_DATE
------------------------------ -------------------------------- --------------
CQTEST			       OPEN
CQUSER			       OPEN
BACKUPKEVIN		     OPEN
TESTSSS 		       OPEN
DEV			           OPEN
TEST			         OPEN
YUNTEST 		       OPEN
TSMSYS			       EXPIRED & LOCKED 		02-8Ղ -22
DMSYS			         EXPIRED & LOCKED 		02-8Ղ -22

9 rows selected.


select 'alter user '||username||' account lock;' from dba_users where username in ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS') and ACCOUNT_STATU='OPEN';
执行以上输出结果

1.1.5.查看表空间及数据文件

-- 查看表空间及数据文件位置及大小
set lin 1000 pagesize 999
col file_name for a55
select tablespace_name,file_name,bytes/1024/1024/1024 gb,AUTOEXTENSIBLE from dba_data_files order by tablespace_name;
TABLESPACE_NAME 	       FILE_NAME						       GB AUT
------------------------------ ------------------------------------------------------- ---------- ---
CQSCHEMA		       /opt/oracle/oradata/cq/CQSCHEMA1.dbf		       30.4882813 YES
CQSCHEMA		       /opt/oracle/oradata/cq/CQSCHEMA4.dbf			31.171875 YES
CQSCHEMA		       /opt/oracle/oradata/cq/CQSCHEMA3.dbf		       30.8789063 YES
CQSCHEMA		       /opt/oracle/oradata/cq/CQSCHEMA2.dbf		       31.1230469 YES
CQSCHEMA		       /opt/oracle/oradata/cq/CQSCHEMA5.dbf		       30.6347656 YES
SYSAUX			       /opt/oracle/oradata/cq/sysaux01.dbf			 .5078125 YES
SYSTEM			       /opt/oracle/oradata/cq/system01.dbf		       .537109375 YES
UNDOTBS1		       /opt/oracle/oradata/cq/undotbs01.dbf		       1.12304688 YES
USERS			         /opt/oracle/oradata/cq/users01.dbf		       .434570313 YES

9 rows selected.

--查看临时表空间及临时表空间数据文件位置及大小
set lin 1000 
col FILE_NAME for a60
select TABLESPACE_NAME,FILE_NAME,BYTES/1024/1024/1024 total_gb,USER_BYTES/1021/1024/1024 gb from dba_temp_files;

TABLESPACE_NAME 	       FILE_NAME						      TOTAL_GB	       GB
------------------------------ ------------------------------------------------------------ ---------- ----------
TEMP			       /opt/oracle/oradata/cq/temp01.dbf			    2.67285156 2.67972576

--查看控制文件位置
SQL> show parameter control

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time	     integer	 7
control_files			     string	 /opt/oracle/oradata/cq/control
						                   01.ctl, /opt/oracle/oradata/cq
						                   /control02.ctl, /opt/oracle/or
						                   adata/cq/control03.ctl


--查看redo log大小和位置
set linesize 999
col member for a60
select b.thread#,a.group#,a.member,bytes/1024/1024,b.members,b.status from v$logfile a,v$log b where a.group#=b.group#;	

   THREAD#     GROUP# MEMBER							   BYTES/1024/1024    MEMBERS STATUS
---------- ---------- ------------------------------------------------------------ --------------- ---------- ----------------
	 1	    3 /opt/oracle/oradata/cq/redo03.log 					50	    1 INACTIVE
	 1	    2 /opt/oracle/oradata/cq/redo02.log 					50	    1 CURRENT
	 1	    1 /opt/oracle/oradata/cq/redo01.log 					50	    1 INACTIVE

1.1.6..查业务数据

--每个业务用户下的总对象数量校验
SELECT D.OWNER,COUNT(1)
  FROM dba_objects d
 WHERE d.OWNER   in ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS')
 AND NOT EXISTS (SELECT 1 FROM DBA_RECYCLEBIN B WHERE B.object_name=D.OBJECT_NAME AND D.OWNER=B.owner) 
 GROUP BY D.OWNER
 ORDER BY D.OWNER ;
OWNER				 COUNT(1)
------------------------------ ----------
CQTEST				      407
CQUSER				      109
DEV				          458
DMSYS				        189
TEST				        326
TESTSSS 			       36
TSMSYS					     3
YUNTEST 			      452

8 rows selected.


--每个业务用户下的各个对象类别的数量校验
set pagesize 999
select OWNER,OBJECT_TYPE,status,count(OBJECT_NAME) from dba_objects  where owner in ('BACKUPKEVIN' ,'TESTSSS' ,'YUNTEST' ,'CQTEST' ,'CQUSER' ,'DEV' ,'TEST' ,'DMSYS' ,'TSMSYS')  group by OBJECT_TYPE,owner,status order by 1,3,2;

OWNER			       OBJECT_TYPE	   STATUS  COUNT(OBJECT_NAME)
------------------------------ ------------------- ------- ------------------
CQTEST			       INDEX		   VALID		  161
CQTEST			       LOB		     VALID		  156
CQTEST			       TABLE		   VALID		   90
CQUSER			       INDEX		   VALID		   51
CQUSER			       LOB		     VALID		   11
CQUSER			       TABLE		   VALID		   47
DEV			           INDEX		   VALID		  179
DEV			           LOB		     VALID		  162
DEV			           PROCEDURE	 VALID		    4
DEV			           TABLE		   VALID		  103
DEV			           VIEW		     VALID		   10
DMSYS			         FUNCTION 	   VALID		   12
DMSYS			         INDEX		   VALID		    2
DMSYS			         LIBRARY		   VALID		    6
DMSYS			         PACKAGE		   VALID		   27
DMSYS			         PACKAGE BODY	   VALID		   23
DMSYS			         PROGRAM		   VALID		    9
DMSYS			         SEQUENCE 	   VALID		    1
DMSYS			         TABLE		   VALID		    2
DMSYS			         TYPE		   VALID		   94
DMSYS			         TYPE BODY	   VALID		   12
DMSYS			         VIEW		   VALID		    1
TEST			         INDEX		   VALID		  137
TEST			         LOB		   VALID		  110
TEST			         TABLE		   VALID		   79
TESTSSS 		       INDEX		   VALID		   20
TESTSSS 		       LOB		   VALID		    5
TESTSSS 		       TABLE		   VALID		   11
TSMSYS			       INDEX		   VALID		    1
TSMSYS			       LOB		   VALID		    1
TSMSYS			       TABLE		   VALID		    1
YUNTEST 		       INDEX		   VALID		  172
YUNTEST 		       LOB		   VALID		  175
YUNTEST 		       PROCEDURE	   VALID		    4
YUNTEST 		       TABLE		   VALID		   97
YUNTEST 		       VIEW		   VALID		    4

36 rows selected.


--查询回收站lob对象数量(可选),lob数量不一致排查
select owner,type,count(*) from dba_recyclebin group by owner,type order by owner;
无返回

--数据量统计
----新增count_rows 函数
CREATE OR REPLACE FUNCTION count_rows (
	table_name IN varchar2, 
	owner IN varchar2 := NULL
)
RETURN number AUTHID current_user
AS
num_rows number;
	stmt varchar2(2000);
BEGIN
	IF owner IS NULL THEN
		stmt := 'select count(*) from "' || table_name || '"';
	ELSE
		stmt := 'select count(*) from "' || owner || '"."' || table_name || '"';
	END IF;
	EXECUTE IMMEDIATE stmt INTO num_rows;
	RETURN num_rows;
END;
/
---调用count_rows 函数,统计各种表的记录数
select table_name, count_rows(table_name) nrows from user_tables  where tablespace_name='ENTSERVICE'
order by nrows desc;

1.2.查看新库信息

1.2.1.查看服务器配置

确保新服务器配置等于或高于旧服务器。

1.2.2.1.查看操作系统版本
[root@ecs-677a ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
1.2.2.2.查看磁盘空间
[root@ecs-677a ~]#  df -Th
Filesystem           Type   Size  Used Avail Use% Mounted on
/dev/vda1            ext4    40G  1.6G   36G   5% /
tmpfs                tmpfs  3.9G     0  3.9G   0% /dev/shm
/dev/mapper/data-data01
                     ext4   689G   69M  654G   1% /data
1.2.2.3.cpu配置
[root@ecs-677a ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel(R) Xeon(R) Gold 6161 CPU @ 2.20GHz
Stepping:              4
CPU MHz:               2200.000
BogoMIPS:              4400.00
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              1024K
L3 cache:              30976K
NUMA node0 CPU(s):     0-3
1.2.2.4.内存配置
[root@cq ~]# awk '/MemTotal/{print $2}' /proc/meminfo  K
8060540   --单位

或 

[root@cq ~]# free -g
[root@ecs-677a ~]# free -g
             total       used       free     shared    buffers     cached
Mem:             7          0          7          0          0          0
-/+ buffers/cache:          0          7
Swap:            0          0          0
1.2.2.5.磁盘IO测速
1.2.2.5.1.创建存放测速文件的目录
--创建存放测速文件的目录
[root@ecs-677a ~]# ls -ld /ddtest  --确定不存在该目录
[root@ecs-677a ~]# mkdir -p /ddtest
[root@ecs-677a ~]# cd /ddtest
[root@ecs-677a ddtest]# ls -l
total 0
1.2.2.5.2.测试纯写入性能
--测试纯写入性能  连续执行3次取平均值
[root@ecs-677a ddtest]# dd if=/dev/zero of=test bs=4G count=1 oflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 18.0524 s, 119 MB/s
[root@ecs-677a ddtest]# dd if=/dev/zero of=test01 bs=4G count=1 oflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 17.8508 s, 120 MB/s
[root@ecs-677a ddtest]# dd if=/dev/zero of=test02 bs=4G count=1 oflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 17.7979 s, 121 MB/s
1.2.2.5.3.测试纯读取性能
--测试纯读取性能 连续执行3次取平均值
[root@ecs-677a ddtest]# dd if=test of=/dev/null bs=4G count=1 iflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 16.1827 s, 133 MB/s
[root@ecs-677a ddtest]# dd if=test01 of=/dev/null bs=4G count=1 iflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 16.5974 s, 129 MB/s
[root@ecs-677a ddtest]# dd if=test02 of=/dev/null bs=4G count=1 iflag=direct
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 16.7011 s, 129 MB/s

1.3.新服务器配置

1.3.1.配置主机名

--查看主机名
[root@ecs-677a ddtest]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=ecs-677a
RES_OPTIONS='timeout:1 single-request-reopen'

--配置主机名
/bin/hostname cqnew
sysctl kernel.hostname="cqnew"
echo "cqnew" >/proc/sys/kernel/hostname
sed -i "s/^HOSTNAME=.*/HOSTNAME=cqnew/" /etc/sysconfig/network

--查看主机名
hostname

1.3.2.配置/etc/hosts

如果是弹性云服务器不能配置为对外访问的ip 120.46.146.123 需配置成实际网卡的ip,不然后面监听启动报错。

--查看ip地址
[oracle@cqnew admin]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether fa:16:3e:5d:b5:d8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.35/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::f816:3eff:fe5d:b5d8/64 scope link
       valid_lft forever preferred_lft forever
       
--配置/etc/hosts
[root@ecs-677a ddtest]# vi /etc/hosts
::1	localhost	localhost.localdomain	localhost6	localhost6.localdomain6
127.0.0.1	localhost	localhost.localdomain	localhost4	localhost4.localdomain4
#127.0.0.1	ecs-677a	ecs-677a
192.168.0.35 cqnew  

1.3.3.设置系统服务 

禁用一些不必要的系统服务

--Linux/Centos 6.10环境下
chkconfig iptables off
chkconfig ip6tables off
chkconfig postfix off

Linux/Centos 6.5 采用以下

chkconfig iptables off
chkconfig ip6tables off
chkconfig cups off
chkconfig firstboot off
chkconfig wpa_supplicant off
chkconfig postfix off

1.3.4.禁用透明大页

--临时禁用
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

--加入开机启动
echo '
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag' >>/etc/rc.local
chmod +x /etc/rc.local

--检查是否关闭透明大页的命令
grep Huge /proc/meminfo

1.3.5.关闭numa

注意Centos6和Centos7的配置不一样。

--检查检查OS是否开启NUMA
# numactl --hardware     检查 numa 节点信息

available: 1 nodes (0)       #如果是2或多个nodes就说明numa没关掉

--关闭 numa
numastat  #查看

vi /etc/grub.conf  设置 numa=off

查看每个节点的分配情况

【1】numastat  【2】numactl --show

然后重启生效,reboot

注意:numa=off 要写在内核后

1.3.5.用在线安装方式常用软件及必需软件 

安装kernel-devel和kernel-headers,并且在更新系统时,禁止更新kernel

yum -y install kernel-devel kernel-headers && echo exclude=kernel*

更新yum

yum -y update

安装常用软件

yum -y install autoconf automake binutils-devel bison cpp dos2unix ftp gcc gcc-c++ lrzsz python-devel

安装Oracle必需软件

yum -y install compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-33 glibc-* glibc-*.i686 libXpm-*.i686 libXp.so.6 libXt.so.6 libXtst.so.6 libgcc_s.so.1 ksh libXp libaio-devel numactl numactl-devel unixODBC unixODBC-devel

注:安装完成以上软件后,重启系统。

1.3.6.检查或配置交换空间

若swap>=2G,跳过该步骤,

若swap=0,则执行以下操作

--检查内存配置
[root@cqnew install]# free -g
             total       used       free     shared    buffers     cached
Mem:             7          7          0          0          0          6
-/+ buffers/cache:          0          7
Swap:            0          0          0

--创建指定大小的空文件 /swapfile,并将其格式化为交换分区
dd if=/dev/zero of=/data/swapfile bs=2G count=8

--设置文件权限为 0600
chmod 600 /data/swapfile

--格式化文件为 Swap 分区
mkswap /data/swapfile

--启用 Swap 分区
swapon /data/swapfile

--将 Swap 分区信息添加到 /etc/fstab 文件中,以便系统重启后自动加载
cp /etc/fstab /etc/fstab_bak_20240511
echo "/data/swapfile none swap sw 0 0" >> /etc/fstab

--手动挂载所有磁盘
mount -a

--查看内存  已经有swap了
[root@cqnew install]# free -g
             total       used       free     shared    buffers     cached
Mem:             7          5          2          0          0          5
-/+ buffers/cache:          0          7
Swap:           15          0         15

1.3.7.创建Oracle相关用户和目录

--创建oracle组及用户
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

--创建安装目录
mkdir -p /data/app/oracle
mkdir -p /data/app/oracle/oraInventory
mkdir -p /data/app/oracle/product/10.2.0.1/dbhome_1
chown -R oracle.oinstall /data/app/oracle/
chmod -R 755 /data/app/oracle/

--创建数据目录
mkdir -p /data/oracle/oradata/cq
chown -R oracle.oinstall /data/oracle/oradata/cq
chmod -R 755 /data/oracle/oradata/cq

1.3.8.修改内核参数

-物理内存(KB)
os_memory_total=$(awk '/MemTotal/{print $2}' /proc/meminfo)

--获取系统页面大小,用于计算内存总量
pagesize=$(getconf PAGE_SIZE)

min_free_kbytes = $os_memory_total / 250

shmall = ($os_memory_total - 1) * 1024 / $pagesize

shmmax = $os_memory_total * 1024 - 1

  # 如果 shmall 小于 2097152,则将其设为 2097152
  (($shmall < 2097152)) && shmall=2097152
  # 如果 shmmax 小于 4294967295,则将其设为 4294967295
  (($shmmax < 4294967295)) && shmmax=4294967295

  
$shmall
$shmmax
$min_free_kbytes
$local_ifname
[root@cqnew ~]# cp /etc/sysctl.conf /etc/sysctl.conf_bak_20240511
[root@cqnew ~]# cat /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter = 0
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_announce=2
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 2015134
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=262144
fs.aio-max-nr = 1048576
vm.swappiness=0
net.core.somaxconn=1024
net.ipv4.tcp_max_tw_buckets=5000
net.ipv4.tcp_max_syn_backlog=1024
net.ipv4.neigh.default.gc_stale_time=120

--使设置生效
sysctl -p

1.3.9.配置图形化界面

如果不配置,后面安装过程中调用图形化界面会报错:

yum groupinstall -y "X Window System"
yum groupinstall -y "Desktop"
yum groupinstall -y "Chinese Support"

如果是Centos7

yum groupinstall "GNOMEDesktop" -y
yum groupinstall -y "X Window System"

1.3.10.Oracle用户设置Shell限制 

编辑/etc/security/limits.conf
cp /etc/security/limits.conf /etc/security/limits.conf_bak_20240511
vim /etc/security/limits.conf 
//最后添加如下参数
#add by oracle
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft memlock 6542450944
oracle hard memlock 6542450944
编辑/etc/pam.d/login
cp /etc/pam.d/login /etc/pam.d/login_bak_20240511

vim /etc/pam.d/login 
最后添加如下参数
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
编辑/etc/profile
cp /etc/profile /etc/profile_bak_20240511
vim /etc/profile
最后添加如下内容:
#add by oracle
if [ root = "oracle" ]; then
   if [ /bin/bash = "/bin/ksh" ]; then
      ulimit -p 16384
      ulimit -n 65536
      else
      ulimit -u 16384 -n 65536
   fi
fi

source /etc/profile
编辑/etc/csh.login
cp /etc/csh.login /etc/csh.login_bak_20240511
vim /etc/csh.login
最后添加如下内容:
#add by oracle
if ( $USER == "oracle") then
    limit maxproc 16384
    limit descriptors 65536
endif
编辑/home/oracle/.bash_profile
cp /home/oracle/.bash_profile /home/oracle/.bash_profile_bak_20240511
vim /home/oracle/.bash_profile
最后添加如下内容:
#add by oracle
umask 022
export LANG=en_US.UTF-8
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=/data/app/oracle/product/10.2.0.1/dbhome_1
export ORACLE_HOSTNAME=Centos3
export ORACLE_SID=cqnew
export NLS_LANG="SIMPLIFIED CHINESE_CHINA".ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin

1.3.10.上传Oracle安装包上传至服务器并解压

将Oracle服务端10201_database_linux_x86_64.cpio.gz安装包上传至服务器,保存在/data目录下面。

在/data目录下面会生成一个名为database的目录。

cd /data
[root@cqnew data]# ls -l
total 740684
-rw-r--r-- 1 oracle oinstall 758433170 May 11 10:21 10201_database_linux_x86_64.cpio.gz

--解压安装包
cd /data
[root@cqnew data]# zcat 10201_database_linux_x86_64.cpio.gz | cpio -idmv > /dev/null 2>&1
[root@cqnew data]# ls -l
total 740684
-rw-r--r-- 1 oracle oinstall 758433170 May 11 10:21 10201_database_linux_x86_64.cpio.gz
drwxr-xr-x 6  94110    42424      4096 Oct 23  2005 database

--赋予权限
[root@cqnew data]# chown -R oracle:oinstall database/

[root@cqnew data]# ls -l
total 740684
-rw-r--r-- 1 oracle oinstall 758433170 May 11 10:21 10201_database_linux_x86_64.cpio.gz
drwxr-xr-x 6 oracle oinstall      4096 Oct 23  2005 database

以上步骤完成后,重启服务器验证下重启正常。

二.安装过程

2.1.更改参数文件

--解压安装包
su - oracle
cd /data
zcat 10201_database_linux_x86_64.cpio.gz | cpio -idmv > /dev/null 2>&1

在/data目录下面会生成一个名为database的目录,进入database目录。 

编辑install目录下面的oraparam.ini文件,在“Certified Versions”的项目中添加“redhat-6”。

su - oracle
cd /data/database/install/
cp oraparam.ini oraparam.ini_bak_20240511
vim oraparam.ini
[Certified Versions]
Linux=redhat-6,redhat-3,SuSE-9,redhat-4,UnitedLinux-1.0,asianux-1,asianux-2

2.2.开始安装

2.2.1.安装数据库软件

su - oracle
export DISPLAY=192.168.16.122:0.0
cd /data/database/
export LANG=en_US.UTF-8
./runInstaller
选择高级安装

选择高级安装“Advanced Installation”,然后Next:

指定产品清单目录和身份证明

指定产品清单目录和身份证明,默认即可:

选择安装类型

选择安装类型,这里选择企业版“Enterprise Edition”,点击“Product Language”按钮可以进行产品语言的选择:

指定安装主目录

指定安装主目录的详细信息,这里默认即可,点击Next:

产品特定的先决条件检查

产品特定的先决条件检查(注:一般会出现warning),默认即可,点击Next:

出现如下的Warning窗口,点击“Yes”继续:

只安装数据库软件

安装过程中会有报错画面,直接“Continue”即可

执行脚本

执行以下脚本后点ok,继续

/data/app/oracle/oraInventory/orainstRoot.sh
/data/app/oracle/product/10.2.0.1/dbhome_1/root.sh

脚本执行详细过程:

[root@cqnew bin]# /data/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /data/app/oracle/oraInventory to 770.
Changing groupname of /data/app/oracle/oraInventory to oinstall.
The execution of the script is complete


[root@cqnew bin]# /data/app/oracle/product/10.2.0.1/dbhome_1/root.sh
Running Oracle10 root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /data/app/oracle/product/10.2.0.1/dbhome_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.

安装完成,退出安装。

问题处理
调用图形化失败

如果调用图形化失败,执行下面进行配置图形化界面操作

如果不配置,后面安装过程中调用图形化界面会报错:

yum groupinstall -y "X Window System"
yum groupinstall -y "Desktop"
yum groupinstall -y "Chinese Support"

如果是Centos7

yum groupinstall "GNOMEDesktop" -y
yum groupinstall -y "X Window System"
图形化界面乱码
echo $LANG
export LANG=en_US.UTF-8

2.2.2.创建监听

监听日志:

配置文件路径:/data/app/oracle/product/10.2.0.1/dbhome_1/network/admin

日志文件路径:/data/app/oracle/product/10.2.0.1/dbhome_1/network/log/listener.log

/data/app/oracle/product/10.2.0.1/dbhome_1/network/trace

查看监听文件

--查看ip地址
[oracle@cqnew admin]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether fa:16:3e:5d:b5:d8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.35/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::f816:3eff:fe5d:b5d8/64 scope link
       valid_lft forever preferred_lft forever

--查看监听文件内容
[oracle@cqnew admin]$ cat /data/app/oracle/product/10.2.0.1/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /data/app/oracle/product/10.2.0.1/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /data/app/oracle/product/10.2.0.1/dbhome_1)
      (PROGRAM = extproc)
    )
     (SID_DESC =
      (GLOBAL_DBNAME = cq)
      (ORACLE_HOME = /data/app/oracle/product/10.2.0.1/dbhome_1)
      (SID_NAME = cq)
     )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = cqnew)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

注意事项:如果是弹性云服务器,HOST = ip的场景下,ip应该为实际网卡的ip地址,而不是对外访问的ip地址,不然后面监听启动报错。

问题处理
创建监听最后一步没反应

反应慢导致

--问题描述
[oracle@cqnew database]$ netca

Oracle Net Services Configuration:
Warning: Cannot convert string "-b&h-lucida-medium-r-normal-sans-*-140-*-*-p-*-iso8859-1" to type FontStruct
Configuring Listener:LISTENER

--问题处理
该报错不影响监听和数据库的创建
监听启动失败
--问题描述
[oracle@cqnew admin]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-5Ղ -2024 13:51:51

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /data/app/oracle/product/10.2.0.1/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /data/app/oracle/product/10.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /data/app/oracle/product/10.2.0.1/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=120.46.146.123)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
 TNS-12560: TNS:protocol adapter error
  TNS-00515: Connect failed because target host or object does not exist
   Linux Error: 99: Cannot assign requested address

Listener failed to start. See the error message(s) above...

问题原因
服务器为华为云服务器,120.46.146.123是对外访问ip,实例的网卡ip为192.168.0.35

--解决办法
更改/etc/hosts将120.46.146.123更改为192.168.0.35

更改/data/app/oracle/product/10.2.0.1/dbhome_1/network/admin/listener.ora中host为192.168.0.35或者保持主机名

手动删除/data/app/oracle/product/10.2.0.1/dbhome_1/network/admin/目录下的listener.ora和tnsnames.ora配置文件
重新netca添加
查看监听状态正常

2.2.3.创建数据库实例

[oracle@cqnew]$cd /data/database
[oracle@cqnew database]$ dbca

问题处理

创建数据库实例最后一步finish点击无反应

安装日志位置:安装日志/oraInventory/logs

--问题描述
[oracle@cqnew]$cd /data/app/oracle/oraInventory/logs
[oracle@cqnew logs]$ cat oraInstall2024-05-14_10-53-26AM.err
java.lang.NullPointerException
	at oracle.sysman.oii.oiin.OiinNetOps.addNICInfo(OiinNetOps.java:143)
	at oracle.sysman.oii.oiin.OiinNetOps.computeNICList(OiinNetOps.java:108)
	at oracle.sysman.oii.oiin.OiinNetOps.<init>(OiinNetOps.java:75)
	at oracle.sysman.oii.oiin.OiinNetOps.getNetOps(OiinNetOps.java:89)
	at oracle.sysman.oii.oiif.oiifw.OiifwHostNameWCDE.initialize(OiifwHostNameWCDE.java:111)
	at oracle.sysman.oii.oiif.oiifb.OiifbCondIterator.iterate(OiifbCondIterator.java:152)
	at oracle.sysman.oii.oiic.OiicDepWizEngine.doOperation(OiicDepWizEngine.java:424)
	at oracle.sysman.oii.oiif.oiifb.OiifbCondIterator.iterate(OiifbCondIterator.java:171)
	at oracle.sysman.oii.oiic.OiicPullSession.doOperation(OiicPullSession.java:1273)
	at oracle.sysman.oii.oiic.OiicSessionWrapper.doOperation(OiicSessionWrapper.java:289)
	at oracle.sysman.oii.oiic.OiicInstaller.run(OiicInstaller.java:546)
	at oracle.sysman.oii.oiic.OiicInstaller.runInstaller(OiicInstaller.java:929)
	at oracle.sysman.oio.oioc.OiocOneClickInstaller.runInstaller(OiocOneClickInstaller.java:1925)
	at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(OiocOneClickInstaller.java:2149)

--解决办法
监听未配置,$ORACLE_HOME/network/admin/无listener.ora文件

注意安装顺序:数据库软件--监听--实例

若有疑问,可关注公众号解惑哈

参考链接:

https://blog.51cto.com/u_11233498/4720527

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1676862.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【MATLAB】Enigma机加密原理与自实现

文章目录 什么是EnigmaEnigma机加密通信流程Enigma的物理构造Enigma的加密设置Enigma加密通信密码重新设置Enigma加密消息拼接注意 Enigma的解密分解设置Enigma解密通信密码重新设置Enigma解密消息 Enigma的弱点MATLAB自实现Enigma加密与解密Enigma_functionRotate_functiontes…

排序(一)----冒泡排序,插入排序

前言 今天讲一些简单的排序,冒泡排序和插入排序,但是这两个排序时间复杂度较大,只是起到一定的学习作用,只需要了解并会使用就行,本文章是以升序为例子来介绍的 一冒泡排序 思路 冒泡排序是一种简单的排序算法&#xff0c;它重复地遍历要排序的序列&#xff0c;每次比较相邻…

K8S内容

K8S介绍 1、故障迁移:当某一个node节点关机或挂掉后&#xff0c;node节点上的服务会自动转移到另一个node节点上&#xff0c;这个过程所有服务不中断。这是docker或普通云主机是不能做到的 2、资源调度:当node节点上的cpu、内存不够用的时候&#xff0c;可以扩充node节点&…

详细分清Session,Cookie和Token之间的区别,以及JWT是什么东西

Cookie Cookie是一种小型的文本文件&#xff0c;由网站在用户访问时存储在其计算机或移动设备上&#xff0c;Cookie主要用于跟踪、识别和存储有关用户的信息。 简单来说Cookie就是用来存储某些后端发送给前端的数据&#xff0c;例如我们登陆后&#xff0c;后端会返回一个登录…

求正方形阴影部分面积

正方形边长6&#xff0c;求阴影部分面积 xy6① vw6② 1/26v1/23x1/263③ 1/26v1/26y1/266④ ③是左下角三角形的面积&#xff0c;④是左上角三角形的面积。 求解方程组得到x2 阴影部分面积1/2*3x3.

海豚调度器如何看工作流是在哪个worker节点执行

用海豚调度器&#xff0c;执行一个工作流时&#xff0c;有时成功&#xff0c;有时失败&#xff0c;怀疑跟worker节点环境配置不一样有关。要怎样看是在哪个worker节点执行&#xff0c;在 海豚调度器 Web UI 中&#xff0c;您可以查看任务实例&#xff0c;里面有一列显示host&a…

网络安全快速入门(九)MySQL进阶操作

上一章我们了解了对表及库的基本增删查改操作&#xff0c;本章我们针对增删查改内容进行与一些拓展&#xff0c; 9.1字段修饰及数据类型 我们之前在创建表时用到的格式为&#xff1a; create table 表名 ( 字段名1 字段数据类型&#xff08;数据类型长度&#xff09;, 字段名2 …

刷代码随想录有感(65):回溯算法——组合问题

题干&#xff1a; 代码&#xff1a; class Solution { public:vector<vector<int>> res;vector<int> tmp;void backtracking(int n, int k, int start){if(tmp.size() k){res.push_back(tmp);return;}for(int i start; i < n; i){tmp.push_back(i);bac…

[Algorithm][回溯][组合][目标和][组合总和]详细讲解

目录 1.组合1.题目链接2.算法原理详解3.代码实现 2.目标和1.题目链接2.算法原理详解3.代码实现 3.组合总和1.题目链接2.算法原理详解3.代码实现 1.组合 1.题目链接 组合 2.算法原理详解 思路&#xff1a;每次都只选一个数&#xff0c;此后只能选它后面的数函数设计&#xff…

全面提升数据采集效率:亮数据产品的应用与评估详解

全面提升数据采集效率&#xff1a;亮数据产品的应用与评估详解 文章目录 全面提升数据采集效率&#xff1a;亮数据产品的应用与评估详解背景应用场景&#xff1a;平台首页信息抓取准备评测素材详细的产品使用和评测流程产品介绍亮数据的IP代理服务亮数据的爬虫工具及采集技术 注…

elasticsearch使用Ngram实现任意位数手机号搜索

文章目录 Ngram自定义分词案例实战问题拆解 Ngram分词器定义Ngram分词定义Ngram分词示例Ngram分词应用场景 Ngram分词实战 Ngram自定义分词案例 当对keyword类型的字段进行高亮查询时&#xff0c;若值为123asd456&#xff0c;查询sd4&#xff0c;则高亮结果是&#xff1c;em&a…

项目管理-案例重点知识(整合管理)

项目管理&#xff1a;每天进步一点点~ 活到老&#xff0c;学到老 ヾ(◍∇◍)&#xff89;&#xff9e; 何时学习都不晚&#xff0c;加油 一、整合管理 案例重点 重点内容&#xff1a; &#xff08;1&#xff09;项目章程内容和作用 &#xff08;2&#xff09;项目管理计划…

乡村振兴的农业科技创新:加大农业科技投入,推广农业科技成果,提升农业科技创新水平,推动美丽乡村农业现代化

一、引言 随着全球化和信息化时代的到来&#xff0c;农业作为国民经济的基础&#xff0c;其现代化进程日益受到关注。在乡村振兴战略的大背景下&#xff0c;农业科技创新成为推动乡村经济转型升级、实现农业现代化的关键力量。本文旨在探讨如何通过加大农业科技投入、推广农业…

【PB案例学习笔记】-02 目录浏览器

写在前面 这是PB案例学习笔记系列文章的第二篇&#xff0c;该系列文章适合具有一定PB基础的读者&#xff0c; 通过一个个由浅入深的编程实战案例学习&#xff0c;提高编程技巧&#xff0c;以保证小伙伴们能应付公司的各种开发需求。 文章中设计到的源码&#xff0c;小凡都上…

蓝桥杯单片机之模块代码《串口发数据》

过往历程 历程1&#xff1a;秒表 历程2&#xff1a;按键显示时钟 历程3&#xff1a;列矩阵按键显示时钟 历程4&#xff1a;行矩阵按键显示时钟 历程5&#xff1a;新DS1302 历程6&#xff1a;小数点精确后两位ds18b20 历程7&#xff1a;35定时器测量频率 历程8&#xff…

初识鸿蒙之ArkTS基础

前言 学习一种应用程序开发&#xff0c;需要从这种程序的开发语言开始&#xff0c;比如说Android开发从入门到放弃&#xff0c;肯定是从Java基础或者是Kotlin语言基础开始学习的&#xff0c;IOS程序开发也肯定是从object-c开始学习的。鸿蒙软件开发也不例外&#xff0c;如果做…

平衡三进制小数详解与进制转换

标准三进制是“逢三进一&#xff0c;退一还三”的机制&#xff0c;平衡三进制与之类似&#xff0c;但就是偏移了一下变得对称了&#xff0c;平衡三进制与标准三进制可以相互转换&#xff0c;但这样显得有点多余了&#xff0c;所以这里只讲平衡三进制与十进制的转换。 数字系统的…

meshlab: pymeshlab合并多个物体模型并保存(flatten visible layers)

一、关于环境 请参考&#xff1a;pymeshlab遍历文件夹中模型、缩放并导出指定格式-CSDN博客 二、关于代码 本文所给出代码仅为参考&#xff0c;禁止转载和引用&#xff0c;仅供个人学习。 本文所给出的例子是https://download.csdn.net/download/weixin_42605076/89233917中的…

【微记录】dmidecode是干什么的?常用来做什么?如何查看系统支持的PCIe版本号(本质:标准,Desktop Management Interface)

是什么 dmidecode 是一个在 Linux 系统提取硬件信息的命令行工具。DMI 代表桌面管理接口&#xff08;Desktop Management Interface&#xff09;&#xff0c;是一种标准&#xff0c;收集桌面计算机的硬件信息&#xff0c;包括系统制造商、序列号、BIOS 信息、系统资产标签等。…

风电功率预测 | 基于PSO-BP神经网络实现风电功率预测(附matlab完整源码)

风电功率预测 风电功率预测完整代码风电功率预测 基于粒子群优化算法(Particle Swarm Optimization, PSO)的BP神经网络是一种常见的方法,用于实现风电功率预测。下面是一个基于PSO-BP神经网络实现风电功率预测的一般步骤: 数据准备:收集与风电场发电功率相关的数据,包括…