该软件是数据库免费版本,也称简化版,主要的限制为:
1、最大数据库大小是11GB
2、可使用的最大内存是1G
3、一个机器只能安装一个XE实例
4、XE只能使用单CPU
https://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip?AuthParam=1610681219_4130b4f7d59b1e42ece4a0d345b2eac2
下载后上传至需要安装的服务器
swap 空间至少为2G
1、查看当前swap空间
[root@VM-0-15-centos ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 299M 73M 458M 1.4G 927M
Swap: 3.0G 49M 3.0G
[root@VM-0-15-centos ~]#
看其中 swap 的total大小,最低要求为2G
2、关闭所有交换分区
[root@VM-0-15-centos ~]# swapoff -a
3、分配 swap 大小,总内存=bs*count
[root@VM-0-15-centos ~]# dd if=/dev/zero of=/swapfile bs=3M
count=1024
4、 配置权限为600
[root@VM-0-15-centos ~]# chmod 600 /swapfile
5、格式化 swap 分区文件
[root@VM-0-15-centos ~]# mkswap /swapfile
6、添加开机启动该分区
[root@VM-0-15-centos ~]# vim /etc/fstab
增加一行内容:/swapfile swap swap defaults 0 0
7、文件内容如下
[root@VM-0-15-centos ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Mar 7 06:38:37 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4b499d76-769a-40a0-93dc-4a31a59add28 / ext4 defaults 1 1
tmpfs /dev/shm tmpfs defaults,size=2048M 0 0
/swapfile swap swap defaults 0 0
8、启动swap 分区
[root@VM-0-15-centos ~]# swapon /swapfile
[root@VM-0-15-centos ~]#
查看是否生效
[root@VM-0-15-centos ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 301M 74M 458M 1.4G 925M
Swap: 3.0G 49M 3.0G
[root@VM-0-15-centos ~]#
[root@VM-0-15-centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 909M 0 909M 0% /dev
tmpfs 920M 459M 461M 50% /dev/shm
tmpfs 920M 852K 919M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/vda1 50G 26G 22G 54% /
tmpfs 184M 0 184M 0% /run/user/0
tmpfs 184M 0 184M 0% /run/user/6000
[root@VM-0-15-centos ~]#
确保磁盘空间大于3G, tmpfs 最低要求为1G
1、编辑文件,增加调整的内容
[root@VM-0-15-centos ~]# vim /etc/fstab
增加一行:tmpfs 2.0G 0 2.0G 0% /dev/shm
2、卸载挂载
[root@VM-0-15-centos ~]# umount /dev/shm
3、重新挂载
[root@VM-0-15-centos ~]# mount /dev/shm/
4、查看是否调整成功
[root@VM-0-15-centos ~]# df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs 2.0G 0 2.0G 0% /dev/shm
[root@VM-0-15-centos ~]#
[root@VM-0-15-centos ~]# vim /etc/security/limits.conf
添加下列内容:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
[root@VM-0-15-centos ~]# vim /etc/sysctl.conf
添加下列内容:
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
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
使之生效执行:
[root@VM-0-15-centos ~]# sysctl -p
[root@VM-0-15-centos ~]# vim /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
刷新使之生效
[root@VM-0-15-centos ~]# source /etc/profile
[root@VM-0-15-centos ~]# groupadd -g 6000 oracle
[root@VM-0-15-centos ~]# useradd -d /home/oracle/ -g 6000 oracle
[root@VM-0-15-centos ~]# chown oracle.orace /home/oracle/ -R
[root@VM-0-15-centos ~]# id oracle
uid=6000(oracle) gid=6000(oracle) groups=6000(oracle),7001(dba)
[root@VM-0-15-centos ~]#
修改linux用户登录密码
[root@VM-0-15-centos ~]# passwd oracle
[oracle@VM-0-15-centos ~]$ unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
[oracle@VM-0-15-centos ~]$ ls
Disk1 oracle-xe-11.2.0-1.0.x86_64.rpm.zip oradiag_oracle
[oracle@VM-0-15-centos ~]$ cd Disk1/
[oracle@VM-0-15-centos Disk1]$ ls
n oracle-xe-11.2.0-1.0.x86_64.rpm response upgrade
[oracle@VM-0-15-centos Disk1]$
[root@VM-0-15-centos Disk1]# rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to
configure the database.
[root@VM-0-15-centos Disk1]# ls
oracle-xe-11.2.0-1.0.x86_64.rpm response upgrade
根据提示输入,http默认端口、数据库端口、管理员密码,稍等显示为安装成功
[root@VM-0-15-centos Disk1]# /etc/init.d/oracle-xe configure
[root@VM-0-15-centos Disk1]# /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g
ExpressEdition. 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 to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application
Express [8080]:6001
Specify a port that will be used for the database listener
[1521]: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:
The password you entered contains invalid characters. Enter password:
Confirm the password:
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.
[root@VM-0-15-centos ~]# cd /u01/app/oracle/
[root@VM-0-15-centos oracle]# ls
admin diag fast_recovery_area oradata product
[root@VM-0-15-centos oracle]#
[root@VM-0-15-centos oracle]# vim /etc/profile
添加以下内容:
export ORACLE_BASE=/u01/app/oracle
# oracle 主目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe
#数据库实例ID
export ORACLE_SID=XE
# 当地语言
export NLS_LANG=zh_CN.UTF-8
# sql命令行查找*.sql文件
export SQLPATH=$ORACLE_HOME/sqlplus/admin
# oracle可执行命令路径
export PATH=$PATH:$/HOME/bin:$ORACLE_HOME/bin
# 查找路径共享库
export LD_LIBERRAY_PATH=$ORACLE_HOME/lib:/usr/lib
[root@VM-0-15-centos oracle]# source /etc/profile
oracle
用户,登录测试[root@VM-0-15-centos oracle]# su - oracle
Last login: Tue Jan 19 18:35:54 CST 2021 on pts/5
[oracle@VM-0-15-centos ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jan 19 18:52:17 2021
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn sys/as sysdba
Enter password:
Connected to an idle instance.
SQL>
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
启动
数据库实例SQL> conn /as sysdba
Connected to an idle instance.
SQL> show parameter service_name
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
SQL> startup
ORACLE instance started.
Total System Global Area 768294912 bytes
Fixed Size 2230448 bytes
Variable Size 457181008 bytes
Database Buffers 306184192 bytes
Redo Buffers 2699264 bytes
Database mounted.
Database opened.
SQL>
SQL> SHUTDOWN IMMEDIATE
SQL> create tablespace interface datafile '/u01/app/oracle/oradata
/XE/interface.dbf' size 700m autoextend on next 100m maxsize
unlimited;
Tablespace created.
SQL>
SQL> alter user test default tablespace interface;
User altered.
SQL>
SQL> CREATE USER test IDENTIFIED BY test;
User created.
SQL> grant connect,resource to test;
Grant succeeded.
SQL> grant unlimited tablespace to test;
Grant succeeded.
SQL> grant create database link to test;
Grant succeeded.
SQL> grant select any sequence,create materialized view to test;
Grant succeeded.
SQL>
至此,客户端工具可以通过用户 test/test 进行连接oracle数据库了
[root@VM-0-15-centos ~]# sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jan 19 22:37:21 2021
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn test/test
Connected.
SQL>
或者指定用户、密码、ip、端口、服务名
CONNECT username/password@[//]host[:port][/service_name]
SQL> conn test/[email protected]:1521/xe
Connected.
SQL>
[root@VM-0-15-centos log]# pwd
/u01/app/oracle/product/11.2.0/xe/config/log
[root@VM-0-15-centos log]# ls
cloneDBCreation.log CloneRmanRestore.log postDBCreation.log
postScripts.log
[root@VM-0-15-centos log]#
1、删除关于oracle安装或创建的所有目录
[root@VM-0-15-centos 11.2.0]# rm -rf /u01/app/oracle/
[root@VM-0-15-centos 11.2.0]# rm /etc/ora
oraInst.loc oratab
[root@VM-0-15-centos 11.2.0]# rm /etc/ora
oraInst.loc oratab
[root@VM-0-15-centos 11.2.0]# rm /etc/oratab /etc/oraInst.loc
[root@VM-0-15-centos oracle]# rm -rf Disk1/
[root@VM-0-15-centos oracle]# rm -rf oradiag_oracle/
2、卸载安装的数据库
[root@VM-0-15-centos Disk1]# rpm -qa |grep oracle
oracle-xe-11.2.0-1.0.x86_64
[root@VM-0-15-centos Disk1]# rpm -e oracle-xe
3、如果想重新安装,可以不用删除创建的oracle用户和组
监听器用于监听本地或远程访问数据库的连接
[root@VM-0-15-centos ~]# lsnrctl status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production
on 19-JAN-2021 22:54:25
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)
(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 19-JAN-2021 17:06:56
Uptime 0 days 5 hr. 47 min. 29 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network
/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/VM-0-15-centos
/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=VM-0-15-centos)
(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=VM-0-15-centos)
(PORT=6001))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this
service...
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
[root@VM-0-15-centos ~]#
注意
(port=1521) 表示该监听器正在监听通过oracle net 1521端口建立的连接
(PORT=8080))(Presentation=HTTP)
该监听器正在监听通过http 端口6001建立的数据库连接
Service "XE" has 1 instance(s) and Instance "XE", status READY
表示:oracle 数据库XE已经注册了监听,正在等待接受连接
[root@VM-0-15-centos ~]# LSNRCTL START
[root@VM-0-15-centos ~]# LSNRCTL STOP
注意
当数据库正在启动运行的时候,停止监听再启动,将会花费一些时间来重新注册
数据库监听和接受连接,可以通过 LSNRCTL STATUS 命令来观察实际状态,直
到出现如:
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
1、停止当前监听:LSNRCTL STOP
2、打开文件 /usr/lib/oracle/xe/app/oracle/product/11.2.0
/server/network/admin/listener.ora
3、找到如下内容:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
)
)
4、变更文本(PORT = 1521)为(PORT = 1522)
5、保存文件,并重新启动监听:LSNRCTL START
6、使用管理员账号登录连接数据库
7、执行如下内容:
ALTER SYSTEM SET LOCAL_LISTENER = "(ADDRESS=(PROTOCOL=TCP)
(HOST=VM-0-15-centos)(PORT=1522))";
ALTER SYSTEM REGISTER;
8、退出sql窗口,查看监听状态:LSNRCTL STATUS
ALTER USER SYS IDENTIFIED BY newpassword;
ALTER USER SYSTEM IDENTIFIED BY newpassword;
SQL> @?/apex/apxconf.sql
PORT
----------
6001
Enter values below for the XDB HTTP listener port and the password
for the Application Express ADMIN user.
Default values are in brackets [ ].
Press Enter to accept the default value.
Enter a password for the ADMIN user []
Enter a port for the XDB HTTP listener [ 6001]
...changing HTTP Port
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Session altered.
...changing password for ADMIN
PL/SQL procedure successfully completed.
Commit complete.
SQL>
1、SQL> @?/rdbms/admin/epgstat.sql
2、调整端口
SQL> begin
2 dbms_xdb.setHTTPPort(6060);
3 commit;
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select dbms_xdb.getHTTPPort from dual;
GETHTTPPORT
-----------
6060
3、SQL> ALTER USER ANONYMOUS ACCOUNT UNLOCK;
4、修改密码
SQL> @?/apex/apxchpwd.sql
Enter a value below for the password for the Application Express
ADMIN user.
Enter a password for the ADMIN user []
Session altered.
...changing password for ADMIN
PL/SQL procedure successfully completed.
Commit complete.
5、关闭匿名访问
SQL> begin
2 DBMS_XDB.SETLISTENERLOCALACCESS (FALSE);
3 end;
4 /
PL/SQL procedure successfully completed.
SQL>
6、重新加载监听
[root@VM-0-15-centos ~]# lsnrctl reload
7、页面访问地址:http://81.68.169.2:6060/apex/apex_admin