fdisk -l 查看目前磁盘
df -Th 查看磁盘挂载信息
1.添加一个分区
fdisk /dev/sdb
fdisk -l | grep ‘/dev’
命令输入n
2.格式化’sdb1’分区
mkfs.xfs /dev/sdb1 mkfs -t ext4 /dev/sdb1
3.创建文件系统(手工挂载)
mkdir /u01
mkdir /soft
mount /dev/sdb1 /u01/ 将’sdb1’分区挂载到’u01’目录上
mount /dev/sdc1 /soft/
添加至开机自启
blkid /dev/sdb1 查看分区的UUID和类型
vim /etc/fstab 编辑开机自启文件
passwd oracle 修改’oracle’用户密码
mount /dev/cdrom /mnt/ 光驱挂载?/mnt/下,(挂载使用一次,重启后需要重新挂载)
内核参数修改 Oracle监听操作
sysctl -p 参数修改生效
lsnrctl status 查看监听
lsnrctl start 启动监听
lsnrctl stop 停止监听
fdisk /dev/sdb
300 fdisk -l
301 fdisk /dev/sda
302 partprobe
303 fdisk -l
304 pvcreate /dev/sda3
305 pvdisplay
306 vgextend centos /dev/sda3
310 lvresize -L +39.9G /dev/mapper/centos-root
311 xfs_growfs /dev/mapper/centos-root
312 df -h
lsblk /dev/sda4 老师不离开,查看磁盘分区信息
mkfs.ext4 /dev/sda4 指定格式,格式化分区
mkdir -pv /newdata 挂载前,创建的
ls -l /dev/disk/by-uuid
vim /etc/fstab
reboot 重启使生效
UUID=16a42304-99f8-472a-ae60-19e244e28d9a /newdata ext4 defaults 0 0
--------安装步聚
参考视频教程https://www.bilibili.com/video/BV1Jg4y1B7uC/?spm_id_from=333.788.recommend_more_video.-1
1.主机名及IP
获取ip
ifconfig
获取主机名
hostname
编辑/etc/hosts文件,IP在下面命令中被隐藏。
echo "192.168.31.234 youHostName" >> /etc/hosts
2.创建用户和组
/usr/sbin/groupadd -g 65431 oinstall
/usr/sbin/groupadd -g 65432 dba
/usr/sbin/groupadd -g 65433 oper
useradd -u 61001 -g oinstall -G dba,oper -m oracle
passwd oracle #改用户密码
3.创建文件夹及权限
/u01/newdata
mkdir /u01
mkdir -p /newdata/app/oracle/product/19.3.0/dbhome_1
mkdir -p /newdata/app/oraInventory
chown -R oracle:oinstall /newdata
chmod -R 775 /newdata
4.配置yum源 挂载的是光驱ISO镜像文件
需要用/mnt/Packages下面的东西
mount /dev/cdrom /mnt/ 光驱挂载到/mnt/下
mv /etc/yum.repos.d/* /tmp/ 原有的repo文件移动至/tmp下
echo “[henry_repo]” >> /etc/yum.repos.d/henry.repo
echo “name=localyum” >> /etc/yum.repos.d/henry.repo
echo “baseurl=file:///mnt/” >> /etc/yum.repos.d/henry.repo
echo “enabled=1” >> /etc/yum.repos.d/henry.repo
echo “gpgcheck=0” >> /etc/yum.repos.d/henry.repo
===/etc/yum.repos.d/henry.repo
[henry_repo]
name=localyum
baseurl=file:///mnt/
enabled=1
gpgcheck=0
===
5.安装RPM包
yum -y install autoconf
yum -y install automake
yum -y install binutils
yum -y install binutils-devel
yum -y install bison
yum -y install cpp
yum -y install dos2unix
yum -y install ftp
yum -y install gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-libcap1
yum -y install compat-libstdc++-33
yum -y install compat-libstdc++--33.i686
yum -y install glibc-*
yum -y install glibc-*.i686
yum -y install libXpm-*.i686
yum -y install libXext
yum -y install libXext.i686
yum -y install libXtst
yum -y install libXtst.i686
yum -y install libX11
yum -y install libX11.i686
yum -y install libXau
yum -y install libXau.i686
yum -y install libxcb
yum -y install libxcb.i686
yum -y install libXi
yum -y install libXi.i686
yum -y install libstdc++.i686
yum -y install libstdc++-devel
yum -y install libstdc++-devel.i686
yum -y install libaio
yum -y install libaio.i686
yum -y install libaio-devel
yum -y install libaio-devel.i686
yum -y install ksh
yum -y install libXp
yum -y install libaio-devel
yum -y install numactl
yum -y install numactl-devel
yum -y install make -y
yum -y install sysstat -y
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
yum -y install unzip
yum install -y libXrender
yum install -y libXrender-devel
yum install -y nfs-utils
yum install -y smartmontools
6.资源限制
编辑以下文件
vim /etc/security/limits.conf
添加内容以下内容
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 16384
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
7.SHELL限制:最后一行追加"session required pam_limits.so"命令
echo “session required pam_limits.so” >> /etc/pam.d/login
8.修改内核参数
编辑文件 :
vim /etc/sysctl.conf
----以下两参数在生产环境的计算方法
kernel.shmmax = 当前内存之*1024*1024*1024 *0.9 (本例中是4G内存的值)
kernel.shmall = kernel.shmmax / 4096
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmax = 3865470566
kernel.shmall = 943718
kernel.shmmni = 4096
kerne1.sem = 25032000100128
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 = 1048586
kernel.panic_on_oops = 1
使之生效
sysctl -p
9.关闭防火墙
firewall-cmd --zone=public --list-ports
查看防火墙放行端口
firewall-cmd --zone=public --add-port=1521/tcp --permanent
防火墙添加放行端口1521
firewall-cmd --reload
切记要刷新
systemctl status firewalld.service
查看防火墙状态
systemctl start firewalld.service
启动防火墙
systemctl stop firewalld.service
关闭防火墙
systemctl disable firewalld.service
永久关闭防火墙
10.配置用户环境变量
#切换oracle用户
su - oracle
#编辑 .bash_profile
vim .bash_profile
末尾添加以下行,注意换行问题
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNONAME=cdb19c
ORACLE_SID=cdb19c; export ORACLE_SID
ORACLE_BASE=/newdata/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin; export PATH
THREADS_FLAG=native; export THREADS_FLAG
umask=022
if [ $USER = "oracle" ]; then
if [ $SELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
u1imit -u 16384 -n 65536
fi
umask 022
fi
stty erase ^h
#SQL>模式下退格键起作用,不然一按退格键输出^h
11.解压软件
压缩包上传至/soft目录,用oracle用户进行解压,注意权限。
注意:从orac1e 18c开始,必须把压缩文件解压到$ORACLE_HOME里面。
使用root用户授权
chown -R oracle:oinstall /soft
chmod -R 775 /soft
chown -R oracle:oinstall /newdata/soft 我本地是这个样子
chmod -R 775 /newdata/soft
切换 oracle 用户解压
su - oracle
cd $ORACLE_HOME
unzip -q /soft/19c-V982063-01.zip
12.数据库软件安装
静默安装参数定义请参考文件$ORACLE_HOME/install/response/db_install.rsp
./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile /newdata/app/oracle/product/19.3.0/dbhome_1/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/newdata/app/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=/newdata/app/oracle/product/19.3.0/dbhome_1 \
ORACLE_BASE=/newdata/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
As a root user, execute the following script(s):
1. /newdata/app/oraInventory/orainstRoot.sh
2. /newdata/app/oracle/product/19.3.0/dbhome_1/root.sh
Successfully Setup Software with warning(s).
- Oracle监听器服务操作
lsnrctl status
查看监听状态
lsnrctl start
启动监听
lsnrctl stop
停止监听
14.创建数据库
静默建库参数定义请参考文件$ORACLE HOME/assistants/dbca/dbca.rsp或官方文档
在Oracle用户的~目录下执行
dbca -silent -createDatabase -templateName General_Purpose.dbc \
-gdbname cdb19c \
-sid cdb19c \
-databaseConfigType SI \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName oca \
-useLocalUndoForPDBs TRUE \
-pdbAdminPassword oracle \
-sysPassword oracle \
-systemPassword oracle \
-characterSet AL32UTF8 \
-memoryPercentage 30
解释:
gdbname groupName 与环境变量里配置需要一样
sid SID
-databaseConfigType SI 单实例数据库
createAsContainerDatabase 是否创建为容器数据库12c以后都是容器数据库
pdbAdminPassword
sysPassword
systemPassword 他们的密码都设为是’oracle’
Oracle 19c 创建用户、授权实践
sqlplus / as sysdba;
#在Linux上用Oracle用户执行
startup
#启动库
shutdown immediate
#关闭库
alter pluggable database all open;
#开起PDB库
alter pluggable database all close;
#关闭PDB库
alter user sys identified by oracle;
#cdb中修改用户密码
select name,cdb from v$database;
#查看实例名
env | grep ora
#查看环境变量内容
cdb19c
SQL> select * from v$version; #查看Oracle版本
SQL> show pdbs;
show user; #数据库查询用户角色
create user <userName> identified by <password>;
create user maoll identified by softroad_1;
参考:
https://blog.csdn.net/u013919153/article/details/122468178
用户 C##test
密码 testpass
grant dba,connect,resource,create view to C##test;
grant create session to C##test;
grant select any table to C##test;
grant update any table to C##test;
grant insert any table to C##test;
grant delete any table to C##test;
grant create session,resource to C##test;
#进入(切换会话)PDB
alter session set container= OCA;
alter session set container= ORCLPDB1;
用户名 test2
密码 test2pass
授权
grant sysdba to test2;
grant select any table to test2;
grant update any table to test2;
grant insert any table to test2;
grant delete any table to test2;
grant create session to test2;
/newdata/app/oracle/product/19.3.0/dbhome_1
sqlplus test2/test2pass@OCA
#删除用户
drop user test2 cascade;
---------------------------VNC(for Linux)远程桌面服务的安装
yum install tigervnc-server 安装VNC
ps -aux |grep vnc 查看进程
vncserver
vncserver -list 查看会话列表
vncserver :1 启动会话1
---------------------------------------7.205 Oracle 信息
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
ORCLPDB1
grant dba,connect,resource,create view to C##test;
grant create session to C##test;
grant select any table to C##test;
grant update any table to C##test;
grant insert any table to C##test;
grant delete any table to C##test;
create user hino1 identified by softroad;
PDB用户名 密码
hino1 softroad
使用账号测试连接
conn hino1/softroad@ORCLPDB1;
grant dba,connect,resource,create view to hino1;
grant select any table to hino1;
grant update any table to hino1;
grant insert any table to hino1;
grant delete any table to hino1;
grant create session to hino1;
#----------添加区间 start------------------
#不要再动其他地方
# ORCLPDB1 这个名字可以自定义
ORCLPDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLPDB1)
# SERVICE_NAME 这个就是你进入的pdb名称
)
)
#------------添加区间 end--------------
修改oracle数据库的编码
1.查看oracle数据库的编码
select * from nls_database_parameters where parameter ='NLS_CHARACTERSET'; characterset
SELECT * FROM v$nls_parameters;
select userenv('language') from dual; 默认字符集:JAPANESE_JAPAN.AL32UTF8 // NLS_CHARACTERSET JA16SJISTILDE
2.切换会话到自己的
alter session set container= ORCLPDB1;
3.关闭数据库
shutdown immediate;
4.以mount打来数据库
startup mount;
alter session set sql_trace=true;
alter system enable restricted session;
alter system set job_queue_processes=0;
alter system set aq_tm_processes=0;
alter database character set internal_use JA16SJISTILDE;
shutdown immediate;
startup;
alter database open;
select pdb_id,pdb_name,status from cdb_pdbs;
select con_id, dbid, guid, name , open_mode from v$pdbs;
sqlplus出现???问号
ORA-00604: ??SQL???1???
解决办法:使用Oracle用户
vi ~/.bash_profile
追加一下变量
$ export NLS_LANG=american_america.zhs16gbk