安装Oracle12C 总结笔记
IP:10.20.4.214
---------------------------------------------
用户和密码:
root/bayaim
bayaim/064286BAIbay
oracle/oracle
SID:orcl
sys/oracle
system/oracle
mpay/mpay
dx/dx
em: The Database Control URL is https://orcl:1158/em
注意:安装完centos7 后,linux需要指定新建一个用户,要求密码强度很高,才能通过,安装系统完成。
---------------------------------------------
linux #安装环境
cat /etc/issue
uname -a
cat /etc/redhat-release //查看系统的版本
1. 安装centos 选择语言:english / U.S.English 防止乱码
[oracle@testoracle database]$ export LANG=EN
echo $LANG
vi /etc/sysconfig/i18n
echo LANG=zh_CN.gbk
locale -a |grep en
export LANG=en_US
SELINUX
vi /etc/sysconfig/selinux
(本来是:SELINUXTYPE=targeted )
SELINUX=disabled
[root@ums-data mysql]# setenforce 0 (关闭沙盒!)
[root@ums-data mysql]# getenforce
>>>bayaim1.0------关闭防火墙:>>>>>>>>
防火墙
chkconfig iptables off
chkconfig --level 35 NetworkManager off
iptables -F (清空防火墙默认规则)
systemctl status firewalld.service //查看防火墙状态:
systemctl stop firewalld //关闭:
systemctl stop firewalld.service (停止防火墙,这是CentOS7的命令)
systemctl start firewalld //开启:
systemctl disable firewalld //禁止开机启动
-------------------------------------------------------
[root@wwdb2 ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=wwdb2
注意:修改了主机名后
vi /etc/sysconfig/network
---修改hostname
hostaname = oracleServer
vi /etc/hosts
192.168.1.99 oracleServer
-----------------------------------------
[root@rac1 named]# systemctl restart network //重启网卡-----------
// 修改网卡---------
[root@rac1 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@rac1 network-scripts]# cat ifcfg-ens256
[root@dns~]# cat /etc/resolv.conf
search localdomain
nameserver 114.114.114.114
[root@dns ~]# chattr +i /etc/resolv.confv
增加路由规则:
route add -net 172.28.22.0 netmask 255.255.255.0 gw 172.28.20.254 dev eth1
--------------------------------------------------------------------
3) 检查内存及交换空间:Oracle 要求内存至少为1G,。当内存为1G—2G时,交换空间要求为内存的1.5 倍:
#free
查看系统当前共享内存,查看当前服务器swap交换分区大小,可以通过df命令,例如:
#grep SwapTotal /proc/meminfo
4) 修改swap 分区:------------
以下操作需要root权限。
#cd /usr/
#mkdir swap
#dd if=/dev/zero of=swapfile bs=2G count=8
这条命令从硬盘里分出一个 2×8G 大小的空间,挂在swapfile上。
#mkswap swapfile
构建swap格式于/usr/swap/swapfile 上
#swapon swapfile
激活swapfile ,加入到swap分区中。
# vi /etc/fstab
在/etc/fstab文件中加入下面这样一行:
/usr/swap/swapfile swap swap defaults 0 0
--------------------------------------------------------------------
挂载cdrom,配置本地YUM
# mkdir /mnt/cdrom
[root@bay214 cdrom]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
或者
# mount /dev/cdrom /media/cdrom
安装本地光盘yum:
1.检查是否安装了yum
# rpm -qa |grep yum
redhat一般都默认安装了yum。
2.
[root@rac1 Server]# vi /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=localyum
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=0
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
#这里指向了Server目录, 如果还要软件, 则还需建立指向Cluster,ClusterStorage,VT的baseurl.
[root@DB-mysql1-z yum.repos.d]# pwd
/etc/yum.repos.d
[root@DB-mysql1-z yum.repos.d]# ls
my.repo redhat.repo
[root@DB-mysql1-z yum.repos.d]# cat my.repo
[name]
name=my new repo
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@DB-mysql1-z yum.repos.d]#
3.清除缓存
[root@kangvcar ~]# yum clean all
[root@kangvcar ~]# yum makecache //把yum源缓存到本地,加快软件的搜索好安装速度
[root@kangvcar ~]# yum list //列出了3780个包
4.安装测试
#yum -y install gcc
--------------配置网络 YUM
[root@ums-data /]# vi /etc/resolv.conf
nameserver 114.114.114.114 (在结尾加上)
---CentOS 6
[root@ums-data /]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
[root@ums-data /]# yum makecache --生成缓存
----安装好linux 系统自带的
[root@localhost bayaim]# cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-------------------------------------------------------------
CentOS 6.2 64位系统通过yum安装32位软件包
方法2:
这是一种一劳永逸的方法
echo 'multilib_policy=all' >> /etc/yum.conf
---1.0一键安装包:( 注意空格)
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel libXp ksh xorg-x11 pdksh*
---2.0 需要安装一些依赖包之类的,也写一个脚本执行( 2 段都要运行)
yum install -y unixODBC* xorg-x11-apps libXp* pdksh binutils compat-libstdc++-33 glibc ksh libaio libgcc libstdc++ make compat-libcap1 gcc gcc-c++ glibc-devel libaio-devel libstdc++-devel sysstat elfutils-libelf-devel
如果联网:
yum -y install unixODBC*
卸载包:
# yum remove compat*
如果联网:
yum -y install unixODBC*
yum -y install xorg-x11-apps
yum -y install libXp*
yum -y install pdksh
rpm -ivh compat-lib* --nodeps --force >>>>>强制安装的方法
[root@rac1 bai]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm --nodeps --force
[root@rac1 bai]# rpm -ivh cvuqdisk-1.0.9-1.rpm
------------------------------------------------------------------
二:安装rlwrap
[root@bay214 home]# yum -y install readline*
[root@bay214 home]# tar -zxvf rlwrap-0.41.tar.gz
[root@bay214 home]# cd rlwrap-0.41/
[root@oracle11g rlwrap-0.30]# ./configure
[root@oracle11g rlwrap-0.30]# make
[root@oracle11g rlwrap-0.30]# make install
三:方便使用rlwrap
配置环境变量
[oracle@node2 ~]$ vi .bash_profile
stty erase ^h
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
此文件末尾增加如上三句
保存
[oracle@node2 ~]$ source .bash_profile
---------------------------------------------------------------------------------------
>>>bayaim4.0------Oracle建立用户:>>>>>>>>
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmoper
groupadd asmdba
useradd -u 1101 -g oinstall -G dba,oper,asmdba,asmadmin -d /home/oracle -s /bin/bash -c "Oracle Software Owner" oracle
echo "oracle" | passwd --stdin oracle
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
使用groupadd命令创建组 :
[root@jssnode1~]#groupadd -g 502 dba
然后创建OracleInventory组,该组组名通常定义为oinstall :
[root@jssnode1~]#groupadd oinstall
创建ORACLE的owner用户,一般也命令为oracle,操作如下:
[root@jssnode1~]#useradd -u 502 -g oinstall -G dba oracle
创建oracle软件所有者oracle用户,指定其主组为oinstall,并还属于组dba和oper
# useradd -g oinstall -G dba oracle
修改oracle用户组名:
#usermod -G root oracle
#usermod -G dba oracle
然后为该用户设置密码 :
[root@jssnode1~]#passwd oracle
oracle
验证nobody用户:
[root@localhost rpms]# id nobody
[root@localhost rpms]# id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba) context=root:system_r:unconfined_t:SystemLow-SystemHigh
创建文件系统/bai 的所有者,以便以后将数据库安装在/bai 文件系统上:
【创建oracle目录】
#mkdir -p /bai(详细目录可以在环境变量里设置)
#chown -R oracle:oinstall /bai
#chmod -R 775 /bai
【为oracle 用户设置环境变量】
你ORACLE_BASE=/oracle/app/oracle制定什么目录,【要先建目录】!!!!
[root@standby u01]# mkdir -p /u01/app/oracle
[root@standby u01]# chown -R oracle:oinstall /u01
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/11g/
用文本编辑器vi 编辑.bash_profile 参数文件:
[oracle@linuxserv7 ~]$ pwd
[oracle@localhost ~]$ vi .bash_profile
export PATH
umask 022
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_TERM=xterm
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_SID=bay214
export ORACLE_UNQNAME=bay214
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export THREADS_FLAG=native
export LANG=en_US
export NLS_LANG=american_america.AL32UTF8
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
stty erase ^h
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
----------------------------------------------------------------------
>>bayaim6.0------修改环境变量参数:>>>>>>>>
【执行 source .bash_profile 使生效】
[oracle@localhost ~]$ source .bash_profile
在Linux 系统中,我们通常把一些配置写到/etc/sysctl.conf文件,但在Linux 7中,这个规则稍微发生了变化。
[root@bay214 sysctl.d]# pwd
/etc/sysctl.d
[root@18c sysctl.d]# mv 99-sysctl.conf sysctl.conf
[root@18c sysctl.d]# cat sysctl.conf
【修改Linux 内核参数】
[root@jssnode1Server]#vi /etc/sysctl.conf
将下列内容加入该文件:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8160280
kernel.shmmax = 33424509440
kernel.shmmni = 4096
kernel.sem =250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
【使内核参数立即生效】
[root@linuxserv7 ~]#sysctl -p
【为 root 用户设置 Shell 限制 】
[oracle@localhost ~]$ su - root
[oracle@localhost ~]$ vi /etc/security/limits.conf
在文件最下方输入以下内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
[oracle@localhost ~]$ vi /etc/pam.d/login
session required /lib64/security/pam_limits.so
#session required /lib/security/pam_limits.so
session required pam_limits.so
在文件最下方输入以下内容:
#session required /lib/security/pam_limits.so 【此行在centos7.5 系统上要注释掉,要不系统启动不了】
session required pam_limits.so
[root@localhost ~]$ vi /etc/profile
在文件最下方输入以下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[oracle@linuxserv5 sw]$ yum -y install zip unzip
[oracle@linuxserv5 sw]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
[oracle@linuxserv5 sw]$ unzip p13390677_112040_Linux-x86-64_2of7.zip
【注意/bai 目录的权限所有者】
[root@localhost rlwrap-0.41]# chown -R oracle:oinstall /bai
[root@localhost rlwrap-0.41]# chmod 775 /bai
[root@localhost rlwrap-0.41]# cd /bai/
否则启动不了 xclcok 。。。。。。。。。。。
打开:就是使用xmanager的passive.
查看本地"CMD"——IPconfig: IPv4 地址 . . . . . . . . . . . . : 10.20.100.128
rac1-> export DISPLAY=10.20.100.114:0.0
rac1-> export LANG=en_US
--------------------------------------------------------------------
vi /etc/sysconfig/network
---修改hostname
hostaname = oracleServer
vi /etc/hosts
192.168.1.99 oracleServer
--------------------------------------------------------------------
ra11g 安装报错ins_emagent.mk
[root@localhost usr]# find / -name ins_emagent.mk
/u01/app/oracle/11g/sysman/lib/ins_emagent.mk
$(MK_EMAGENT_NMECTL)
替换为
$(MK_EMAGENT_NMECTL) -lnnz11
--------------------------------------------------------------------
>>>bayaim8.0------安装oracle:>>>>>>>>
[root@jssnode1~]#su - oracle
[oracle@jssnode1database]$./runInstaller
Starting Oracle Universal Installer...
--------------------------------------------------------------------
>>>bayaim8.0------安装oracle:>>>>>>>>
#su - oracle
$source .bash_profile
$export DISPLAY=10.20.100.128:0.0
$export LANG=en_US
$xhost +
$xclock
$./runInstaller
[root@testoracle database]# echo $DISPLAY
localhost:10.0
export DISPLAY=localhost:10.0
----------------------------------------------------------
>>>bayaim9.0------安装oracle:>>>>>>>>
中途中:
在另外一个CDE的“终端”窗口中以root用户运行相关脚本:
sh /u01/app/oraInventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0/db_1/root.sh (过程中需要按回车键)
----------------------------------------------------------------------------------------
>>>bayaim10.0------配置oracle:>>>>>>>>
[oracle@linuxserv7 ~]$ dbca
[oracle@linuxserv7 ~]$ lsnrctl
[oracle@linuxserv7 ~]$ netca
[oracle@linuxserv7 ~]$ netmgr
sys/oracle
oracle/oracle
The Database Control URL is https://oradbm:1158/em
https://bay214:5500/em
[oracle@wwdb2 ~]$ echo $ORACLE_HOME
[oracle@wwdb2 ~]$ echo $ORACLE_BASE
[oracle@wwdb2 ~]$ source .bash_profile
[oracle@testoracle ~]$ env | grep ORA
ORACLE_UNQNAME=prodb
ORACLE_SID=prodb
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
[oracle@testoracle ~]$
-------------------------------------------------------------------------------
查看数据库:
sqlplus / as sysdba
set linesize 450
set pagesize 500
col INSTANCE_NAME for A15
col STATUS for A10
col NAME for A10
select instance_name,status from v$instance;
SELECT a.NAME,a.DATABASE_ROLE,a.OPEN_MODE,a.LOG_MODE FROM V$DATABASE a;
-------------------------------------------------------------------------------
查看数据库字符集:
select userenv('language') from dual;
select * from sys.props$ where name='NLS_CHARACTERSET';
可以查看服务器的版本:
select * from v$version;
/u01/app/oracle/oradata/orcl/TBS_MPAY01.dbf
/u01/app/oracle/oradata/orcl/TEST01_TBS_MPAY01.dbf
ORA-00959: tablespace 'TBS_MPAY' does not exist
ORA-00959: tablespace 'TEST01_TBS_MPAY' does not exist
[oracle@orcl expdp]$ impdp system/oracle DIRECTORY=bayaim DUMPFILE=database_full.DMP schemas=mpay,dx
SQL> alter database default tablespace TEST01_TBS_MPAY;
Database altered.
SQL> alter user mpay identified by mpay;
-0-------------------------------------------------------
可以在终端查看监听状态
[oracle@linux4 database]$ lsnrctl status
$ orapwd file=$ORACLE_HOME\pwdjsbx.ora password=jh_jsbx entries=2
orapwd file=$ORACLE_HOME\pwdjsbx.ora password=jh_jsbx entries=2
strings pwdjsbx.ora
[oracle@bay214 admin]$ pwd
/u01/app/oracle/product/11.2.0/db_1/network/admin
[oracle@bay214 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = bay214)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = bay214)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bay214)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@bay214 admin]$
[oracle@bay214 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
BAY214 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.4.214)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = bay214)
)
)
PDB214 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.4.214)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = BAYPDB)
)
)
-=-----------------------------------------
https://blog.csdn.net/liou825/article/details/10054589
基本概念:
Multitenant Environment:多租户环境
CDB(Container Database):数据库容器
PDB(Pluggable Database):可插拔数据库
CDB与PDB关系图
COMMON USERS(普通用户):经常建立在CDB层,用户名以C##或c##开头;
LOCAL USERS(本地用户):仅建立在PDB层,建立的时候得指定CONTAINER。
--------------CDB与PDB操作-----------------------------
SQL> startup
SQL> show con_name //查看当前所在的容器
SQL> show pdbs; //查询数据库的所有容器
. 创建公用用户bighero, 需要使用C##或者c##作为该用户名的开头。
SYS@cdb > create user c##bighero identified by bighero;
查看容器
select con_id, dbid, guid, name , open_mode from v$pdbs;
SQL> alter pluggable database baypdb open; //修改可插拔库orclpdb打开状态
插接式数据库已变更。
SQL> alter session set container=baypdb; //CDB下切换会话到PDB中
会话已更改。
4.创建PDBORCL库用户
--注意需要先确定数据库中有users表空间、temp临时表空间
create user ajao identified by ajao default tablespace users temporary tablespace temp;
CREATE USER mpay IDENTIFIED BY mpay;
5、授权
grant create user,drop user,alter user,create any view,connect,resource,dba,create session,create any sequence to AJAO;
grant DBA,connect,RESOURCE to mpay;
----------------------------------
alter tablespace SYSTEM
add datafile '/u01/app/oracle/oradata/bay214/system02.dbf' size 1024M
autoextend off