- 创建 Oracle 用户及组、授权文件夹:
创建组、用户并添加到组:
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
修改用户密码:
passwd oracle
创建文件夹并授权:
mkdir -p /u01/app
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app/
- 修改 /etc/yum.conf,将缓存 yum 安装文件:
缓存 yum 安装文件可用于离线安装。
vi /etc/yum.conf
将 keepcache 设置为 1
keepcache=1
- 安装 vim、wget:
yum -y install vim
- 安装 CentOS 可视化桌面:
yum -y groups install 'GNOME Desktop'
- 设置默认开机为可视化桌面:
systemctl set-default graphical.target
关闭默认开机可视化桌面(设置开机为命令桌面):
systemctl set-default multi-user.target
- 开启可视化桌面:
关闭命令后将关闭可视化桌面:
startx
后台运行可视化桌面:
systemctl start graphical.target
- 安装 VNC:
yum -y install tigervnc-server
- 启动VNC并设置密码:
- 设置 root 用户的 VNC 密码:
登陆 root:
未设置只读密码:
[root@localhost ~]# vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[root@localhost ~]#
- 设置 oracle 用户的 VNC 密码:
登陆 oracle:
未设置只读密码:
[root@localhost ~]# su oracle
[oracle@localhost root]$ vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
xauth: file /home/oracle/.Xauthority does not exist
New 'localhost.localdomain:2 (oracle)' desktop is localhost.localdomain:2
Creating default startup script /home/oracle/.vnc/xstartup
Creating default config /home/oracle/.vnc/config
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/localhost.localdomain:2.log
[oracle@localhost root]$
- 创建窗口 1、2 的开机启动:
窗口 1 可用于连接 root 桌面;
窗口 2 可用于连接 oracle 桌面。
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
- 修改窗口 1、2 的开机启动:
将 vncserver@:1.service 中的 <USER> 修改为 root:
vim /etc/systemd/system/vncserver@:1.service
将 vncserver@:1.service 中的 <USER> 修改为 oracle:
vim /etc/systemd/system/vncserver@:2.service
- 设置窗口 1、2 的开机启动:
systemctl enable vncserver@:1.service
systemctl enable vncserver@:2.service
- 开启窗口 1、2:
systemctl start vncserver@:1.service
systemctl start vncserver@:2.service
- 开启5900+?端口:
开启窗口 1,开放端口5901(即5900+1):
开启窗口 2,开放端口5902(即5900+2):
开启端口 5901、5902(需要开启防火墙):
firewall-cmd --zone=public --add-port=5901/tcp --permanent
firewall-cmd --zone=public --add-port=5902/tcp --permanent
- 重新加载防火墙:
firewall-cmd --reload
- 查看已开放端口及服务:
firewall-cmd --list-all
- 打开 VNC,输入地址:
- 点击回车,选择 continue:
- 输入密码,点击 OK:
- 连接成功后显示:
- 输入密码后登陆:
- 登陆后显示:
设置语言:
- 桌面显示如下:
- 相同操作,可登陆 oracle 用户。
- 上传解压 Oracle 11.2.0.4.0 至 /u01 文件夹。
- 上传解压 jdk1.8 至 /u01 文件夹。
- 添加字体,防止安装过程乱码:
mkdir -p /usr/share/fonts/zh_CN/TrueType
cd /usr/share/fonts/zh_CN/TrueType
上传 zysong.ttf 至文件夹 /usr/share/fonts/zh_CN/TrueType 并授权:
chmod -R 75 zysong.ttf
- 使用 VNC 登陆 oracle 用户。
- 设置临时语言为中文并运行安装Oracle:
[oracle@localhost ~]$ LANG=zh_CN.UTF-8
[oracle@localhost ~]$ locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
[oracle@localhost ~]$ cd /u01/database/
[oracle@localhost database]$ ./runInstaller -jreLoc /u01/jdk1.8.0_231/
正在启动 Oracle Universal Installer...
检查临时空间: 必须大于 120 MB。 实际为 27021 MB 通过
检查交换空间: 必须大于 150 MB。 实际为 2039 MB 通过
检查监视器: 监视器配置至少必须显示 256 种颜色。 实际为 16777216 通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2020-06-06_03-17-12PM. 请稍候...[oracle@localhost database]$
- 点击下一步:
- 点击是:
- 跳过软件更新,点下一步:
- 点击下一步:
- 选择服务器类,点下一步:
- 点击下一步:
- 选择高级安装,点下一步:
- 点击下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 点下一步:
- 启用自动备份,点下一步:
- 点下一步:
- 点下一步:
- 检查依赖的结果:
- 点击修补并再次检查:
保存 /tmp/CVU_11.2.0.4.0_oracle 文件夹中的内容可用于静默安装。
- 使用 root 运行脚本:
sh /tmp/CVU_11.2.0.4.0_oracle/runfixup.sh
运行结果:
[root@localhost TrueType]# sh /tmp/CVU_11.2.0.4.0_oracle/runfixup.sh
Response file being used is :/tmp/CVU_11.2.0.4.0_oracle/fixup.response
Enable file being used is :/tmp/CVU_11.2.0.4.0_oracle/fixup.enable
Log file location: /tmp/CVU_11.2.0.4.0_oracle/orarun.log
Setting Kernel Parameters...
/tmp/CVU_11.2.0.4.0_oracle/orarun.sh: line 246: [: 18446744073692774399: integer expression expected
The value for shmmax in response file is not greater than value of shmmax for current session. Hence not changing it.
The value for shmmni in response file is not greater than value of shmmni for current session. Hence not changing it.
/tmp/CVU_11.2.0.4.0_oracle/orarun.sh: line 337: [: 18446744073692774399: integer expression expected
The value for shmall in response file is not greater than value of shmall for current session. Hence not changing it.
The value for semmsl in response file is not greater than value of semmsl for current session. Hence not changing it.
The value for semmns in response file is not greater than value of semmns for current session. Hence not changing it.
The value for semmni in response file is not greater than value of semmni for current session. Hence not changing it.
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
The value for aio-max-nr in response file is not greater than value of aio-max-nr for current session. Hence not changing it.
uid=1001(oracle) gid=1003(oper) groups=1003(oper),1002(dba)
[root@localhost TrueType]#
- 点确定:
- 再次检查结果:
- 安装依赖:
yum -y install gcc libaio-devel elfutils-libelf-devel glibc-devel glibc-headers gcc-c++ libstdc++-devel
- 再次检查:
- 增加 1G 交换空间:
dd if=/dev/zero of=/home/swap bs=4096 count=250000
mkswap /home/swap
/sbin/swapon /home/swap
编辑 /etc/fstab :
vim /etc/fstab
增加:
/home/swap swap swap default 0 0
- 再次检查:
- 在 阿里巴巴开源镜像站 下载依赖:compat-libstdc++、pdksh
安装依赖:
[root@localhost TrueType]# cd /u01
[root@localhost u01]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
warning: pdksh-5.2.14-37.el5_8.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:pdksh-5.2.14-37.el5_8.1 ################################# [100%]
[root@localhost u01]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:compat-libstdc++-33-3.2.3-72.el7 ################################# [100%]
[root@localhost u01]#
- 再次检查,依赖完全解决,自动进入下一个页面,点安装:
保存此页面的响应文件,可用于静默安装。
- 安装过程遇见问题:
- 编辑文件 /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk:
/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk
修改:
$(SYSMANBIN)emdctl:
$(MK_EMAGENT_NMECTL)
为:
$(SYSMANBIN)emdctl:
$(MK_EMAGENT_NMECTL) -lnnz11
- 点击重试即可继续。
- 安装结束,可在此页面解锁 SCOTT 账户:
- 使用 root 运行脚本:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
运行结果:
[root@localhost u01]# /u01/app/oraInventory/orainstRoot.sh
更改权限/u01/app/oraInventory.
添加组的读取和写入权限。
删除全局的读取, 写入和执行权限。
更改组名/u01/app/oraInventory 到 dba.
脚本的执行已完成。
[root@localhost u01]# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@localhost u01]#
- 点击确定后显示:
Oracle 页面管理地址:https://localhost:1158/em
- 开通端口:
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --zone=public --add-port=1158/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
- 远程连接:
- 配置 oracle 用户环境变量(用于开机自启):
vim /home/oracle/.bash_profile
环境变量:
export ORACLE_BASE=/u01/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
- 修改 Oracle 软件环境变量(手动启动、用于开机自启):
- 修改 dbstart 文件:
vim /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbshut
修改:
ORACLE_HOME_LISTNER=$1
为:
ORACLE_HOME_LISTNER=$ORACLE_HOME
- 修改 /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart 文件同上。
- 开启开机自启:
- 修改:/etc/rc.d/rc.local
vim /etc/rc.d/rc.local
增加:
su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"
su oracle -lc "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart"
授权 /etc/rc.d/rc.local 为可执行文件:
chmod +x /etc/rc.d/rc.local
- 修改 /etc/oratab:
vim /etc/oratab
将:
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N
修改为:
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
- 重启后连接:
- 使用 oracle 用户查看监听:
lsnrctl status
运行结果:
[oracle@localhost root]$ source /home/oracle/.bash_profile
[oracle@localhost root]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-JUN-2020 16:52:12
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 06-JUN-2020 16:44:20
Uptime 0 days 0 hr. 7 min. 52 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost root]$
启动监听:
lsnrctl start
停止监听:
lsnrctl stop
- 操作数据库:
启动数据库:
dbstart
停止数据库:
dbshut