首页 > 数据库 >32.数据库的创建和维护

32.数据库的创建和维护

时间:2023-02-28 23:48:08浏览次数:40  
标签:02 00 -- 32 数据库 2023 28 sys 创建

1.使用OEM访问数据库

--启动oem
[[email protected]:/home/oracle]$ emctl start dbconsole
[root@yuanzj ~]# firefox https://yuanzj.com:1158/em/console/aboutApplication

2.密码文件的管理

 10g,11g没有太大差别

 12c有独特的管理方式

--说明有密码文件
sys@ORCL10G 2023-02-28 22:02:07> select * from v$pwfile_users;

USERNAME		       SYSDB SYSOP
------------------------------ ----- -----
SYS			       TRUE  TRUE

Elapsed: 00:00:00.02

--说明没有密码文件
sys@ORCL10G 2023-02-28 22:02:07> select * from v$pwfile_users;

now rows selectd

Elapsed: 00:00:00.02

--有密码文件,可以远程连接
--没有密码文件,不能远程连接

--重新配置密码文件
orapwd file=$ORACLE_HOME/dbs/orapworcl10g password=Oracle_4U force=y

--禁止远程登陆
sys@ORCL10G 2023-02-28 22:02:20> show parameter remote;

NAME_COL_PLUS_SHOW_PARAM							 TYPE               VALUE_COL_PLUS_SHOW_PARAM
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
remote_archive_enable								 string             true
remote_dependencies_mode							 string             TIMESTAMP
remote_listener 								 string 
remote_login_passwordfile							 string             EXCLUSIVE
remote_os_authent								 boolean            FALSE
remote_os_roles 								 boolean            FALSE
sys@ORCL10G 2023-02-28 22:06:52> alter system set remote_login_passwordfile=none scope=spfile;

--独占模式
sys@ORCL10G 2023-02-28 22:06:52> alter system set remote_login_passwordfile=EXCLUSIVE scope=spfile;
--共享模式(可以使用sys登录数据库,但是不能改sys密码)
sys@ORCL10G 2023-02-28 22:06:52> alter system set remote_login_passwordfile=shared scope=spfile;

--禁止密码文件认证,只允许操作系统认证
[[email protected]:/home/oracle]$ cat $ORACLE_HOME/network/admin/sqlnet.ora
sqlnet.authentication_services=all
--禁止操作系统认证,只允许密码文件认证
[[email protected]:/home/oracle]$ cat $ORACLE_HOME/network/admin/sqlnet.ora
sqlnet.authentication_services=none

--Oracle11g
--密码文件区分大小写

--Oracle12c
sys@ORCL 2023-02-28 22:29:52> select * from v$pwfile_users

USERNAME	SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM ACCOUNT_ST PASSWORD_P LAST_LOGIN LOCK_DATE	EXPIR EXTERNAL_N AUTHENTI COM	  CON_ID
--------------- ----- ----- ----- ----- ----- ----- ---------- ---------- ---------- ---------- ----- ---------- -------- --- ----------
SYS		TRUE  TRUE  FALSE FALSE FALSE FALSE OPEN							 PASSWORD YES	       0
SYSDG		FALSE FALSE FALSE FALSE TRUE  FALSE OPEN							 PASSWORD NO	       1
SYSBACKUP	FALSE FALSE FALSE TRUE	FALSE FALSE OPEN							 PASSWORD NO	       1
SYSKM		FALSE FALSE FALSE FALSE FALSE TRUE  OPEN							 PASSWORD NO	       1

Elapsed: 00:00:00.00
sys@ORCL 2023-02-28 22:32:49> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB01			  READ WRITE NO
sys@ORCL 2023-02-28 22:32:54> alter session set container = ORCLPDB01;

Session altered.

Elapsed: 00:00:00.00
sys@ORCL 2023-02-28 22:33:07>  select * from v$pwfile_users
  2  ;

USERNAME	SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM ACCOUNT_ST PASSWORD_P LAST_LOGIN LOCK_DATE	EXPIR EXTERNAL_N AUTHENTI COM	  CON_ID
--------------- ----- ----- ----- ----- ----- ----- ---------- ---------- ---------- ---------- ----- ---------- -------- --- ----------
SYS		TRUE  TRUE  FALSE FALSE FALSE FALSE OPEN							 PASSWORD YES	       0

在12c中管理密码文件,需要去cdb中管理密码文件

3.参数文件的管理

--参数文件有两种
--1.查看
show parameter
select * from v$parameter;

sys@ORCL11G 2023-02-28 22:42:58> show parameter pga;

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target		     big integer 0
sys@ORCL11G 2023-02-28 22:43:04> desc v$parameter;
 Name																			           Null?	Type
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 NUM																			    NUMBER
 NAME																			    VARCHAR2(80)
 TYPE																			    NUMBER
 VALUE																			    VARCHAR2(4000)
 DISPLAY_VALUE																		    VARCHAR2(4000)
 ISDEFAULT																		    VARCHAR2(9)
 ISSES_MODIFIABLE																	    VARCHAR2(5)
 ISSYS_MODIFIABLE																	    VARCHAR2(9)
 ISINSTANCE_MODIFIABLE																	    VARCHAR2(5)
 ISMODIFIED																		    VARCHAR2(10)
 ISADJUSTED																		    VARCHAR2(5)
 ISDEPRECATED																		    VARCHAR2(5)
 ISBASIC																		    VARCHAR2(5)
 DESCRIPTION																		    VARCHAR2(255)
 UPDATE_COMMENT 																	    VARCHAR2(255)
 HASH																			    NUMBER

sys@ORCL11G 2023-02-28 22:43:09> select name,ISSYS_MODIFIABLE,ISINSTANCE_MODIFIABLE from v$parameter where name = 'pga_aggregate_target';

NAME										 ISSYS_MOD ISINS
-------------------------------------------------------------------------------- --------- -----
pga_aggregate_target								 IMMEDIATE TRUE

Elapsed: 00:00:00.00
--ISSYS_MODIFIABLE:表示立即生效
--ISINSTANCE_MODIFIABLE:表示可以修改

--改到内存
sys@ORCL11G 2023-02-28 22:46:22> alter system set pga_aggregate_target = 120m scope=memory;

System altered.

Elapsed: 00:00:00.01

--改到参数文件
sys@ORCL11G 2023-02-28 22:46:33> alter system set pga_aggregate_target = 120m scope=spfile;

System altered.

Elapsed: 00:00:00.01

--改到内存和参数文件
sys@ORCL11G 2023-02-28 22:46:47> alter system set pga_aggregate_target = 120m scope= both;

System altered.

Elapsed: 00:00:00.01
sys@ORCL11G 2023-02-28 22:47:03> alter system set pga_aggregate_target = 120m;

System altered.

Elapsed: 00:00:00.01

会话可以改的,基本都可以改

sys@ORCL 2023-02-28 22:52:28> select PDB_UID,sid,name,value$ from pdb_spfile$;

no rows selected

Elapsed: 00:00:00.02
sys@ORCL 2023-02-28 22:53:12> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB01			  READ WRITE NO
sys@ORCL 2023-02-28 22:53:27> alter session set container = ORCLPDB01;

Session altered.

Elapsed: 00:00:00.14
sys@ORCL 2023-02-28 22:53:44> alter system set open_cursors=400;

System altered.

Elapsed: 00:00:00.21
sys@ORCL 2023-02-28 22:54:17> alter session set container = cdb$root;

Session altered.

Elapsed: 00:00:00.00
sys@ORCL 2023-02-28 22:54:40> select PDB_UID,sid,name,value$ from pdb_spfile$;

  
   PDB_UID SID		   NAME               VALUE$
---------- --------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3873269478 *		   open_cursors       400

sys@ORCL 2023-02-28 23:01:18> select name,guid,con_uid from v$pdbs;

NAME		GUID				    CON_UID
--------------- -------------------------------- ----------
PDB$SEED	F48EBCF996743B67E0532802A8C010BF  182913619
ORCLPDB01	F48EE2C05E6D47CCE0532802A8C0A02A 3873269478

Elapsed: 00:00:00.00
sys@ORCL 2023-02-28 23:01:34> select pdb_uid,name from pdb_spfile$;

   PDB_UID NAME
---------- ---------------
3873269478 open_cursors

Elapsed: 00:00:00.01
sys@ORCL 2023-02-28 23:01:36> alter session set container = ORCLPDB01;

Session altered.

Elapsed: 00:00:00.01
sys@ORCL 2023-02-28 23:02:36> alter system reset open_cursors;

System altered.

Elapsed: 00:00:00.10
sys@ORCL 2023-02-28 23:02:48> alter session set container = cdb$root;

Session altered.

Elapsed: 00:00:00.01
sys@ORCL 2023-02-28 23:02:56> select pdb_uid,name from pdb_spfile$;

   PDB_UID NAME
---------- ---------------
3873269478 open_cursors

Elapsed: 00:00:00.00

--所有pdb参数生效
alter system set open_cursors=400 container = all;


--修改参数文件转化
create pfile from memory;
create pfile from spfile;
create spfile from pfile;

4.数据库的启动和关闭

--数据库启动阶段
--实例启动阶段
--启动的四个阶段:shudown-->nomount-->mount-->open
--1.shutdown:数据库关闭阶段
--2.nomount:实例已经启动
--3.mount:此实例的控制文件已打开
--4.open:正常打开数据库


--启动到数据库的四个阶段
--startup nomount
--startup mount
--alter database open;

--oracle12c
--打开
alter pluggable database orclpdb01 open;
--关闭
alter pluggable database orclpdb01 close;

5.三个版本数据库的启动和关闭

--oracle10和oracle11g启动方式一样
sys@ORCL10G 2023-02-28 23:26:23> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

Elapsed: 00:00:00.01
sys@ORCL10G 2023-02-28 23:26:39> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ORCL10G 2023-02-28 23:26:59> select open_mode from v$database;
select open_mode from v$database
*
ERROR at line 1:
ORA-01034: ORACLE not available


Elapsed: 00:00:00.00
sys@ORCL10G 2023-02-28 23:27:09> startup nomount;
ORACLE instance started.

Total System Global Area						 1174405120 bytes
Fixed Size								    2095800 bytes
Variable Size								  301991240 bytes
Database Buffers							  855638016 bytes
Redo Buffers								   14680064 bytes
sys@ORCL10G 2023-02-28 23:27:15> alter database mount;

Database altered.

Elapsed: 00:00:04.08
sys@ORCL10G 2023-02-28 23:27:30> select open_mode from v$database;

OPEN_MODE
----------
MOUNTED

Elapsed: 00:00:00.00
sys@ORCL10G 2023-02-28 23:27:39> alter database open;

Database altered.

Elapsed: 00:00:00.96
sys@ORCL10G 2023-02-28 23:27:46> select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

Elapsed: 00:00:00.00
sys@ORCL10G 2023-02-28 23:27:48>

6.使用grid管理数据库的启动和关闭

 

7.动态性能视图

标签:02,00,--,32,数据库,2023,28,sys,创建
From: https://www.cnblogs.com/yuanzijian/p/17166503.html

相关文章

  • Java连接数据库技术-JDBC
    课程简介和目标 Java数据库连接,(JavaDatabaseConnectivity,简称JDBC)是Java语言中用来规范客户端程序如何来访问数据库的应用程序接口,提供了诸如查询和更新数据库中数据......
  • Java连接数据库技术-JDBC
    课程简介和目标 Java数据库连接,(JavaDatabaseConnectivity,简称JDBC)是Java语言中用来规范客户端程序如何来访问数据库的应用程序接口,提供了诸如查询和更新数据库中数据......
  • 路飞:路飞后台配置之封装logger、路飞后台配置之封装全局异常、路飞台配置之二次封装re
    目录一、路飞后台配置之封装logger配置步骤步骤一:复制代码(之前学过的日志字典)到配置文件中(dev.py)步骤二:在utils新建common_logger.py,写入下方代码,得到日志对象步骤三:在......
  • Oracle数据库2
    一.创建用户和表空间1.1.以超级管理员身份登录connsysas/password**assysdba**1.1.1查看使用哪一个实例进行登录的selectinstance_namefromv$instance;1.2.......
  • 云原生数据库TDSQL-C 容灾的实践和探索
    云原生数据库TDSQL-C作为腾讯云架构平台部核心数据库产品之一,致力于为云上ToB用户和公司自研业务提供集高性能、低成本、大存储、低延迟、秒级扩缩容、极速回档、Serverles......
  • mysql数据库的主主复制和半同步复制
    今天分享的是mysql数据库的主主复制和半同步复制的一系列步骤,以及在各处出现错误的解决方法和其在操作过程中需要注意的地方范例:主主复制主主复制:两个节点,都可以更新数据,并......
  • mybatis-plus主键生成策略(实体类配置,数据库插入数据自动生成id)
    转载:MyBatisplus--ActiveRecord(AR)_mybatisplusidtype.auto_憨憨浩浩的博客-CSDN博客0.auto:自动增长(mysql,sqlserver)1.none:没有主键2.input:手动输入3.id_worker:实体......
  • xr32f429开发环境搭建
    XR32是全志科技的一款MCU芯片,基本参数如下所示:  环境的搭建首先是下载芯片对应的资料和手册(QQ群723687715)软硬件资料官网工具下载:注册全志服务平台    下......
  • 理论:第二章:Spring的AOP和IOC是什么?使用场景有哪些?Spring事务与数据库事务,传播行为,数据
    AOP:面向切面编程。即在一个功能模块中新增其他功能,比方说你要下楼取个快递,你同事对你说帮我也取一下呗,你就顺道取了。在工作中如果系统中有些包和类中没有使用AOP,例如日志......
  • 路飞项目使用mysql数据库详细讲解
    目录一、首先需要彻底删除原有的数据库步骤二、去官网下载mysql步骤三、安装mysql数据库步骤四、一管理员身份进去cmd进行一系列命令启动五、接下来为路飞项目创建数据库六......