Installing Oracle is much more complicated than installing MySQL.
Basic configuration requirements:
1.1 Check memory, system architecture and disk before installation
1.2 For details, please refer to the official documentation: https://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#i1011296
installation steps:
2.1 Configure virtual memory: Because the memory of my Alibaba Cloud server is only 2G, it is not large enough. If the memory is greater than 4G, the virtual memory can be omitted.
2.2 Virtual memory display: # swapon -s
2.3 Memory usage: # free -m
If there is no prompt as above, it means that the swap partition (virtual partition, virtual memory) is not configured
2.4 Create the folder where the swap partition file is located: # mkdir -p / data1 / swapon
2.5 Create a swap partition file:
(If: read the file, of: write out the file, bs: each read and write byte size (block size), count: the number of blocks (unit: bytes))
(Where represents the swap partition of 1gb, the calculation rule = bs * count = about 1gb)
# dd if=/dev/zero of=/data1/swapon/SwapFile bs=1024 count=1024000
2.6 Convert the swap format file: # mkswap / data1 / swapon / SwapFile
2.7 Activate the file and use it: # swapon / data1 / swapon / SwapFile
2.8 Check the size of the virtual partition again: # swapon -s
2.9 In order to prevent restart problems: # vi / etc / fstab (modify this file)
Add at the end:
/data1/swapon/SwapFile swap swap default 0 0
Click x to save and exit
(
No cloud server required, virtual machine required
3.1 View the host name: cat / etc / hosts
3.2 Close selinux: vi / etc / sysconfig / selinux
Among them: Set SELINUX and SELINUXTYPE to SELINUX = disabled, SELINUXTYPE = targeted
Edit x to write and exit;
3.3 Turn off the firewall
# systemctl stop firewalld #stop firewall
# systemctl disable firewalld #Turn off the self-starting firewall service
# systemctl status firewalld #View firewall status
)
4. Install the dependency package corresponding to Oracle:
# yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel libXp*
5. Create a new user and the corresponding two user groups:
# groupadd oinstall # Create user group
# groupadd dba # Create user group
# useradd -g oinstall -G dba oracle # Create a user and set up a group
# passwd oracle # set oracle user password
6. Modify the kernel parameters:
6.1 # vi /etc/sysctl.conf
6.2 Add the following parameters:
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
Edit x to write and exit;
6.3 Make parameters effective: sysctl -p
7. Modify the user's restriction file
7.1 # vi /etc/security/limits.conf
7.2 Add parameters:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
Edit x to write and exit;
8. Modify the login information file:
8.1 # vi /etc/pam.d/login
8.2 Add parameters:
session required /lib64/security/pam_limits.so
session required pam_limits.so
Edit x to write and exit;
9. Modify the configuration file information:
9.1 # vi /etc/profile
9.2 Add parameters:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
be
be
Edit x to write and exit;
10. Create an installation directory and modify file permissions:
# mkdir -p /data0/oracle/product/11.2.0
# mkdir /data0/oracle/oradata
# mkdir /data0/oracle/inventory
# mkdir /data0/oracle/fast_recovery_area
# chown -R oracle:oinstall /data0/oracle
# chmod -R 777 /data0/oracle
11. Upload the software to / data0 / oracle, and switch to the root user to set the corresponding permissions:
# its
# chown -R oracle:oinstall /data0/oracle
# chmod -R 777 /data0/oracle
12. Switch oracle, configure the environment variables of the oracle user:
12.1
# su - oracle
# you .bash_profile
12.2 Add parameters:
ORACLE_BASE=/data0/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
Edit x to write and exit;
12.3 Make the command effective: source .bash_profile
13. Edit the response file for silent installation:
13.1 Switch to the root user and enter the directory / data0 / oracle / database / response / where the Oracle installation package is decompressed to back up the db_install.rsp file:
# its
Password: the password with the first letter capitalized
# vi /data0/oracle/database/response/db_install.rsp
13.2 Modify the following parameters:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME = Host name (iz2zef ...)
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data0/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data0/oracle/product/11.2.0
ORACLE_BASE=/data0/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
Edit x to write and exit;
14. Start installing Oracle11g:
# su - oracle
# cd /data0/oracle/database
# ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /data0/oracle/database/response/db_install.rsp
Oracle is installed silently in the background. During the installation process, if the prompt [WARNING] is ignored, the installation program is still in the background. If [FATAL] appears, the installation program has stopped.
At this time, open another terminal tab (another window), enter the prompted session log directory: ( Do not disconnect, just press Enter, here will normally be stuck for a long time, use the swap partition, swap partition Speed is slower than normal memory speed )
# tail –f /data0/oracle/inventory/logs/installActions2019-08-12_10-31-49PM.log
If you see the log file, the installation information will continue to be output. If no abnormal information is entered, it indicates that the installation process is normal; until the prompt of running script and Successfully Setup Software is output.
Follow the prompts to switch the root user to run the script:
# its
Password: the one with the first letter capitalized
# sh /data0/oracle/inventory/orainstRoot.sh
# sh /data0/oracle/product/11.2.0/root.sh
15. Switch back to Oracle user configuration monitoring:
# su - oracle
If DISPLAY environment variable not set appears , you need to configure the DISPLAY variable, and then re-netca after the configuration:
[oracle @ Hostname ~] $ export DISPLAY = localhost: 0.0
# netca -silent -responseFile /data0/oracle/database/response/netca.rsp
I haven't seen the following situation so far: (If it doesn't appear, no operation is required)
(
If it appears: (You need to switch to the root user to install the plugin before you can install it)
# its
# yum install libXp*
After successful operation, two files listener.ora and sqlnet.ora will be generated in /data0/oracle/product/11.2.0/network/admin/
)
16. View the listening port information: (If there is no port information, it will be cool)
# netstat -tnulp | grep 1521
(
Note: if the command is not found, you need to install netstate
# its
# yum install net-tools
)
17. Switch to the root user, create a new library, and create an instance:
# its
Password: the one with the first letter capitalized
# vi /data0/oracle/database/response/dbca.rsp
Modify the parameters (if there is a # in front, you need to delete the #):
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION ="/data0/oracle/oradata"
RECOVERYAREADESTINATION="/data0/oracle/fast_recovery_area"
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"
Edit x to write and exit;
18. Switch to oracle and configure
# su - oracle
# dbca -silent -responseFile /data0/oracle/database/response/dbca.rsp (This is very slow, wait a while)
19. After the installation is complete, open the instance ( each time you connect to the database you need to start operation from here ):
# su - oracle
Password: orcl or oracle
# ps -ef | grep ora_ | grip -v grip
View monitoring status:
# lsnrctl status
Just go here, and then you can create a user and log in
1. Connect to the database: sqlplus / as sysdba
2.SQL> 键入:create User zcy identified by zcy;
Prompt us: the user has created
3.SQL> ( grant permissions) type: grant connect, resource, dba to zcy;
Prompt us: successfully grant zcy user permissions
4. Remember to configure the port number of the oracle database on Alibaba Cloud , otherwise there is no way to access
5. Then use Navicat software locally to connect to the remote database
1. Open Navicat, 2. Edit the connection, 3. The host address is the public network IP, 4. The port number is the port number of the oracle database, 5. The service name is orcl, 6. The user name and password are just created by yourself
After the connection is successful, we can create tables and create sequences.
Start monitoring:
# lsnrctl start
Stop listening:
# lsnrctl stop
Log in to start the monitoring service:
Create user: # sqlplus / as sysdba
Username: sys as SYSDBA; Password: oracle
# startup
Note: If the startup is informed that it has started, you can enter shutdown immediate; wait for the shutdown to end, then enter startup
20. Set self-starting Oracle service:
# vi /etc/oratab
change the data:
orcl:/data0/oracle/product/11.2.0:Y
Edit x to write and exit;
# su - oracle
# cd $ORACLE_HOME/bin
# vi dbstart
change the data:
Modify ORACLE_HOME_LISTNER = $ 1 to:
ORACLE_HOME_LISTNER=$ORACLE_HOME
Edit x to write and exit;
# vi dbshut
change the data:
Modify ORACLE_HOME_LISTNER = $ 1 to:
ORACLE_HOME_LISTNER=$ORACLE_HOME
Edit x to write and exit;
# vi /etc/rc.d/rc.local
adding data:
su oracle -lc "/data0/oracle/product/11.2.0/bin/lsnrctl start"
su oracle -lc "/data0/oracle/product/11.2.0/bin/dbstart"
Edit x exit
As root user, execute the following instructions:
# chmod +x /etc/rc.d/rc.local
21. Modify the Oracle port:
# lsnrctl stop
# cd /data0/oracle/product/11.2.0/network/admin
# vi listener.ora
Modify PORT = 1521 to PORT = 11521
Edit x to write and exit;
# vi tnsnames.ora
Modify PORT = 1521 to PORT = 11521
Edit x exit
# su - oracle
# sqlplus / as sysdba;
# alter system set local_listener="(address=(protocol=tcp)(host=localhost)(port=11521))";
Note: The value of host here is the value of HOST in listener.or, and the value of port is the port you need to modify;
# exit;
# lsnrctl start
22. Delete the installation package: (I don't need to delete it, because I unzip both compressed packages in the local oracle folder to the current folder, and they are automatically decompressed into the database folder)
# its
# cd /data0/oracle
# rm -rf database