[root@lucky ~]# uname -m
x86_64
[root@lucky ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@lucky ~]# cat /etc/hosts
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
172.16.97.103 lucky
127.0.0.1 lucky
vim /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
[root@lucky~]# service iptables stop
[root@lucky~]# systemctl stop firewalld
[root@lucky~]# systemctl disable firewalld
yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel numactl-devel sysstat unixODBC unixODBC-devel kernelheaders pdksh pcre-devel readline rlwrap
groupadd oinstall && groupadd dba && useradd -g oinstall -G dba oracle
echo "123456" | passwd --stdin oracle && id oracle
[root@lucky oracle]# cd /home/oracle
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
vim /etc/sysctl.conf
#添加以下内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
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 = 1048576
#使内核新配置生效
sysctl -p
vim /etc/security/limits.conf
#添加以下内容
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
vim /etc/pam.d/login
#添加以下内容
session required /lib64/security/pam_limits.so
session required pam_limits.so
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@lucky oracle]# free -m
total used free shared buff/cache available
Mem: 3789 206 190 908 3392 2414
Swap: 1959 0 1959
#我的是分配了2G,不够的使用以下命令分配
dd if=/dev/zero of=/swapadd bs=1024 count=2006424
mkswap /swapfile
swapon /swapfile
#编辑这个文件,增加以下内容
vim /etc/fstab
/swapfile swap swap default 0 0
mkdir -p /data/u01/software
cd /home/oracle
mv linux.x64_11gR2_database_* /data/u01/software/ && cd /data/u01/software
unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
mkdir -p /data/u01/app/oracle/product/11.2.0/dbhome_1
mkdir /data/u01/app/oracle/{oradata,inventory,fast_recovery_area}
chown -R oracle:oinstall /data/u01/app/oracle
chmod -R 775 /data/u01/app/oracle
su - oracle
vim .bash_profile
#添加以下内容
export ORACLE_BASE=/data/u01/app/oracle
export ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=$ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=american_america.AL32UTF8
#生效
source .bash_profile
cp -R /data/u01/software/database/response/ . && cd response/
vim db_install.rsp
#设置以下内容
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=自己的主机名
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/data/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
cd /data/u01/software/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
#当安装界面出现如下信息的时候 打开另一个终端窗口,用root连接
The installation of Oracle Database 11g was successful.
Please check '/home/oracle/oraInventory/logs/silentInstall2016-02-04_09-21-13AM.log' for more details.
As a root user, execute the following script(s):
1. /home/oracle/oraInventory/orainstRoot.sh
2. /home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh
Successfully Setup Software.
su - root
source .bash_profile
sh /data/u01/app/oracle/inventory/orainstRoot.sh
sh /data/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
egrep -v "(^#|^$)" /home/oracle/response/netca.rsp
#以静默方式配置监听
su - oracle
source .bash_profile
netca /silent /responsefile /home/oracle/response/netca.rsp
su - oracle
lsnrctl start
netstat -tunlp|grep 1521
#查看监听状态
lsnrctl status
#查看监听器配置文件 listener.ora
cat $ORACLE_HOME/network/admin/listener.ora
vim /home/oracle/response/dbca.rsp
设置以下参数
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "SYS 用户密码"
SYSTEMPASSWORD = "SYSTEM 用户密码"
SYSMANPASSWORD = "sysman"
DBSNMPPASSWORD = "dbsnmp"
DATAFILEDESTINATION =/data/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/data/u01/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "6144"
root@oracle ~]# egrep -v "(^#|^$)" /home/oracle/response/dbca.rsp
dbca -silent -responseFile /home/oracle/response/dbca.rsp
#查看监听器配置文件 listener.ora
cat $ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File: /data/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = lucky)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /data/u01/app/oracle
#查看监听服务名配置文件 tnsnames.ora
cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File:/data/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = lucky)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ps -ef | grep ora_ | grep -v grep
#查看 ORACLE_UNQNAME 环境变量
env|grep ORACLE_UNQNAME
lsnrctl stop
以 sysdba 身份登录
sqlplus / as sysdba
启动 oralce 数据库
SQL> shutdown immediate
SQL> startup
SQL> exit
lsnrctl start
lsnrctl status
3.14创建用户
[oracle@oracal ~]$ sqlplus / as sysdba
SQL> conn / as sysdba;
SQL> alter user lucky identified by 123456;
SQL> alter user lucky account unlock;
SQL> conn lucky/123456;
PS:如果本地客户端连接提示ora12170或者提示监听有误,去开启下服务器1521端口