安装rlwrap 解压编译 tar zxf rlwrap-0.43.tar.gz cd rlwrap-0.43 编译安装到指定目录 yum -y install readline-devel(需要先装下这个) ./configure --prefix=/data/software/rlwrap-0.43 make make install 配置环境变量

  • 追加rlwrap命令到PATH路径, 同时设置别名 vi ~/.bash_profile export PATH=/data/software/rlwrap-0.43/bin:$PATH alias sqlplus="rlwrap sqlplus"
  • 生效环境变量 source ~/.bash_profile

oracle安装:https://www.cnblogs.com/ghl1024/p/9008483.html

一、CentOS7.2静默安装Oracle11G 1.#查看系统性能参数 cat /etc/sysctl.conf  2.#查看安装包 rpm -qa |grep -E 'EMC|Ultra|multipath'  3.#安装依赖包 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

4.#创建用户、组 groupadd oinstall && groupadd dba && useradd -g oinstall -G dba oracle echo "1hbl#QT2YnYp" | passwd --stdin oracle && id oracle 5.#上传软件包 http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html [linux.x64_11gR2_database_1of2.zip] [linux.x64_11gR2_database_2of2.zip] 可以下载到本地通过ftp上传到虚拟机中,也可以使用wget命令,下载到虚拟机中。  6.#创建安装包文件存放目录 mkdir -p /data/data/software mv linux.x64_11gR2_database_* /data/data/software/ && cd /data/data/software 7.#解压安装包文件 unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip 8.#创建目录 mkdir -p /data/data/app/oracle/product/11.2.0/dbhome_1 mkdir /data/data/app/oracle/{oradata,inventory,fast_recovery_area} chown -R oracle:oinstall /data/data/app/oracle chmod -R 775 /data/data/app/oracle 9.#修改内核参数 vi /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 10.#修改用户限制 vi /etc/security/limits.conf #添加以下内容 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 sysctl -p

11.#修改/etc/pam.d/login 文件 vi /etc/pam.d/login #添加以下内容 session required /lib64/security/pam_limits.so session required pam_limits.so   12.#修改/etc/profile 文件 vi /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 source /etc/profile 13.#设置 oracle 用户环境变量 su - oracle vi .bash_profile #添加以下内容 export ORACLE_BASE=/data/data/app/oracle export ORACLE_HOME=/data/data/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 alias sqlplus='rlwrap sqlplus' alias rman='rlwrap rman' #生效 source .bash_profile 14.#编辑静默安装响应文件 cp -R /data/data/software/database/response/ . && cd response/ vi db_install.rsp #设置以下内容 oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=自己的主机名 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/data/data/app/oracle/inventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/data/data/app/oracle/product/11.2.0/dbhome_1 ORACLE_BASE=/data/data/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba DECLINE_SECURITY_UPDATES=true  15.#安装 cd /data/data/software/database/ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq 等待几分钟   16.#以 root 身份执行脚本 su - root source .bash_profile sh /data/data/app/oracle/inventory/orainstRoot.sh sh /data/data/app/oracle/product/11.2.0/dbhome_1/root.sh vi /etc/hosts 127.0.0.1 后面加上主机名   17.#查看监听响应文件配置信息 egrep -v "(^#|^$)" /home/oracle/response/netca.rsp #以静默方式配置监听 su - oracle source .bash_profile netca /silent /responsefile /home/oracle/response/netca.rsp 18.#用Oracle用户启动 su - oracle lsnrctl start netstat -tunlp|grep 1521 #查看监听状态 lsnrctl status #查看监听器配置文件 listener.ora cat $ORACLE_HOME/network/admin/listener.ora #查看监听服务名配置文件 tnsnames.ora cat $ORACLE_HOME/network/admin/tnsnames.ora
19.#配置文件 vi /home/oracle/response/dbca.rsp 设置以下参数 GDBNAME = "orcl" SID = "orcl" SYSPASSWORD = "1hbl#QT2YnYp" SYSTEMPASSWORD = "1hbl#QT2YnYp" SYSMANPASSWORD = "sysman" DBSNMPPASSWORD = "dbsnmp" DATAFILEDESTINATION =/data/data/app/oracle/oradata RECOVERYAREADESTINATION=/data/data/app/oracle/fast_recovery_area CHARACTERSET = "AL32UTF8" TOTALMEMORY = "6144"  

20.#查看建库响应文件配置信息 [root@oracle ~]# egrep -v "(^#|^$)" /home/oracle/response/dbca.rsp image.png 21. 进su - oracle用户启用配置建立新库和实例,root启动不成功 dbca -silent -responseFile /home/oracle/response/dbca.rsp
image.png 说明已启动成功 22.#检查实例后台进程 ps -ef | grep ora_ | grep -v grep #查看 ORACLE_UNQNAME 环境变量 env|grep ORACLE_UNQNAME 23.#以 sysdba 身份登录 sqlplus / as sysdba
如果非要输入用户名和passwd,那么用户名就是sys,passwd就是sys用户的passwd: sqlplus sys/sys as sysdba或sqlplus sys/ as sysdba

24.#启动 oralce 数据库 SQL> startup ORA-00845: MEMORY_TARGET not supported on this system

image.png

检查已经被锁定的用户 select username,account_status from dba_users;

解锁被锁定的账户 alter user username account unlock; select user from dual; 修改passwd alter user username identified by passwd;