1.查看存储空间
select (select name from v$database) db_name,name diskgroup_name,total_mb,free_mb,round(free_mb/total_mb*100,1) FREE_Uti_PCT from v$asm_diskgroup order by 4;1
2.查看新增硬盘
[root@rac1 ~]# fdisk -l | grep " /dev/sd[a-i]"1
3.使用udev配置Asm磁盘
[root@rac1 ~]#fdisk /dev/sdm1
rac1和rac2两端都需要修改/etc/udev/rules.d/99-oracle-asmdevices.rules文件
[root@rac1 ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rulesKERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="360003ff44dc75adc99ce03b511761d49", SYMLINK+="asm-diskl", OWNER="grid", GROUP="asmadmin", MODE="0660"[root@rac1 ~]# /sbin/udevadm trigger --type=devices --action=change[root@rac2 ~]# /sbin/udevadm trigger --type=devices --action=change1234
查看宿主和组用户,这里必须要先创建用户和组之后才会显示正确
[root@rac1 ~]# ls -l /dev/sd?1brw-rw---- 1 root disk 8, 1 11月 13 22:42 /dev/sda1 brw-rw---- 1 grid asmadmin 8, 193 11月 13 22:42 /dev/sdm1123
SQL> select name,state,type,total_mb,free_mb from v$asm_diskgroup;NAME STATE TYPE TOTAL_MB FREE_MB------------------------------ ----------- ------ ---------- ----------DATA CONNECTED EXTERN 61424 54024 MGMT MOUNTED EXTERN 30708 5196 OCR MOUNTED NORMAL 15348 14432 TEST CONNECTED EXTERN 15356 150121234567
查看当前数据库名称
SQL> show con_name1
查看表空间
SQL> select file_name from dba_data_files;1
创建用户C##text01
SQL> create user C##text01 identified by oracle; 1
给用户授权
SQL> grant dba to c##text01; 1
确认哪个是pdb
SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB MOUNTED //pdb未打卡 SQL> alter pluggable database PDB open; //打开PDB Pluggable database altered.12345678
确认是否打开PDB
SQL> show pdbs; //确认是否打开PDB CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB READ WRITE NO12345
切换pdb
SQL> alter session set container=PDB;1
在pdb里面创建表空间
SQL> create tablespace TEST02 2 datafile '+TEST' 3 size 200m 4 autoextend on 5 next 50m maxsize unlimited 6 extent management local;Tablespace created.1234567
将表空间分配给用户
SQL> alter user C##text01 default tablespace test02; 1
切换cdb
SQL> alter session set container=CDB$ROOT; 1
Windows连接oracle数据库
C:\Users\admin>sqlplus c##text01/oracle@//192.168.0.212:1521/orcdbC:\Users\admin>sqlplus c##text01/oracle@//192.168.0.212:1521/pdb12
4.添加asm硬盘
[root@rac1 ~]# su - grid[grid@rac1 ~]$ sqlplus / as sysdba12
查看刚才创建的硬盘
SQL> set lines 200 pages 50000 col name for a25 col path for a55select group_number,disk_number,name,path,total_mb/1024 total_G,mode_status,repair_timer from v$asm_disk order by group_number,disk_number;SQL> SQL> SQL> GROUP_NUMBER DISK_NUMBER NAME PATH TOTAL_G MODE_ST REPAIR_TIMER------------ ----------- ------------------------- ------------------------------------------------------- ---------- ------- ------------ 0 0 /dev/sde1 0 ONLINE 0 0 1 /dev/sdg1 0 ONLINE 0 0 2 /dev/sdh1 0 ONLINE 0 0 3 /dev/sdd1 0 ONLINE 0 0 4 /dev/sdb1 0 ONLINE 0 0 5 /dev/sdf1 0 ONLINE 0 0 6 /dev/sdc1 0 ONLINE 0 0 7 /dev/sdi1 0 ONLINE 0 1 0 DATA1 AFD:DATA1 14.9960938 ONLINE 0 1 1 DATA2 AFD:DATA2 14.9960938 ONLINE 0 1 2 DATA_0002 /dev/sdj1 14.9960938 ONLINE 0 1 3 DATA_0003 /dev/sdk1 14.9960938 ONLINE 0 2 0 MGMT1 AFD:MGMT1 9.99609375 ONLINE 0 2 1 MGMT2 AFD:MGMT2 9.99609375 ONLINE 0 2 2 MGMT3 AFD:MGMT3 9.99609375 ONLINE 0 3 0 OCR1 AFD:OCR1 4.99609375 ONLINE 0 3 1 OCR2 AFD:OCR2 4.99609375 ONLINE 0 3 2 OCR3 AFD:OCR3 4.99609375 ONLINE 0 18 rows selected.123456789101112131415161718192021222324252627
将查询到的硬盘添加到DATA
SQL> alter diskgroup DATA add disk '/dev/sdm1' ;Diskgroup altered.12
5.查看添加进去的磁盘是否成功
--asm.sql column name format a20 column free_mb format 999,999,999select name,to_char(sysdate,'YYYY-MM-DD HH24:MI') SYSTEM_DATETIME from v$database;select (select name from v$database) db_name,name diskgroup_name,total_mb,free_mb,round(free_mb/total_mb*100,1) FREE_Uti_PCT from v$asm_diskgroup order by 4;12345
发表评论