首页 > 数据库 >Centos7.8静默安装企业版Oracle11g和创建实例

Centos7.8静默安装企业版Oracle11g和创建实例

时间:2024-11-07 11:10:32浏览次数:1  
标签:name db Centos7.8 实例 install oracle config Oracle11g u01

1、安装环境准备:

A、系统版本和oracle11g企业版安装软件压缩包:

[root@dbprimary07 ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[root@dbprimary07 ~]# uname -a
Linux dbprimary07 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
 
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

B、 HostName修改

hostnamectl set-hostname dbprimary07

C、关闭selinux

sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

重启系统reboot

D 、配置内核参数

[root@dbprimary07 ~]# cat /etc/sysctl.conf 
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 7516192768 #7Gkernel.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

修改后使之生效

/sbin/sysctl -p

E、修改用户权限

root用户

vim  /etc/security/limits.conf
#在末尾添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 10240

F、在/etc/pam.d/login 文件中,使用文本编辑器或vi命令增加或修改以下内容

session required /lib64/security/pam_limits.so
session required pam_limits.so

G、在/etc/profile 文件中,使用文本编辑器或vi命令增加或修改以下内容

if [ $USER = "oracle" ]; then
   if [ $SHELL = "/bin/ksh" ]; then
       ulimit -p 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
   fi
fi

#使之生效:
source /etc/profile

2 安装oracle11g-EE版本主要步骤

2.1创建oracle用户,及用户组
2.2配置oracle用户环境变量
2.3修改安装Oracle软件的响应文件db_install.rsp,静默安装
2.4静默dbca建库,编辑应答文件dbca.rsp
2.5 登陆数据库,测试是否安装成功
2.6 rlwrap安装

具体步骤如下:

2.1创建oracle用户,及用户组

#创建oinstall和dba组

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba

#创建Oracle用户:-d /u01/oracle,将用户创建到/u01下,默认是在/home下

useradd -g oinstall -G dba oracle -d /u01/oracle

#设置oracle密码

passwd oracle

#验证创建及所属组是否正确:id oracle
#输出结果如下

uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

2.2配置oracle用户环境变量

su - oracle
vim ~/.bash_profile 
##提示要是不存在/u01/oracle/.bash_profile 文件,可以创建一个系统用户test001,把他的家目录下的隐藏文件复制到/u01/oracle/目录下
[root@dbprimary07 ~]# useradd test001
[root@dbprimary07 ~]# cp /home/test001/.* /u01/oracle/

然后再
su - oracle
vim ~/.bash_profile 
#添加如下内容,注意修改的是oracle用户的环境变量,su - oracle切换用户
export ORACLE_BASE=/u01/oracle/tools/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin/:$ORACLE_HOME/lib64

#使配置生效
source ~/.bash_profile

2.3修改安装Oracle软件的响应文件db_install.rsp,静默安装

su - oracle 
创建响应文件配置目录
mkdir  -p /u01/oracle/etc  

创建oracle安装目录
mkdir  -p  /u01/oracle/tools/oracle11g 
mkdir -p  /u01/oracle/tools/oraInventory
mkdir -p /u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1 
mkdir -p /u01/oracle/tools/oracle11g/oradata 
mkdir -p /u01/oracle/tools/oracle11g/fast_recovery_area

#将下载的压缩文件解压到/u01/oracle目录下,解压完成后/u01/oracle目录下会生成一个database目录
unzip linux.x64_11gR2_database_1of2.zip -d /u01/oracle 
unzip linux.x64_11gR2_database_2of2.zip -d /u01/oracle 

#将/u01/oracle/database/response下dbca.rsp,db_install.rsp,netca.rsp的文件拷贝到/u01/oracle/etc下
cp /u01/oracle/database/response/*  /u01/oracle/etc

#编辑/u01/oracle/etc下的db_install.rsp文件(注意要用oracle用户编辑)
vi /u01/oracle/etc/db_install.rsp

在db_install.rsp中找到要修改的配置

db_install.rsp中配置文件参数如下:

[oracle@dbprimary07 ~]$ cat /u01/oracle/etc/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/oracle/tools/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1 
ORACLE_BASE=/u01/oracle/tools/oracle11g 
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/oracle/tools/oracle11g/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/oracle/tools/oracle11g/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES= true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
[oracle@dbprimary07 ~]$ 

#用db_install.rsp文件开始静默安装oracle软件

su - oracle 
cd /u01/oracle/database
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile  /u01/oracle/etc/db_install.rsp

#安装完成,提示Successfully Setup Software.如下:

==========================================================
/u01/oracle/tools/oraInventory/orainstRoot.sh
/u01/oracle/tools/oracle/oracle11g/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.
==========================================================

#退出oracle 用户,用root用户执行脚本。安装完后会在Successfully Setup Software上方出现执行脚本路径

exit
sh /u01/oracle/tools/oraInventory/orainstRoot.sh
sh /u01/oracle/tools/oracle/oracle11g/product/11.2.0/db_1/root.sh

2.4静默dbca建库,编辑应答文件dbca.rsp

##应答文件dbca.rsp参数如下:

[oracle@dbprimary07 ~]$ cat /u01/oracle/etc/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"

# 执行:

$ORACLE_HOME/bin/dbca -silent -responseFile /u01/oracle/etc/dbca.rsp

[oracle@dbprimary07 ~]$ $ORACLE_HOME/bin/dbca -silent -responseFile /u01/oracle/etc/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
18% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/oracle/tools/oracle11g/cfgtoollogs/dbca/orcl/orcl1.log" for further details.

#若实例创建错误,删除实例命令

$ORACLE_HOME/bin/dbca -silent -deleteDatabase -sourcedb orcl

#设置Oracle开机启动

vi /etc/oratab

orcl:/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1:Y  # //把“N”改成“Y”

2.5.登陆数据库

su - oracle
sqlplus / as sysdba
或者下面 
sqlplus system/oracle as sysdba
sqlplus sys/oracle as sysdba
#system代表系统账户
#oracle代表密码

# 启动oracle实例
SQL> startup
不挂载启动oracle实例
SQL> startup nomount;
# 关闭oracle实例
SQL> shutdown immediate;

2.6 rlwrap安装

#安装过程如下:

yum install ncurses-devel readline-devel  -y
tar -zxvf rlwrap-0.42.tar.gz 
cd rlwrap-0.42/
./configure
make &&make install 

3.安装过程中可能遇到的报错

The Oracle system identifier(SID) "orcl" already exists. Specify another SID

解决办法:
1、删除u01/admin下的orcl文件
2、删除u01/oradata下的orcl文件夹
3、用root用户以远程登录模式编辑/etc/oratab,删除或者注释掉最后一行orcl。

[oracle@dbprimary07 ~]$ tail -1 /etc/oratab 
orcl:/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1:N    

4.登录oracle11g实例简单应用

4.1查看数据库实例和创建时间

SQL> select name,created  from v$database;

NAME
--------------------
CREATED
---------------
ORCL
09-OCT-24

SQL> set line 100
SQL> select name,created  from v$database;

NAME                        CREATED
--------------------------- ---------------
ORCL                        09-OCT-24

4.2查看数据库版本

SQL> select * from v$version;

BANNER
----------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

4.3查看服务名

SELECT name FROM dba_services; (需要dba权限)
SELECT name FROM v$services;(查看V$SERVICES视图,这个视图不需要DBA权限)

SQL> SELECT name FROM dba_services; 

NAME
----------------------------------------------------------------------------------------------------
SYS$BACKGROUND
SYS$USERS
uni_dg1
orclXDB
orcl

SQL> SELECT name FROM v$services;

NAME
----------------------------------------------------------------------------------------------------
orclXDB
uni_dg1
SYS$BACKGROUND
SYS$USERS

4.4查看当前数据库服务名

SQL> SELECT instance_name FROM v$instance;

INSTANCE_NAME
------------------------------------------------
orcl

4.5查看所有Oracle数据库实例的服务名

SQL> select instance_name FROM v$instance WHERE instance_name IS NOT NULL;

INSTANCE_NAME
------------------------------------------------
orcl

4.6查看字符集:

SELECT * FROM NLS_DATABASE_PARAMETERS p where p.PARAMETER='NLS_CHARACTERSET';
SELECT USERENV('language') FROM DUAL;

4.7查看数据库名称和创建时间:

SQL> select name,created  from v$database;

NAME      CREATED
--------- ------------------
ORCL      17-SEP-24

4.8创建数据库和拥有该库all权限的用户

#创建数据库表空间

create tablespace mytestdb01 datafile '/u01/oracle/tools/oracle11g/oradata/mytestdb01' size 10m autoextend on;
#说明:末尾带autoextend on参数表示当表空间大小不够用时会自动扩容,所有建议加上autoextend on参数。

#查看mytestdb01表空间
SQL> set line 200
SQL> select * from v$tablespace where NAME='MYTESTDB01';

       TS# NAME                                                                                       INCLUDED_ BIGFILE   FLASHBACK ENCRYPT_I
---------- ------------------------------------------------------------------------------------------ --------- --------- --------- ---------
         6 MYTESTDB01                                                                                 YES       NO        YES

SQL>

#创建用户zhangsan拥有库mytestdb01权限

SQL> 
SQL> create user zhangsan identified by pass123321 default tablespace mytestdb01 quota 3m on users;

User created.
SQL> grant all privileges to zhangsan;

Grant succeeded.

#当前采用zhangsan/pass123321登录

查看当前登录用户

[oracle@dbprimary07 etc]$ sqlplus  zhangsan/pass123321

SQL> SELECT USER FROM DUAL;

USER
--------------------------------------------------------------------------------
ZHANGSAN
SQL> show user;
USER is "ZHANGSAN"

##创建测试表和插入测试数据

#创建测试表:
CREATE TABLE employees (
    employee_id NUMBER PRIMARY KEY,
    first_name VARCHAR2(50),
    last_name VARCHAR2(50),
    hire_date DATE,
    salary NUMBER
);

插入数据:
INSERT INTO employees (employee_id, first_name, last_name, hire_date, salary)
VALUES (1, 'John', 'Doe', '01-Jan-2021', 001);
commit;

查看表数据:
select * from employees  

查看用户zhangsan下所拥有的表以及表对应的行数:

SQL> SELECT table_name, num_rows  FROM all_tables WHERE owner = 'ZHANGSAN';

TABLE_NAME
--------------------------------------------------------------------------------
  NUM_ROWS
----------
EMPLOYEES

4.9查看表空间是否开启自动

SQL> set line 400

SQL> select file_name,tablespace_name,autoextensible from dba_data_files;

FILE_NAME
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TABLESPACE_NAME                                                                            AUTOEXTEN
------------------------------------------------------------------------------------------ ---------
/u01/oracle/tools/oracle11g/oradata/orcl/users01.dbf
USERS                                                                                      YES

/u01/oracle/tools/oracle11g/oradata/orcl/undotbs01.dbf
UNDOTBS1                                                                                   YES

/u01/oracle/tools/oracle11g/oradata/orcl/sysaux01.dbf
SYSAUX                                                                                     YES


FILE_NAME
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TABLESPACE_NAME                                                                            AUTOEXTEN
------------------------------------------------------------------------------------------ ---------
/u01/oracle/tools/oracle11g/oradata/orcl/system01.dbf
SYSTEM                                                                                     YES

/u01/oracle/tools/oracle11g/oradata/mytestdb01
MYTESTDB01                                                                                 NO

5.0数据库表空间使用情况查看

select upper(f.tablespace_name) "TS-name",
 d.tot_grootte_mb "TS-bytes(m)",
 d.tot_grootte_mb - f.total_bytes "TS-used (m)",
 f.total_bytes "TS-free(m)",
 to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
 2),
 '990.99') "TS-per"
 from (select tablespace_name,
 round(sum(bytes) / (1024 * 1024), 2) total_bytes,
 round(max(bytes) / (1024 * 1024), 2) max_bytes
 from sys.dba_free_space
 group by tablespace_name) f, 
 (select dd.tablespace_name,
 round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
 from sys.dba_data_files dd
 group by dd.tablespace_name) d
where d.tablespace_name = f.tablespace_name
order by 5 desc;
SQL> select upper(f.tablespace_name) "TS-name",
  2   d.tot_grootte_mb "TS-bytes(m)",
  3   d.tot_grootte_mb - f.total_bytes "TS-used (m)",
  4   f.total_bytes "TS-free(m)",
  5   to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
  6   2),
  7   '990.99') "TS-per"
  8   from (select tablespace_name,
  9   round(sum(bytes) / (1024 * 1024), 2) total_bytes,
 10   round(max(bytes) / (1024 * 1024), 2) max_bytes
 11   from sys.dba_free_space
 12   group by tablespace_name) f, 
 13   (select dd.tablespace_name,
 14   round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
 15   from sys.dba_data_files dd
 16   group by dd.tablespace_name) d
 17  where d.tablespace_name = f.tablespace_name
 18  order by 5 desc;

TS-name                                                                                    TS-bytes(m) TS-used (m) TS-free(m) TS-per
------------------------------------------------------------------------------------------ ----------- ----------- ---------- ---------------------
SYSTEM                                                                                             670      667.19       2.81   99.58
SYSAUX                                                                                             470      446.06      23.94   94.91
USERS                                                                                                5        1.31       3.69   26.20
UNDOTBS1                                                                                            30        5.69      24.31   18.97
MYTESTDB01                                                                                          10        1.12       8.88   11.20

以上就是oracle11g 企业版静默安装过程以及简单的sql操作应用过程,希望能够帮助到oracle用户初学者,笔者技术水平有限,如有不当之处欢迎指证。

标签:name,db,Centos7.8,实例,install,oracle,config,Oracle11g,u01
From: https://www.cnblogs.com/ywdba668/p/18531778

相关文章

  • oracle11g启动过程中加载配置文件
    oracle指定配置文件启动,要是不指定配置文件启动的话默认找的参数文件顺序如下:在oracle11g中oracle启动过程中默认会加载相应的配置文件来启动oracle服务。检查参数文件有两个,一个是spfile<ORACLE_SID>.ora文件,另一个是inti<ORACLE_SID>.ora文件。oracle软件服务安装完成后......
  • 5.Java 数组(一维数组、二维数组、数组实例实操)
    一、数组1、基本介绍【数据类型】[]【数组名】=new【数据类型】[【长度】];【数据类型】[]【数组名】={【元素1】,【元素2】...};【数据类型】[]【数组名】=new【数据类型】[]{【元素1】,【元素2】...};数组中的元素可以是任何数据元素,包括基本类......
  • 12V-5A反激式开关电源实例
    12V-5A反激式开关电源实例 那么,哪种PWM技术最适合您的电机控制应用?在之前的文章中,我们研究了单象限PWM技术,它非常适合成本极其敏感的电机控制应用,在这些应用中,您希望通过改变PWM信号的占空比来控制电机的速度。但是电机只能在一个方向上旋转,并在同一方向上产生扭矩。我......
  • 刘艳兵-DBA024-关于oracle实例说法正确的是?
    关于oracle实例说法正确的是?A   ORACLE_SID和实例名可以相同,也可以不同B   使用pfile参数文件启动实例时,至少要配置两个参数C   oracle在同一个$ORACLE_HOME下,可以有两个同名的实例D   实例名和数据库名必须相同答:A   ORACLE_SID和实例名可以相同,也......
  • SAP ABAP开发学习——WDA 五 使用表格控件实例
    目录实现先建一个WebDynproComponent将两个view关联input_view中添加按钮output_view创建按钮创建一个服务input_view中使用向导创建两个输入框output部分创建输出表单outputinbound创建APPLICATION效果实现先建一个WebDynproComponent将两个view关......
  • .net core 使用定时任务 quartz.net 实例
    项目是core3.1的 只用引用一个包就可以了引用配置Quartz首先创建一个任务工厂publicclassCronJobFactory:IJobFactory{privatereadonlyIServiceProvider_serviceProvider;publicCronJobFactory(IServiceProviderserviceProvider){_ser......
  • Windows Server 2025 中的 Hyper-V 是一种虚拟化技术,允许用户创建和管理虚拟机 (VM),以
    WindowsServer2025中的Hyper-V是一种虚拟化技术,允许用户创建和管理虚拟机(VM),以便在单一的物理服务器上运行多个操作系统实例。以下是一个针对WindowsServer2025中Hyper-V初级使用教程的大纲,旨在帮助初学者快速掌握如何安装、配置和使用Hyper-V。大纲:WindowsServe......
  • 《图解设计模式》 第三部分 生成实例
    第五章Singleton模式单例模式应该是开发中用的比较多的模式。这里我只记一个知识点。多线程下安全的单例模式的一个知识点publicclassSingleton{publicstaticInstanceClassinstance=null;publicstaticSingletongetInstance(){if(instance==null){......
  • 实例化对象有哪几种方式
    1.**new关键字**  Useruser=newUser(); 2.**clone()方法**  UserclonedUser=originalUser.clone();3.**通过反射机制创建**  Class<?>cls=Class.forName("com.dao.User");  Useru=(User)cls.newInstance();4.**序列化反序列化**  序列化是......
  • 实例化对象有哪几种方式
    1.**new关键字**  Useruser=newUser(); 2.**clone()方法**  UserclonedUser=originalUser.clone();3.**通过反射机制创建**  Class<?>cls=Class.forName("com.dao.User");  Useru=(User)cls.newInstance();4.**序列化反序列化**  序列化是......