• Commands used:
Windows probe port open:Telnet 114.67.110.190 1521 Permission denied Telnet 114.67.110.190 1521 Permission denied Telnet 114.67.110.190 1521 Permission denied $sudo chmod -r 777 myResources -r is used to cascade all subdirectories and files in the directoryCentOS 7 Start the Oracle database1. Switch user su - oracle to take effect of user environment variablescd /home/oracle
   source~/.bash_profile 2. Check listener LSNRCTL status -- Check status LSNRCTL start -- Start listener 3. Log in to SqlPlus SqlPlus/nOLOg 4. Log in to the conn/as sysdba database 5. Start the database startup 6. Check the oracle instance processes ps - ef | grep ora_ | grep -v grepCopy the code

####1. Oracle Database Software Downloads 11.2.0.1.0

Oracle 11g oracle 11g oracle 11g Oracle 11G oracle 11G

Download.oracle.com/otn/linux/o…
Download.oracle.com/otn/linux/o…

####2. Setting up an environment

Setup environment: Jingdong Cloud and centos7.6 vim /etc/hosts

192.168.1.1   ambari.master.com
If the vm is a virtual machine, use the Intranet IP address
At the beginning, I failed to use the Intranet IP address. Port 1521 could not be pinged. I searched for the reason for a long time
Copy the code
  • Install dependencies
  • Install PDKSH first

The centos7 installation package is not available. You can download the RPM package of PDKSH

Wget http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm RPM - the ivh PDKSH 5.2.14-37. El5_8. 1. X86_64. RPMCopy the code
  • Install additional dependencies
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
Copy the code
  • Check that all dependencies are installed properly
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"
Copy the code
  • Add oracle user groups and users
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle

Copy the code
  • Viewing an Oracle User
id oracle
Copy the code
  • Set the password for the Oracle user
passwd oracle
Copy the code
  • Optimizing the system kernel
vim /etc/sysctl.conf
# add the following parameters
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 2147483648
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=1048586
Kernel. Shmmax =210241024*1024=2147483648Make the parameters take effect sysctl -pCopy the code
  • Restrict shell permissions of Oracle users
vim /etc/security/limits.conf
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536

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
Copy the code
  • Create an Oracle directory
The mkdir -p/db/app/oracle/product / 11.2.0 mkdir/db/app/oracle/oradata mkdir/db/app/oracle/inventory mkdir /db/app/oracle/fast_recovery_area chown -R oracle:oinstall /db/app/oracle chmod -R 775 /db/app/oracle mkdir -p /u01/app/oracle/inventory chown -R oracle:oinstall /u01/app/oracle/inventoryCopy the code
  • Configure oracle user environment variables
su oracle
cd /home/oracle
vim .bash_profile

umask 022
export ORACLE_HOSTNAME=ambari.master.com
export ORACLE_BASE=/db/app/oracle
export ORACLE_HOME=$ORACLE_BASE/ product / 11.2.0 /export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"Effective immediately:source ~/.bash_profile
Copy the code
  • Decompress the installation package
If the installation package is installed as user root, switch to user root and run the su - root commandcd /opt/oracle

unzip linux.x64_11gR2_database_1of2.zip -d /db
unzip linux.x64_11gR2_database_2of2.zip -d /db

mkdir /db/etc/
cp /db/database/response/* /db/etc/

vim /db/etc/db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=trueUNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oracle/inventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOSTNAME=ambari.master.com ORACLE_HOME = / db/app/oracle/product / 11.2.0 ORACLE_BASE = / db/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba

Copy the code

3. Install oracle

Before installation, configure swap. Otherwise, Failed <<<< is displayed

Some requirement checks failed. You must fulfill these requirements before

continuing with the installation,

Error reference:

su - oracle
cd /db/database/
./runInstaller -silent -ignorePrereq -responseFile /db/etc/db_install.rsp



Install will take a few minutes
Add a command window and execute it

tail -f  /u01/app/oracle/inventory/logs/installActions2018-05-04_11-48-18AM.log

Copy the code

Execute the command as prompted

Su - root sh/u01 / app/oracle/inventory/orainstRoot. Sh sh/db/app/oracle/product / 11.2.0 / root. ShCopy the code
  • Configuring Silent Listening
su oracle
netca /silent /responsefile /db/etc/netca.rsp

Copy the code
  • View the listener port netstat tnulp | grep, 1521

  • Silently creating a database

vim /db/etc/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/db/app/oracle/oradata
RECOVERYAREADESTINATION=/db/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "3277"
# execute as user root (if not authorized)
chown -R oracle:oinstall /db/etc/dbca.rsp

Copy the code
  • Perform silent library building
dbca -silent -responseFile /db/etc/dbca.rsp

Then check the log to see if any errors are reported
vim /db/app/oracle/cfgtoollogs/dbca/orcl/orcl.log
# log as follows:

Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /db/app/oracle/cfgtoollogs/dbca/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
Copy the code

  • View the Oracle instance process
ps -ef | grep ora_ | grep -v grep
root@ambari:~# ps -ef | grep ora_ | grep -v grep
oracle     3531      1  0 05:48 ?        00:00:00 ora_pmon_orcl
oracle     3533      1 11 05:48 ?        00:00:12 ora_vktm_orcl
oracle     3537      1  0 05:48 ?        00:00:00 ora_gen0_orcl
oracle     3539      1  0 05:48 ?        00:00:00 ora_diag_orcl
oracle     3541      1  0 05:48 ?        00:00:00 ora_dbrm_orcl
oracle     3543      1  0 05:48 ?        00:00:00 ora_psp0_orcl
oracle     3545      1  0 05:48 ?        00:00:00 ora_dia0_orcl
oracle     3547      1 16 05:48 ?        00:00:17 ora_mman_orcl
oracle     3549      1  0 05:48 ?        00:00:00 ora_dbw0_orcl
oracle     3551      1  0 05:48 ?        00:00:00 ora_lgwr_orcl
oracle     3553      1  0 05:48 ?        00:00:00 ora_ckpt_orcl
oracle     3555      1  0 05:48 ?        00:00:00 ora_smon_orcl
oracle     3557      1  0 05:48 ?        00:00:00 ora_reco_orcl
oracle     3559      1  1 05:48 ?        00:00:01 ora_mmon_orcl
oracle     3561      1  0 05:48 ?        00:00:00 ora_mmnl_orcl
oracle     3563      1  0 05:48 ?        00:00:00 ora_d000_orcl
oracle     3565      1  0 05:48 ?        00:00:00 ora_s000_orcl
oracle     3615      1  0 05:48 ?        00:00:00 ora_qmnc_orcl
oracle     4088      1  1 05:48 ?        00:00:00 ora_cjq0_orcl
oracle     4121      1  0 05:48 ?        00:00:00 ora_q000_orcl
oracle     4134      1  0 05:48 ?        00:00:00 ora_q001_orcl
Copy the code
  • Listening to the
lsnrctl status 
lsnrctl stop
lsnrctl statr
Copy the code

  • Log in to Oracle and test
sqlplus / as sysdba
select status from v$instance;
Copy the code

  • Various errors and solutions
Checking swap space sqlplus/as sysdba startup [centos 0 MB available, 150 MB required. Failed < < < <] solve reference address: (https://www.cnblogs.com/a9999/p/6957280.html).# error
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/ db/app/oracle/product / 11.2.0 / DBS/initORCL ora'

cd $ORACLE_BASE/admin/orcl/pfile/
# View the file belowCp./ File name$ORACLE_HOME/dbs/initORCL.ora

# to startup
# error
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
su - root
mount -t tmpfs shmfs -o size=7g /dev/shm

# to startup
# error
SQL> startup
ORACLE instance started.

Total System Global Area 1720328192 bytes
Fixed Size		    2214056 bytes
Variable Size		 1006634840 bytes
Database Buffers	  704643072 bytes
Redo Buffers		    6836224 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode

Close the database first
shutdown immediate
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.

su - root

cd/ db/app/oracle/product / 11.2.0 / DBS fuser -k lkORCL error: fuser:commandNot found yum install - y psmisc/db/app/oracle/product / 11.2.0 / DBS/lkORCL: 2933 2939 2943 2945 2949 2951 2953 2955 2957 2959 2961 2963 3138 3140 3142 3144 3341 3343 3345 3869 3961 Run the fuser -u command again LkORCL does not have any outputRun the startup command

SQL> startup
ORACLE instance started.

Total System Global Area 1720328192 bytes
Fixed Size		    2214056 bytes
Variable Size		 1006634840 bytes
Database Buffers	  704643072 bytes
Redo Buffers		    6836224 bytes
Database mounted.
Database opened.
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNSforLinux: Version 11.2.0.1.0 - Production Version 11.2.0.1.0 - Production SQL>Copy the code
  1. Oracle Changes the passwords of the SYS and system users

concept

The SYS user is the most privileged user in Oracle, while the SYSTEM user is used for database administration. To ensure database security, change the passwords of the SYS and SYSTEM users immediately after the database is installed.

###### How to change the password after the installation

In fact, this was not successfully modified

SQL> alter user Scott identified by ZPF 2 ^C alter user Scott identified by ZPF 2 ^CCopy the code
On the cli, enter sqlplus/as sysdba. SQL>alter user SYS identified by huozhe SQL>grant connect to SYS identified by 123456 Password of system New password: Retype new password: password has been changed (Note: Method 3 only applies to system) Verify: SQL> conn System/Huozhe is connected. SQL> conn sys/"123456"As sysdba SQL> show user user is"SYSTEM"

SQL> exit
Copy the code

Problem: Linux uses source every time ~/.bash_profile is configured for Oracle

Solution:

Bashrc in root mode. Bash_profile or oracle mode#cd ~

#vim .bashrcAdded the following environment configurations:export ORACLE_BASE=/db/app/oracle

export ORACLE_HOME=$ORACLE_BASE/ product / 11.2.0 /export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export ORACLE_SID=orcl

export PS1='[\u@\h \W]\$'

export ORACLE_PID=orcl


:wq

source .bashrc

reboot
Copy the code

######5. Set the Oracle database to start automatically

1. After the Oracle database is installed, run dbstart and dbshut. Dbshut Dbstart cause: ORACLE_HOME_LISTNER in the dbstart and dbshut scripts is incorrect$ORACLE_HOME/bin/dbstart
 vim $ORACLE_HOME/bin/dbshut Open the two files respectively and change the following information: ORACLE_HOME_LISTNER=The $1Change the value to ORACLE_HOME_LISTNER=$ORACLE_HOMEMysql > start Oracle listener and instance automatically Vi/etc/oratab find: former: / db/app/oracle/product / 11.2.0: N is amended as: former: / db/app/oracle/product / 11.2.0: Y (the path associated with the installation path,$ORACLE_SID:$ORACLE_HOME: < N > | Y) CentOS 7 add startup services/script reference: https://www.jianshu.com/p/9cd8708422c0 Add the following command to the autostart.sh script su - oracle -lc"/ db/app/oracle/product / 11.2.0 / bin/LSNRCTL start"
su - oracle -lc "/ db/app/oracle/product / 11.2.0 / bin/dbstart"Note: The first action starts the database listening service upon startup and the second action starts the database upon startup. The path is related to the installation path. Reboot to see oracle instance processes ps - ef | grep ora_ | grep -v grep view listening state: LSNRCTL status LSNRCTL stop LSNRCTL statrCopy the code

Example Modify the Oracle database character set

SQL> conn system as sysdba; SQL> shutdown immediate; SQL> startup mount; SQL> alter system enable restricted session; SQL> alter system set job_queue_processes=0; SQL> alter database open; SQL> alter database character set internal_use AL32UTF8; SQL> shutdown immediate; SQL> startup

#### Main reference articles:

CentOS 7 Installing Oracle11 CentOS 7 Silent (no GUI) Installing Oracle 11G CentOS 7 Starting the Oracle Database Set the Oracle database to automatically start Linux ~/.bash_profile: oracle character set () : oracle character set () : oracle character set ()

After # #