Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deploy Oracle 12c Enterprise Edition database

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In the field of computer information security, database system undoubtedly plays an important role. For example, SQL Server, MySQL, DB2, Oracle and so on are all well-known database management software. because of the security of Oracle database, it is widely used in some important occasions, such as telecommunications, banks, government departments and so on.

This blog takes the 64-bit Enterprise Edition of Oracle 12c database as an example to learn how to install and basic configuration in Centos operating system, including installation preparation and so on.

Blog outline:

First, install Oracle 12c

Second, create Oracle 12c database

III. Startup and shutdown of Oracle 12c database

4. Set the Oracle database to boot

First, install Oracle 12c1. Considerations for installing CentOS 7 operating system

Since this installation of Oracle 12c software is implemented on a CentOS 7 system, there are several requirements for installing CentOS 7 operating system for the first time:

Firewall configuration option is set to disable; SELinux is set to disable; default installation setting is software development; kernel selection is 3.10.0-862.el7.x86_64 and above; 2. Preparation of preconditions

Oracle database is a relatively large application software, which has corresponding requirements for server system type, memory and swap partition, hard disk empty Arkin, kernel parameters, software environment, user environment and so on. Only if these necessary conditions are met can you ensure the successful installation and stable operation of Oracle 12c.

(1) system and configuration requirements

The Linux operating systems explicitly supported by Oracle 12c include Oracle Linux 7, Oracle Linux 6, Oracle Linux 5, Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 5, and so on. Because Red Hat Enterprise and CentOS are synchronous parallel operating systems, Oracle 12c also supports CentOS 7, CentOS 6, CentOS 5 operating systems. Individual software or configuration files may need to be adjusted appropriately when installed on other Linux systems.

[root@localhost ~] # cat / etc/centos-release / / View system version information CentOS Linux release 7.5.1804 (Core) [root@localhost ~] # uname-r / / View system kernel information 3.10.0-862.el7.x86_64

The Linux operating system requires:

Physical memory: must be higher than 1GB, and not less than 2GB is recommended for VMware virtual machines; swap space: when physical memory is 1~2GB, swap partition is 1.5 times larger than physical memory; when physical memory is 2~16GB, swap partition is the same size as physical memory; when physical memory exceeds 16GB, swap partition uses 16GB.

If there is not enough space in the swap partition, you can extend the swap partition in the following ways

[root@localhost ~] # dd if=/dev/zero of=/swap_file bs=1024 count=2097152 / / this is the swap partition that extends 2GB, 2097152 divided by 1024 equals 2048, so it is after the completion of 2GB [root@localhost ~] # mkswap / swap_ file [root @ localhost ~] # swapon / swap_file// If you query again, you will find that the swap partition has more 2GB space [root@localhost ~] # grep MemTotal / proc/meminfoMemTotal: 7992344 kB [root@localhost ~] # grep SwapTotal / proc/meminfoSwapTotal: 18568716 kB / / the swap partition space and memory space have met the requirements

For the Oracle 12c database, if the program files and data files are installed in the same partition, the most important requirement for the hard disk space of the partition is 6.4G for the enterprise and 6.1G for the standard edition. In addition, make sure that the free space of the / tmp directory is not less than 1G. In general, it is recommended that you install Oracle 12c to prepare at least 15G of hard disk space.

[root@localhost ~] # df-hT / tmp / / View / tmp directory disk usage file system type capacity available available mount point / dev/mapper/centos-root xfs 50G 21G 30G 42% / / obviously meets the requirements

Before installing the Oracle database, plan the hostname and IP. The hostname and IP address of the server should be confirmed in advance. Once the Oracle database is installed, it is recommended not to modify the hostname easily, otherwise it will cause the database to fail to start. The methods are as follows:

[root@localhost ~] # sed-I'1c oracle' / etc/hostname// set hostname to oracle [root@localhost ~] # echo-e "192.168.1.1 oracle" > > / etc/hosts// add the corresponding relationship between hostname and IP address (2) Software environment requirements

The installation process of Oracle 12c is usually carried out in a graphical interface, so it is recommended to use a CentOS server with GNOME Chinese desktop environment installed. Of course, software development tools are essential, and the following necessary software environments should be installed in yum mode.

[root@localhost] # yum-y install binutils compat-* gcc gcc-c++ glibc glibc-devel ksh\ libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat\ unixODBC unixODBC-devel// can use either a local CD or a network yum

Oracle 12c itself integrates the Java runtime environment, but the Chinese language support for the installation interface is not perfect, so if you want to use the Chinese Oracle installation interface, it is recommended to install the Java package in advance.

(3) Kernel requirements

In order to ensure the stability of the database, Oracle 12c puts forward some requirements for Linux kernel parameters and process session restrictions, some of which can be automatically detected and repaired during installation, but they must be complete, so it is best to configure them in advance according to the installation documentation.

Kernel parameter adjustment is reflected in the / etc/sysctl.conf file, which mainly includes some settings related to memory scheduling, port range, number of open files, Icano request and so on. The relevant values should not be lower than the installation requirements. As follows:

[root@localhost] # vim / etc/sysctl.conf... / / omit part of the content and add it at the end! Fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 4294967295kernel.shmmni = 4096kernel.sem = 25032000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_max = 4194304net.core.rmem_default = 262144net.core.wmem_default = 262144net.core.wmem_max = 1048576 [root@localhost ~] # sysctl-p / / reload the configuration file

Detailed description of each parameter:

Fs.aio-max-nr: this parameter restricts the concurrency of outstanding requests and should be set to avoid Icano subsystem failures; fs.file-max: this parameter determines the maximum number of files allowed to be opened in the system; kernel.shmall: this parameter controls the total number of pages of shared memory that can be used; .kernel.shmmax: is one of the most important parameters in the core parameter and is used to define the maximum value of a single shared memory segment.

Recommendations:

32-bit linux system: the maximum preferred value is 4GB (4294967296bytes)-1byte, which is 4294967295. The recommended value is more than half of the memory, so if 32 is the system, the value is generally 4294967295.

64-bit linux system: the maximum preferred value is the physical memory value-1byte, and the recommended value is more than half of the physical memory. For example, in the case of 12GB physical memory, 12102410241024-1 12884901887 is recommended. Kernel.shmmni: this parameter is the maximum number of shared memory segments. The default value of shmmni is 4096, which is generally sufficient. Kernel.sem:

Take kernel.sem = 250 32000 100128 as an example:

250 is the value of the parameter semmsl, indicating the maximum number of semaphores that can be contained in a semaphore set.

32000 is the value of the parameter semmns, indicating the maximum number of semaphores allowed in the system.

100 is the value of the parameter semopm, which represents the number of operations that a single semopm () call can perform on a semaphore set.

The value of the parameter semmni represents the total set of system semaphores. Net.ipv4.ip_local_port_range: indicates the range of IPv4 ports that the application can use; net.core.rmem_default: represents the default value of the socket receive buffer size; net.core.rmem_max: represents the maximum socket receive buffer size; net.core.wmem_default: represents the default value of the socket send buffer size; net.core.wmem_max: represents the maximum socket send buffer size (4) Oracle user environment requirements

Oracle 12c requires a fixed running user oracle, installation group oinstall, and management group dba. These accounts should be created in advance. The basic directory for storing Oracle programs and database files should also be created in advance.

[root@localhost ~] # groupadd oinstall [root@localhost ~] # groupadd dba [root@localhost ~] # useradd-g oinstall-G dba oracle [root@localhost ~] # echo '123456' | passwd-- stdin oracle changes the password of user oracle. Passwd: all authentication tokens have been successfully updated. [root@localhost] # mkdir-p / u01/app/oracle [root@localhost ~] # chown-R oracle:oinstall / u01/app [root@localhost ~] # chmod-R 775 / u01/app/oracle

The installation task of Oracle 12c should be performed as the running user oracle, and the environment configuration of the oracle user needs to be adjusted to meet the requirements.

[root@localhost] # vim / home/oracle/.bash_profile... / / omit part of the content and add it at the end! Umask 022ORACLE_BASE=/u01/app/oracle # oracle basic directory ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/ # installer directory ORACLE_SID=orcl # defines the database instance name NLS_LANG= "SIMPLIFIED CHINESE_CHINA" .UTF8 # is for Oracle language, region, character set settings PATH=$PATH:$ORACLE_HOME/binLANG=zh_CN.UTF-8 # LANG is for Linux system language, region, character set settings. DISPLAY=:0.0 # on which terminal can you use graphic export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID DISPLAY # to export variables as global variables (5) oracle user resource limit requirements

The process session restriction can be realized by pam_limits authentication module. By modifying the PAM setting of the login program login to enable the authentication, and then modifying the / etc/security/limits.conf file, the number of processes that the user oracle can open and the number of files used by the process can be increased.

[root@localhost] # vim / etc/pam.d/login... / / omit part of the content and add it at the end! Session required / lib/security/pam_limits.sosession required pam_ rooms.so [root @ localhost ~] # vim / etc/security/limits.conf... / / omit part of the content and add it at the end! Oracle soft nproc 2047 # set soft limit on processes oracle hard nproc 16384 # set hard limit on number of processes oracle soft nofile 1024 # set soft limit on number of files oracle hard nofile 65536 # set hard limit on number of files oracle soft stack 10240 # Oracle soft stack limit

Configuring the oracle user resource limit will not affect the successful installation of the oracle database. However, considering that the server resources are infinitely occupied by bad sql statements, resulting in no response to user requests for a long time, it is recommended to limit oracle user resources in advance.

[root@localhost ~] # vim / etc/profileif [$USER = "oracle"]; then if [$SHELL = "/ bin/ksh"]; then ulimit-p 16384 ulimit-n 65536 else ulimit-u 16384-n 65536 fifi

Restart the system after the preparatory work is completed, and after the restart, check again whether the previous configuration is in effect.

3.Oracle 12c installation process

The official Chinese website of Oracle is https://www.oracle.com/index.html, which can be downloaded by itself or installed through the Oracle installation package provided by me.

[root@oracle ~] # cd / [root@oracle /] # unzip / root/linuxx64_12201_database.zip / / enter the root directory to decompress the downloaded Oracle package [root@oracle /] # ls database/ and generate the database directory install response rpm runInstaller sshsetup stage welcome.html

Authorization allows the user oracle to use a graphics terminal, such as: xhost + oracle@localhost, to allow user oracle access from the local machine, or to execute xhost + to remove all restrictions, where xhost + can be executed.

[root@oracle /] # xhost + / / be sure to operate [root@oracle /] # su-oracle / / switch to the oracle user [oracle@oracle ~] $cd / database/ [oracle@oracle database] $export DISPLAY=:0.0 to set the DISPLAY environment variable [oracle@oracle database] $. / RunInstaller / / execute the installation script

When the execution is complete, a graphical interface pops up to do the following:

During execution, there will be a prompt like this:

[root@oracle ~] # / u01/app/oraInventory/orainstRoot.sh [root@oracle ~] # / u01/app/oracle/product/12.2.0/dbhome_1/root.sh// executes the second script. When prompted, enter all the way!

Visit the Web page as follows:

Next, use the command line for login access:

First of all, you need to solve the problem that the sqlplus command line direction keys cannot be used, as follows:

Get the rlwrap package

[root@oracle ~] # yum-y install ncurses* readline* / / to install the package depends on [root@oracle ~] # tar zxf rlwrap-0.30.tar.gz.zip-C / usr/src [root@oracle ~] # cd / usr/src/rlwrap-0.30/ [root@oracle rlwrap-0.30] #. / configure & & make & & make install// compiles and installs using root identity, and can be used after installation! [oracle@oracle] $rlwrap sqlplus "/ as sysdba" SQL*Plus: Release 12.2.0.1.0 Production on Tuesday November 26 10:51:44 2019Copyright (c) 1982, 2016, Oracle. All rights reserved. Connect to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit ProductionSQL >

In this way, you can use the arrow keys when you log in to the database. However, it is a bit troublesome to use the rlwrap command every time you log in to the database. You can do the following:

[oracle@oracle] $vim / home/oracle/.bash_profile... / / adding the following at the end of the alias sqlplus='rlwrap sqlplus'alias rman='rlwrap rman'// is to create an alias for the command

Log out of the current oracle user before logging in again.

[oracle@oracle ~] $sqlplus sys/123456 as sysdba// uses the command line to log in to SQL*Plus: Release 12.2.0.1.0 Production on Tuesday November 26 10:57:41 2019Copyright (c) 1982, 2016, Oracle. All rights reserved. Connect to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit ProductionSQL >

Or

[oracle@oracle] $sqlplus / nologSQL*Plus: Release 12.2.0.1.0 Production on Tuesday November 26 10:59:10 2019Copyright (c) 1982, 2016, Oracle. All rights reserved.SQL > conn sys/123456 as sysdba is connected. / / you can also use this way to log in to the Oracle database and create an Oracle 12c database

If you do not create a database when you install an oracle product, you must first create a database to use the oracle system. If you choose to build a database when you install oracle, you can also create a second database (although it is recommended that only one database be created on a server in order for the oracle database to make full use of system resources).

There are two ways to create a database: through a graphical interface, or by using the "CREATE DATABASE" command. Here's how to create a database with a graphical interface:

[oracle@oracle ~] $dbca / / create a database using oracle users / / execute this command will pop up a graphical interface to create a database

If there is no pop-up window, you can refer to the previous steps to run the "xhost +" command as the root user, and then run the "export DISPLAY=:0.0" command as oracle.

The graphical interface that pops up is as follows:

The database has been created!

III. Startup and shutdown of Oracle 12c database

The startup and shutdown of oracle database is one of the daily tasks. For most oracle DBA, the most common way to start and shut down the oracle database is to execute it on the command line.

1. Start and shut down the Oracle database

To start and shut down the database, you must be logged in by a user with Oracle administrator privileges, usually as a user with SYSDBA privileges.

(1) Startup of database

Starting a database requires three steps: ① starts the oracle instance (non-mount phase), ② loads the database by the instance (mount phase), and ③ opens the database (open phase).

In the startup command, you can use different options to control the different startup steps of the database.

1) startup nomount (this command is not commonly used)

The nomount option starts only one oracle instance, reads the init.ora initialization parameter file, starts the background process, and initializes the SGA. When the instance is started, the system will display a list of SGA memory structure and size, as follows:

[oracle@oracle] $sqlplus / as sysdba / / Log in to the database as oracle user SQL*Plus: Release 12.2.0.1.0 Production on Tuesday November 26 11:18:36 2019Copyright (c) 1982, 2016, Oracle. All rights reserved. Connect to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit ProductionSQL > startup nomount

2) startup mount (this command is sometimes used)

The startup mount command starts the instance and loads the database, but does not open the database. The oracle system reads the contents of the data file and redo log file in the control file, but does not open the file. This opening method is often used in database maintenance operations, such as renaming data files, changing redo logs, opening archive mode, and so on. In this open mode, in addition to seeing the list of SGA systems, the system will also give a prompt that "the database is loaded".

SQL > alter database mount; / / since the startup nomount command has been executed above, you will need to use this command to change its state

3) startup (command used normally)

The startup command completes the three steps of starting the instance, loading the database and opening the database. At this point, the database makes the data files and redo log files online, and usually requests one or more rollback segments; the system will not only see all the prompts in the previous startup mount mode, but also give a prompt that "the database is open"; the database system is in a normal working state and can receive requests from users.

If you use startup nomount or startup mount to open the database, you must use the alter database command to load or open the database.

The first two commands have been executed (startup nomount and alter database mount), so if you execute the following command here, the database can be said to have started correctly. As follows:

SQL > alter database open

Normally, you can use the following command to start the database normally, as follows:

SQL > startup / / execute this command when the database is closed, and the database will be started, loaded, and opened in turn. The ORACLE routine has been started. Total System Global Area 1593835520 bytesFixed Size 8793256 bytesVariable Size 1023411032 bytesDatabase Buffers 553648128 bytesRedo Buffers 7983104 bytes database loaded. The database is already open. (2) shutdown of the database

For database shutdown, there are four different shutdown options.

1) shutdown normal

Shutdown normal is the default option for the shutdown command. That is, if the user issues the shutdown command, the shutdown normal command is executed.

After issuing this command, any new connections will no longer be allowed to connect to the database. Before shutting down the database, oracle will wait for all currently connected users to exit from the database before starting to shut down the database. Shutting down the database in this way does not require any instance recovery at the next startup. It is important to note, however, that in this way, it may take several days or more to shut down a database.

2) shutdown immediate

Shutdown immediate is a common way to shut down a database. If you want to close the database quickly, but also want the database to be "clean" closed, this method is often used.

After issuing this command, the SQL statement currently being processed by oracle is interrupted immediately, and any uncommitted transactions in the system are rolled back. If there is a long uncommitted transaction in the system, it will also take some time to shut down the database in this way (the transaction rollback time). Instead of waiting for all users connected to the database to exit the system, the system forcibly rolls back all currently active transactions and then disconnects all connected users.

3) shutdown transactional

The shutdown transactional command, which is often used to plan a database shutdown, waits for active transactions that are currently connected to the system to complete, and after running the command, any new connections and transactions are not allowed. After all its active transactions are completed, the database shuts down the database in the same way as shutdown immediate.

4) shutdown abort

Shutdown abort is the last choice to shut down the database. It has to be adopted when there is no way to close the database. Generally, it should not be used. Consider shutting down the database in this way when the following situations occur.

The database is in an abnormal working state and cannot be shut down with shutdown normal or shutdown immediate commands; the database needs to be closed immediately

A problem was encountered while starting the database instance.

After issuing this command, all running SQL statements will be aborted immediately, all uncommitted transactions will not be rolled back, and oracle will not wait for the user currently connected to the database to log out of the system; the next time the database is started, the instance needs to be restored, so the next startup may take longer than usual.

It is best to use the shutdown immediate method when shutting down the database because it is safe and relatively fast. Do not use the shutdown abort method as a last resort, as it can result in data loss and take a long time to recover the database.

two。 Start and close the oracle listening process

When the oracle database instance is started, in order for client users to connect to the oracle instance, DBA also needs to start the listening process using the lsnrctl command on the server where oracle resides. If the database instance is shut down, the listening process is generally turned off as well.

(1) start monitoring

Startup listening is a command executed by oracle users under the operating system. You can add parameters directly to lsnrctl or operate from the command prompt, as shown below:

[oracle@oracle] $lsnrctl / / execute the command LSNRCTL for Linux: Version 12.2.0.1.0-Production on 25-September-2019 21:59:04Copyright (c) 1991, 2016, Oracle. All rights reserved. Welcome to LSNRCTL. Type "help" for information. LSNRCTL > start / / start listening start / u01/app/oracle/product/12.2.0/dbhome_1//bin/tnslsnr: please wait... TNSLSNR for Linux: Version 12.2.0.1.0-Production system parameter file is the log of / u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora write / u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml Information monitoring: (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=oracle) (PORT=1521) listening: (DESCRIPTION= (ADDRESS= (PROTOCOL=ipc) (KEY=EXTPROC1521) is connecting to (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=oracle) (PORT=1521)) LISTENER STATUS---- alias LISTENER version TNSLSNR for Linux: Version 12.2 .0.1.0-Production start date 25-September-2019 21:59:12 uptime 0 days 0 hours 0 minutes 0 seconds tracking level off security ON: Local OS AuthenticationSNMP OFF listener parameter file / u01/app/oracle/product/ 12.2.0/dbhome_1/network/admin/listener.ora listener log file / u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml listener endpoint summary. (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=oracle) (PORT=1521) (DESCRIPTION= (ADDRESS= (PROTOCOL=ipc) (KEY=EXTPROC1521) listeners do not support successful execution of service commands

You can also directly use the following command "to start monitoring:

[oracle@oracle] $lsnrctl start / / start listening (2) close listening [oracle@oracle] $lsnrctl stop / / close listening LSNRCTL for Linux: Version 12.2.0.1.0-Production on 25-September-2019 22:00:31Copyright (c) 1991, 2016, Oracle. All rights reserved. Connecting to (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=oracle) (PORT=1521) command executed successfully

Pay attention to start the monitoring before starting the database!

4. Set the Oracle database to boot [root@oracle] # vim / etc/oratab. / / modify the following content orcl:/u01/app/oracle/product/12.2.0/dbhome_1: y [root @ oracle ~] # vim / etc/rc.local su-oracle-c 'dbstart' / / start database su-oracle-c' lsnrctl start' / / enable listening process [root@oracle ~] # chmod + x / etc/rc.d/rc.local// add execution permission

After reboot, verify:

[root@oracle ~] # netstat-anpt | the listening port of grep 5500 / / oracle database tcp6 00:: 5500: * LISTEN 2144/tnslsnr [root@oracle ~] # netstat-anpt | grep 1521 / / oracle database listening process tcp 00 192.168.1.1: 24251 192.168.1.1 ESTABLISHED 1816/ora_lreg_orcl tcp6 1521 ESTABLISHED 2144/tnslsnr tcp6 0:: 1521: * LISTEN 2144/tnslsnr tcp6 0 0 192.168.1.1 ESTABLISHED 2144/tnslsnr tcp6 0 192.168.1.1 1RV 1521 192.168.1.1 JV 24143 TIME_WAIT-

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report