In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Oracle database is a relatively large application software, which has corresponding requirements for server system type, memory and swap partition, hard disk space, kernel parameters, software environment, user environment and so on. Only when the necessary conditions are met can we ensure the successful installation and stable operation of oracle 12c.
System requirements for deploying oracle 12c:
The firewall needs to release related traffic. The default port number of oracle is 5500. SELinux must be disabled; kernel version 3.10 or above; physical memory; must be higher than 1G, swap space. When physical memory is 1GB, swap partition is 1.5 ~ 2 times of physical memory. When physical memory is 2 ~ 16g, swap partition is the same as physical memory size. When physical memory exceeds 16g, swap partition uses 16GB. At least need the disk space of 20GB, if you do not create a partition for oracle alone, then at least make sure that the root partition has the available disk space of 15GB. 1. Prepare before installing oracle 12c
These are the basic hardware requirements, and then you need to modify the software parameters in order to deploy oracle.
Download oracle installer first, I provide an oracle 12c installation file Baidu network disk link, is the version of oracle 12c, you can also go to the oracle Chinese official website, it supports the free download of oracle installation files (need to register an account, the latest version is oracle 19c), find the desired version to download and use, I will install 12c here.
Before installing the oracle database, plan the hostname and IP. The hostname and IP address of the server should also be determined in advance. Once the installation of the oracle database is completed, it is recommended not to modify the hostname, otherwise it will cause the database to fail to start. You generally need to do the following:
[root@localhost ~] # hostnamectl set-hostname oracle # modify the hostname and write to the configuration file [root@localhost ~] # bash # to make the hostname effective [root@oracle ~] # echo "192.168.1.1 oracle" > > / etc/hosts # write the local hostname and IP corresponding to the / etc/hosts file for parsing # can also be parsed through DNS To save trouble [root@oracle] # tail-1 / etc/hosts # confirm that 192.168.1.1 oracle has been added here
The installation process of oracle 12c is carried out in a graphical interface, so it is recommended to use a centos server with GNOME Chinese desktop environment. Of course, software development tools are also essential. You can use yum to install the necessary software environment on the system disk, as follows:
[root@oracle ~] # mount / dev/cdrom / media # Mount the system disk # the following is to configure the local yum source [root@oracle yum.repos.d] # cd / etc/yum.repos.d/ [root@oracle yum.repos.d] # mkdir / yum.repo.bak [root@oracle yum.repos.d] # mv * / yum.repo.bak/ [root@oracle yum.repos.d] # vim system.repo # write to the following Capacity [oracle] baseurl= file:///mediagpgcheck=0[root@oracle yum.repos.d] # yum clean all # clear yum cache [root@oracle yum.repos.d] # cd# the following is to install some development tools [root@oracle ~] # yum-y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel [root@oracle ~] # Vim / etc/sysctl.conf # adjusts kernel parameters Mainly memory scheduling, port range, number of open files, Write the following parameter 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_default = 262144net.core at the end of the file .rmem _ max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576 [root@oracle ~] # sysctl-p # reload configuration file Make sure the output information is correct. Fs.aio-max-nr = 1048576 fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 4294967295kernel.shmmni = 4096kernel.sem = 25032000100 128net.ipv4.ip_local_port_range = 900065500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576 [root@oracle] # groupadd-g 54321 oinstall # create installation group [root@oracle ~] # groupadd-g 54322 dba # create an administrative group [root@oracle ~] # useradd-u 54321-g oinstall-G dba oracle # create a running user [root@oracle ~] # echo "123.comf" | passwd-- stdin oracle # set a password for this user [root@oracle ~] # mkdir-p / u01/app/oracle # create a basic directory [root@oracle ~] # chown-R oracle:oinstall / U01 / app/ # change belonging group [root@oracle ~] # chmod-R 755 / u01/app/oracle/ # change permissions [root@oracle ~] # vim / home/oracle/.bash_profile # adjust the oracle user's environment variable. # omit some content # write the following content umask 022ORACLE_BASE=/u01/ App/oracle # defines the base directory ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/ # defines the installer directory ORACLE_SID=orcl # defines the database instance name NLS_LANG= "SIMPLIFIED CHINESE_CHINA" .UTF8 # determines which locale PATH=$PATH:$ORACLE_HOME/binLANG=zh_CN.UTF-8export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SIDexport DISPLAY=:0.0 to use
Oracle user resource restriction 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. As follows:
[root@oracle ~] # vim / etc/pam.d/login # modify the PAM setting to enable the authentication. # omit part of the content # write the following two lines at the end: session required / lib/security/pam_limits.sosession required pam_ accouns.so[ root @ oracle ~] # vim / etc/security/limits.conf # modify the file.. # omit part # write the following at the end of the file: oracle soft nproc 2047 # soft limit on the number of processes oracle hard nproc 16384 # hard limit oracle soft nofile 1024 # soft limit on the number of files oracle hard nofile 65536 # File count hard limit oracle soft stack 10240 # Oracle soft stack limit [root@oracle ~] # vim / etc/profile # add the following to the end of the file.. # omit part # write the following at the end of the file: if [$USER = "oracle"] Then if [$SHELL = "/ bin/ksh"]; then ulimit-p 16384 ulimit-n 65536 else ulimit-u 16384-n 65536 fifi
Not configuring the limit of oracle user resources will not affect the successful installation of oracle database. However, if a bad SQL statement infinitely consumes the resources of the server, resulting in no response to user requests for a long time, it is recommended to limit oracle user resources in advance.
At this point, the preparation work is complete, and the system needs to be rebooted. After restarting, it is best to check again whether the previous configuration is in effect. Temporary configuration is not recommended.
Second, install oracle 12c process [root@oracle ~] # mkdir / tmp/abc # create directory, / tmp directory Only oracle users can read [root@oracle ~] # mount / dev/cdrom / media # mount the oracle CD image file provided by me [root@oracle ~] # ls / media/ # confirm that the oracle file exists linuxx64_12201_database.zip [root@oracle ~] # cd / tmp/abc # and switch to [root@oracle abc] # cp / media/linuxx64_12201_database.zip under / tmp/abc/ directory. # copy the installation file to the current directory. The file is a bit large. Please wait patiently for [root@oracle abc] # unzip linuxx64_12201_database.zip # to extract the installation file.
The installation of oracle 12c is mainly carried out through runInstaller scripts. Visit the web page welcome.html to view the product manual, including product instructions, release notes, installation guides and other documents, providing us with a wealth of help information.
Once all the prerequisites are in place, you can officially begin the installation, and if the current graphical desktop environment is logged in as another user, such as root, you should also add an authorization to allow oracle to use the graphics terminal. For example: "xhost + oracle@localhost" means that the user oracle is allowed to access from the local machine, and the execution of "xhost +" means that all restrictions are lifted.
Log in to the centos graphical desktop environment as user oracle and start the runInstaller script file in the database directory. The specific actions are as follows (if you install oracle 19c, you need to change the owner of the directory where oracle 19c is stored to oracle. If the extracted oracle installation files are located in the / tmp/abc directory, you need to execute the command: chown-R oracle / tmp/abc to change its owner, otherwise an error will be reported. The oracle 12c installed here will not have this problem. ):
[root@oracle ~] # xhost + # must use the root user to operate [root@oracle] # su-oracle # in the graphical environment to switch to the oracle user [oracle@oracle ~] $cd / tmp/abc/database/ # to the oracle installation file directory [oracle@oracle database] $. / runInstaller # just extracted to execute the script to install. After executing the script, the oracle graphical installer will be started.
The next operation is basically done on the graphical window, as follows:
The window that opens after executing the runInstaller script is as follows:
1 、
2 、
3 、
4 、
5 、
6 、
7 、
8 、
9 、
10 、
11 、
12 、
13 、
14. During the installation process, you will be prompted to use the root identity to execute the following two scripts. At this point, switch a workspace, log in using root, copy the script name and execute the following. As follows:
15. Use the root identity to execute the script prompted in the figure above:
[root@oracle ~] # / u01/app/oraInventory/orainstRoot.sh [root@oracle ~] # / u01/app/oracle/product/12.2.0/dbhome_1/root.sh # when executing the second script, there will be two interactive interfaces, the first time you can directly press the enter key; # the second time is to install the oracle tracking file analyzer, which can either enter directly or enter "yes" to install
16 、
17. If the installation is successful, just close it.
After the installation is completed, you can access the EM (Enterprise Manager, Enterprise Manager) database Express platform through the https://oracle server IP:5500/em, so as to simply manage the database of oracle 12c, but access to the EM database express platform requires the support of flase. The Windows client I use here is directly accessed (with flase installed). If you use Linux's own Firefox browser, you can download the flase player plug-in in Linux provided by me, which is in rpm format. Just execute the command rpm-ivh to install it.
The login page is as follows:
The password mentioned in the figure above is the password defined in the following procedure:
The interface after login is as follows:
With regard to this management interface, there is no need to introduce it any more, just study it yourself.
Third, the command line interface operation of oracle
You can use the sqlplus command to access the oracle database in the command line interface, but after logging in to the database, you cannot use the arrow keys to flip the history command. If you want to solve the problem, you can do the following.
1. Download the tar.gz package provided by me
2. Mount the system disk, and then execute the following command:
[root@oracle ~] # yum-y install ncurses* readline* # install dependency package [root@oracle abc] # tar-zxvf rlwrap-0.30.tar.gz # extract the tar package [root@oracle abc] # cd rlwrap-0.30/ # provided by me and enter the decompressed directory [root@oracle rlwrap-0.30] #. / configure & & make & & make install # compile and install [root@oracle ~] # Vim / home/oracle/.bash_profile # configure environment variables for oracle users In order to facilitate the use of rlwrap commands # after the above configuration, execute the rlwrap + original command to log in to the oracle database, you can use the up and down keys to flip the history command [root@oracle ~] # su-oracle # switch to the oracle user before you can log in to the oracle database last time: September 25 16:46:42 CST 2019 [oracle@oracle ~] $rlwrap sqlplus / as sysdba # login to the database
In the above login database command, it is realized that sys connects to the local oracle database as sysdba. Sys users are the highest administrators of oracle. As sysdba is generally added when logging in as sys users, while other users do not need it. If you log in to oracle database as other users, you can execute the command: "[oracle@oracle ~] $sqlplus system/oracle"
"
Simple operation after entering the SQL environment (case-insensitive in SQL > mode):
SQL > help index # View list of supported instructions SQL > show user # View current user IV. Creation of 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 database] $dbca # run the command dbca as oracle, and a window pops up
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 following window pops up after the command is executed:
V. Startup and shutdown of oracle 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 log in as 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 ~] $rlwrap sqlplus / as sysdba # enter the oracle database SQL > startup nomount # execute the command ORACLE routine has been started. Total System Global Area 1593835520 bytesFixed Size 8793256 bytesVariable Size 1023411032 bytesDatabase Buffers 553648128 bytesRedo Buffers 7983104 bytes
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; # execute the command
Normally, you can use the following command to start the database normally, as follows:
SQL > startup # executes this command when the database is closed, and the database starts, loads, and opens 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. Database shutdown
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.
3. 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 / u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora write / u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml log letter Message listening: (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=oracle) (PORT=1521) listening: (DESCRIPTION= (ADDRESS= (PROTOCOL=ipc) (KEY=EXTPROC1521) is connecting to the STATUS---- alias LISTENER version of (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=oracle) (PORT=1521) LISTENER 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) turn off 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
-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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.