Centos7.4 安装oracle-xe-11.2.0数据库

前言:swap交换空间问题,因为我们创建的centos有,所以后面忽略该步骤

一、创建Oracle相关的组和用户

groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle

[root@coqpva735-1 ~]# groupadd oinstall
[root@coqpva735-1 ~]# groupadd dba
[root@coqpva735-1 ~]# useradd -m -g oinstall -G dba oracle
[root@coqpva735-1 ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
[root@coqpva735-1 ~]# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

二、上传安装包到服务器

三、安装Oracle数据库过程

[root@coqpva735-1 install]# cd oracle-xe-11.2.0-1.0.x86_64.rpm/
[root@coqpva735-1 oracle-xe-11.2.0-1.0.x86_64.rpm]# cd Disk1/
[root@coqpva735-1 Disk1]# ls -l
total 309884
-rw-r--r-- 1 root root 317320273 Aug 28  2011 oracle-xe-11.2.0-1.0.x86_64.rpm
drwxr-xr-x 2 root root        20 Dec  5 17:31 response
drwxr-xr-x 2 root root        26 Dec  5 17:31 upgrade
[root@coqpva735-1 Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
执行安装后......
[root@coqpva735-1 Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing...                          ################################# [100%]
/var/tmp/rpm-tmp.KIHlFI: line 257: [: 18446744073692774399: integer expression expected
/var/tmp/rpm-tmp.KIHlFI: line 271: [: 18446744073692774399: integer expression expected
Updating / installing...
   1:oracle-xe-11.2.0-1.0             ################################# [100%]
Executing post-install steps...

You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
[root@coqpva735-1 Disk1]#
数据命令执行 /etc/init.d/oracle-xe configure
[root@coqpva735-1 Disk1]# /etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:
端口默认 回车
Specify a port that will be used for the database listener [1521]:
端口默认 回车
Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
输入密码 继续回车
Password can't be null.
Enter password:
Confirm the password:
开机启动Y 继续回车
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
等待初始化
Starting Oracle Net Listener...Done
Configuring database...
Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
直到完成!


四、配置系统环境变量

vi /etc/profile

加入下面
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME
ORACLE_SID=XE; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME
ORACLE_SID=XE; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


"/etc/profile" 133L, 2919C written


修改完后使用命令 # source /etc/profile 重新加载改文件。
输入 echo $ORACLE_BASE修改是否成功。

[root@coqpva735-1 Disk1]# echo $ORACLE_BASE
/u01/app/oracle


五、切换到oracle用户 使用sqlplus链接数据库

su - oracle
sqlplus /nolog
进入sqlplus控制台
SQL> connect as sysdba
提示输入用户名密码: 使用sys/password登录
测试:select sysdate from dual

[root@coqpva735-1 Disk1]# su oracle
[oracle@coqpva735-1 Disk1]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Sat Dec 29 18:17:01 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> connect as sysdba
Enter user-name: sys/123456Ab
Connected.
SQL> select sysdate from dual
  2 

五、防火墙设置

# firewall-cmd --zone=public --add-port=8080/tcp --permanent
# firewall-cmd --zone=public --add-port=1521/tcp --permanent
# firewall-cmd --reload
# systemctl restart firewalld

至此,XE数据库就起来了
起/停数据库
# /etc/init.d/oracle-xe start
# /etc/init.d/oracle-xe stop

注:使用pl/sql从主机连接虚拟机的oracle时,需把虚拟机的防火墙关掉,否则连接不上

六.Oracle账号密码过期期限设置
sys以sysdba身份登陆数据库
--查看指定概要文件(如default)的密码有效期设置
SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';
默认是180天

执行下面的语句可以修改未无限制的

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;


=============

修改密码
alter user cps identified by cps;


作者:andy_zhang

猜你喜欢

转载自blog.csdn.net/gmaaa123/article/details/86573068