银河麒麟Kylin_s10_sp3安装Oracle11g(FS)(官方补丁认证221018)
作者:shannon,微信号:shannon3730。
请尊重本人的劳动成果,转载请加作者信息。
2023年5月19日
#!/bin/bash
# OS:
Kylin-Server-V10-SP3-General-Release-2212-X86_64.iso
# 内存:8G
# 业务系统:HS系统
# 主机名:shhs52
# IP地址:192.168.1.52
# db name:
shhsdb
# instance name: shhsdb
# 数据库版本: Oracle 11g
+ psu 补丁(221018)
FS + LINUX 8.2 认证
# 依赖包下载地址:
https://update.cs2c.com.cn/NS/V10/V10SP2/os/adv/lic/updates/x86_64/Packages/
# 备注:
# 之前基于降库安装的方法对于小伙伴要求有点高,现在可以基于官方认证补丁进行安装。
# 必须先安装220118(含)之后的PSU补丁,才可以继续安装 Linux
8.x 系统认证
# 文中的补丁,请网上搜索或打赏索取。
银河麒麟 Kylin_s10_sp3安装Oracle11g(FS)(亲测有效)https://blog.csdn.net/airwolfzhao34/article/details/129649342
##修改内存大小
8G
##手动设置IP
shhs52:
192.168.1.52
##配置源,安装依赖
cd /etc/yum.repos.d
mkdir bk
mv kylin*.repo bk/
cat << EOF >> local-source.repo
[kylin]
name=kylin
baseurl=file:///mnt
gpgcheck=0
enabled=1
EOF
cat local-source.repo
挂载系统iso到/mnt
mount /dev/cdrom /mnt
dnf clean all
mount /dev/cdrom /mnt
dnf list
mount /dev/cdrom /mnt
dnf -y install bc
dnf -y install binutils
dnf -y install compat-openssl10
dnf -y install elfutils-libelf
dnf -y install glibc
dnf -y install glibc-devel
dnf -y install ksh
dnf -y install libaio
dnf -y install libXrender
dnf -y install libX11
dnf -y install libXau
dnf -y install libXi
dnf -y install libXtst
dnf -y install libgcc
dnf -y install libnsl
dnf -y install libstdc++
dnf -y install libxcb
dnf -y install libibverbs
dnf -y install make
dnf -y install policycoreutils
dnf -y install policycoreutils-python-utils
dnf -y install smartmontools
dnf -y install sysstat
dnf -y install autoconf
dnf -y install automake
dnf -y install binutils-devel
dnf -y install bison
dnf -y install dos2unix
dnf -y install ftp
dnf -y install gcc
dnf -y install gcc-c++
dnf -y install lrzsz
dnf -y install python-devel
dnf -y install numactl
dnf -y install numactl-devel
dnf -y install unixODBC
dnf -y install unixODBC-devel
dnf -y install unzip
dnf -y install *vnc*
dnf -y install cmake
dnf -y install readline
dnf -y install readline-devel
dnf -y install kmod
dnf -y install kmod-libs
--下列包需要单独下载
rpm -ivh libnsl-2.28-49.p02.ky10.x86_64.rpm
--nodeps --force
rpm -ivh rlwrap-0.45.2-1.el8.x86_64.rpm
--nodeps --force
##设置主机名
hostnamectl set-hostname shhs52
hostname
##设置hosts
echo "192.168.1.52 shhs52"
>> /etc/hosts
cat /etc/hosts
##设置英文环境
echo "export LANG=en_US.UTF-8"
>> ~/.bash_profile
cat ~/.bash_profile
##配置目录
mkdir /oracle
mkdir /oradata
mkdir /backup
mkdir /archive
##配置用户和组
/usr/sbin/groupadd -g 60001 oinstall
/usr/sbin/groupadd -g 60002 dba
/usr/sbin/groupadd -g 60003 oper
useradd -u 61001 -g oinstall -G dba,oper
oracle
#passwd oracle
echo "oracle" | passwd --stdin
oracle
echo "oracle ALL=(ALL)
NOPASSWD:ALL" >> /etc/sudoers
##创建目录和权限
mkdir -p /oracle
mkdir -p /oracle/app/oracle/product/11.2.0
mkdir -p /oracle/app/oraInventory
chown -R oracle:oinstall /oracle
chown -R oracle:oinstall /oradata
chown -R oracle:oinstall /archive
chown -R oracle:oinstall /backup
chmod -R 775 /oracle
chmod -R 775 /oradata
chmod -R 775 /archive
chmod -R 775 /backup
##配置系统限制
cat << EOF >>
/etc/security/limits.conf
#ORACLE SETTING
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 16384
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 6000000
oracle soft memlock 6000000
EOF
cat /etc/security/limits.conf
echo "* soft nproc 16384" >
/etc/security/limits.d/20-nproc.conf
cat /etc/security/limits.d/20-nproc.conf
echo "session required
pam_limits.so" >> /etc/pam.d/login
cat /etc/pam.d/login
##修改内核参数,物理内存8G
cat
<< EOF >> /etc/sysctl.conf
#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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 = 1048586
kernel.panic_on_oops = 1
kernel.shmmax = 5033164800
kernel.shmall = 2097152
kernel.shmmni = 4096
vm.nr_hugepages = 2500
EOF
cat /etc/sysctl.conf
sysctl -p
##关闭透明页
cat
<< EOF >>
/etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled;
then
echo never >
/sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f
/sys/kernel/mm/transparent_hugepage/defrag; then
echo never >
/sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
cat /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
##关闭NUMA功能
sed -ie 's/rhgb quiet/rhgb quiet
numa=off/g' /etc/default/grub
cat /etc/default/grub
grub2-mkconfig -o /etc/grub2.cfg
##关闭selinux
sed
's/SELINUX=enforcing/SELINUX=disabled/g' -i /etc/selinux/config
setenforce 0
##关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
#systemctl status firewalld.service
##配置oracle环境变量
cat << EOF >>
/home/oracle/.bash_profile
export
PS1="[\`whoami\`@\`hostname\`:"'\$PWD]\$'
export TMP=/tmp
export TMPDIR=\$TMP
export LANG=en_US.UTF-8
#export LANG=zh_CN.UTF-8
export ORACLE_UNQNAME=shhsdb
export ORACLE_SID=shhsdb
export ORACLE_BASE=/oracle/app/oracle
export
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_TERM=xterm
export NLS_DATE_FORMAT="yyyy-mm-dd
HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.UTF8
export
PATH=.:\$PATH:\$HOME/.local/bin:\$HOME/bin:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:/usr/ccs/bin
export THREADS_FLAG=native
umask=022
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
EOF
cat
/home/oracle/.bash_profile
----------------------------------------------------------------------------Oracle
11gr2 11.2.0.4安装,补丁231018
----------------------------------------------------------------------------
--安装包及补丁名称有改动,网上搜索请用名称中的数字进行搜索
###上传软件并解压
#上传至backup文件夹
p13390677_112040_Linux-x86-64_database.zip
Opatch_11.2.0.3.39_Linux.zip
DB_PSU_p34386237_112040_Linux-x86-64.zip
p33991024_11204220118_Generic.zip
su - root
cd /backup
unzip p13390677_112040_Linux-x86-64_database.zip
unzip Opatch_11.2.0.3.39_Linux.zip
unzip
DB_PSU_p34386237_112040_Linux-x86-64.zip
unzip p33991024_11204220118_Generic.zip
chown -R oracle:oinstall /backup
chmod -R 775 /backup
##替换unzip,oracle11g自带的unzip安装会出错
su - oracle
cd /backup/database/install
mv unzip unzip.bak
ln -s /usr/bin/unzip .
## 1.安装
#配置11g_db_install.rsp
su - oracle
cat << EOF >
/home/oracle/11g_db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/app/oraInventory
SELECTED_LANGUAGES=zh_CN,en
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/oracle/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.isRACOneInstall=false
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.memoryOption=false
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.automatedBackup.enable=false
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
EOF
cat /home/oracle/11g_db_install.rsp
env|grep ORACLE
cd /backup/database
ls
./runInstaller -showProgress -silent -force -ignorePrereq -responseFile
/home/oracle/11g_db_install.rsp
## 2.打补丁
## 替换补丁工具Opatch
su - oracle
cd $ORACLE_HOME
ls
cd OPatch/
./opatch version
cd ..
mv OPatch OPatch.BAK
cp -r /backup/OPatch .
ls
opatch version
## 打DBPSU补丁34677698
#查看补丁readme
#验证补丁是否符合要求
su - oracle
cd /backup/34386237/
opatch prereq
CheckConflictAgainstOHWithDetail -ph ./
opatch apply
y
y
Do you want to proceed? [y|n]
y
忽略错误
## 打补丁one-off patch
33991024(关键)
cd /backup/33991024/
opatch prereq
CheckConflictAgainstOHWithDetail -ph ./
opatch apply
y
y
## 手工Relink(必须)
$ORACLE_HOME/bin/relink all
grep -in err
/oracle/app/oracle/product/11.2.0/db_1/install/relink.log
忽略错误
## 查看补丁信息
opatch lspatches
33991024;11204CERT ON OL8: LINKING ERRORS
DURING 11204 FOR DB INSTALL ON OL8.2
34386237;Database Patch Set Update :
11.2.0.4.221018 (34386237)
## 3.创建静态监听
su - oracle
netca
vi
/oracle/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = shhs52)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /oracle/app/oracle
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=shhsdb)
(SID_NAME=shhsdb)
(ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1)
)
)
lsnrctl start
lsnrctl status
## 4.创建实例
#配置11g_dbca.rsp
su - oracle
cat << EOF >
/home/oracle/11g_dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "shhsdb"
SID = "shhsdb"
TEMPLATENAME =
"General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION = /oradata
STORAGETYPE="FS"
CHARACTERSET="AL32UTF8"
NATIONALCHARACTERSET="UTF8"
DATABASETYPE = "MULTIPURPOSE"
TOTALMEMORY = "4800"
SAMPLESCHEMA=TRUE
EOF
cat /home/oracle/11g_dbca.rsp
dbca -silent -responseFile
/home/oracle/11g_dbca.rsp
# 检查服务名配置
vi
/oracle/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
SHHSDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = shhs52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = shhsdb)
)
)
#重启监听
lsnrctl stop
lsnrctl start
lsnrctl status
-------------------------------------------------------------------------
Oracle 11g 安装后设置
-------------------------------------------------------------------------
1.设置显示用户名和数据库名
vi $ORACLE_HOME/sqlplus/admin/glogin.sql
SET TERMOUT OFF
DEFINE sqlprompt=FgeduSQL
COLUMN sqlprompt NEW_VALUE sqlprompt
SELECT USER || '@' ||
NVL('&_CONNECT_IDENTIFIER', global_name )
sqlprompt
FROM global_name;
SET SQLPROMPT '&sqlprompt> '
UNDEFINE sqlprompt
SET TERMOUT ON
col NAME format a40
col VALUE format a60
col VALUE format 99999999999
set linesize 200
set pagesize 500
column plan_plus_exp format a80
set serveroutput on size 1000000
define_editor=vi
2.180天密码过期
select * from dba_profiles where
profile='DEFAULT';
alter profile default limit
PASSWORD_LIFE_TIME UNLIMITED;
3.关闭审计
show parameter audit;
alter system set audit_trail=none
scope=spfile;
shutdown immediate
startup
4.设置自动启动
# 设置dbstart、dbshut的80、50行
sed
's/ORACLE_HOME_LISTNER=\$1/ORACLE_HOME_LISTNER=\$ORACLE_HOME/g' -i /oracle/app/oracle/product/11.2.0/db_1/bin/dbstart
sed
's/ORACLE_HOME_LISTNER=\$1/ORACLE_HOME_LISTNER=\$ORACLE_HOME/g' -i
/oracle/app/oracle/product/11.2.0/db_1/bin/dbshut
# 设置开机自启动项
su - root
vi /etc/oratab
shhsdb:/oracle/app/oracle/product/11.2.0/db_1:Y
cat<<EOF>> /etc/rc.d/rc.local
su - oracle -lc
"/oracle/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
su - oracle -lc
"/oracle/app/oracle/product/11.2.0/db_1/bin/dbstart"
su - oracle -lc "/oracle/app/oracle/product/11.2.0/db_1/bin/emctl
start dbconsole"
EOF
ll /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
cat /etc/rc.d/rc.local
#reboot
----------------------------------------------------------------------------
Oracle 11g 简单操作
----------------------------------------------------------------------------
#创建数据库表、用户、授权
create tablespace itpux datafile '/oradata/shhsdb/itpux01.dbf' size 20m;
create user itpux identified by itpux123
default tablespace itpux;
grant dba to itpux;
#创建表
sqlplus "/as sysdba";
conn itpux/itpux123;
create table hs_itpuxt1(id number(12)
primary key, name varchar(20)) ;
insert into hs_itpuxt1
values(1,'hsxtitpux01');
insert into hs_itpuxt1
values(2,'hsxtitpux02');
commit;
select * from hs_itpuxt1;