In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "mistakenly deleted / home directory under Linux", the content in the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "how to delete / home directory under Linux"!
In general, when we install the Oracle database, we create an Oracle user to install and manage Oracle. The root directory of the Oracle user is / home/oracle.
Usually the Oracle database is installed in accordance with the recommendations of the official documentation to create and manage the database, which is also convenient for database management.
This morning, a friend had this problem. In the customer's place, he mistakenly deleted the entire / home directory using the rm-rf. / home command. At that time, he was about to collapse, didn't know how to recover, and had no idea. Unexpectedly make such a low-level mistake: dare to use such a command as rm-rf; alas, it is all miserable DBA, who could not have made such a mistake? Therefore, as a DBA, you should think carefully when executing any command, especially in a production environment, when using the rm command, it is best not to use the-f parameter. Hey, it is better to experience it slowly. The more pits you encounter, the faster you may grow!
This article mainly aims at the solution of mistakenly deleting / home/oracle directory. The recovery of data files for Oracle is not involved here.
1. When installing the oracle database, we will create relevant users and groups.
[root@seiang11g ~] # groupadd oinstall
[root@seiang11g ~] # groupadd dba
[root@seiang11g ~] # groupadd oper
[root@seiang11g] # useradd-g oinstall-G dba oracle
This is created with the command of Linux. As with database creation, we usually create instances through OUI. So before we talk about handling this failure, we need to understand how Linux manually creates users and groups.
The following files are involved in the creation of each user:
/ etc/passwd (user)
/ etc/group (user group)
/ etc/shadow (key file)
/ home/username (home directory)
/ etc/skel/.* (skeleton file)
The / etc/skel directory / etc/skel directory is generally the directory where user startup files are stored. This directory is controlled by root permissions. When you add a user, the files in this directory are automatically copied to the newly added user's home directory; the files in the / etc/skel directory are hidden files, that is, similar to the .file format. We can provide users with a unified, standard and default user environment by modifying, adding, and deleting files in the / etc/skel directory.
/ etc/skel directory files, generally use the useradd command to add users (user), the system automatically copied to the newly added users (user) home directory; if we modify / etc/passwd to add users, we can create the user's home directory, and then copy the files under / etc/skel to the user's home directory, and then use chown to change the owner of the new user's home directory.
/ etc/default/useradd file
The rules file for adding users through useradd, which is as follows:
# useradd defaults file
GROUP=100
HOME=/home-build the user's home directory in / home
INACTIVE=-1-whether to enable account expiration suspension.-1 means it is not enabled.
EXPIRE=-account termination date. If not set, it will not be enabled.
SHELL=/bin/bash-the type of SHELL used
SKEL=/etc/skel-the default location of files in the directory where users are added by default; that is, when we add users with useradd, all the files in the user's home directory are copied from this directory
When creating a user, the user's information is added to the three files / etc/passwd,/etc/group,/etc/shadow, a user root directory is created under / home, and all the skeleton files are copied to the user's root directory.
[root@seiang11g ~] # cat / etc/passwd | grep oracle
Oracle:x:1001:1001::/home/oracle:/bin/bash
[root@seiang11g] # tail-3 / etc/group
Oinstall:x:1001:
Dba:x:1002:oracle
Oper:x:1003:oracle
[root@seiang11g ~] # cat / etc/shadow | grep oracle
Oracle:$6$ GjeAhxPv$XLNcGZyLVTsm/GTzQPCL57A1/uKIlGgcfFunveGhAe56qTiYW1RwWims77GpHvp3l2GysGqt63vJHBmlFkxRv/:17357:0:99999:7:::
When we delete the user's root directory / home/oracle, the user's configuration information is still stored in the system configuration file, so we only need to restore the skeleton file and modify the information of the environment variables.
Case study of mistakenly deleting / home/oracle directory:
Check the running status of the database: running normally
[oracle@seiang11g ~] $ps-ef | grep ora | grep-v grep
Root 1681 1552 0 16:08 pts/0 00:00:00 su-oracle
Oracle 1682 1681 0 16:08 pts/0 00:00:00-bash
Oracle 1722 1682 0 16:08 pts/0 00:00:00 rlwrap sqlplus / as sysdba
Oracle 1723 1722 0 16:08 pts/3 00:00:00 sqlplus as sysdba
Root 1725 1604 0 16:08 pts/1 00:00:00 su-oracle
Oracle 1726 1725 0 16:08 pts/1 00:00:00-bash
Oracle 1768 1 0 16:08? 00:00:00 / u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER-inherit
Oracle 1774 1 0 16:08? 00:00:00 ora_pmon_seiang11g
Oracle 1776 1 0 16:08? 00:00:00 ora_psp0_seiang11g
Oracle 1778 11 16:08? 00:00:05 ora_vktm_seiang11g
Oracle 1782 1 0 16:08? 00:00:00 ora_gen0_seiang11g
Oracle 1784 1 0 16:08? 00:00:00 ora_diag_seiang11g
Oracle 1786 1 0 16:08? 00:00:00 ora_dbrm_seiang11g
Oracle 1788 1 0 16:08? 00:00:00 ora_dia0_seiang11g
Oracle 1790 1 0 16:08? 00:00:00 ora_mman_seiang11g
Oracle 1792 1 0 16:08? 00:00:00 ora_dbw0_seiang11g
Oracle 1794 1 0 16:08? 00:00:00 ora_lgwr_seiang11g
Oracle 1796 1 0 16:08? 00:00:00 ora_ckpt_seiang11g
Oracle 1798 1 0 16:08? 00:00:00 ora_smon_seiang11g
Oracle 1800 1 0 16:08? 00:00:00 ora_reco_seiang11g
Oracle 1802 1 0 16:08? 00:00:00 ora_mmon_seiang11g
Oracle 1804 1 0 16:08? 00:00:00 ora_mmnl_seiang11g
Oracle 1806 1 0 16:08? 00:00:00 ora_d000_seiang11g
Oracle 1808 1 0 16:08? 00:00:00 ora_s000_seiang11g
Oracle 1814 1723 0 16:08-00:00:00 oracleseiang11g (DESCRIPTION= (LOCAL=YES) (ADDRESS= (PROTOCOL=beq)
Oracle 1816 1 0 16:08? 00:00:00 ora_arc0_seiang11g
Oracle 1818 1 0 16:08? 00:00:00 ora_arc1_seiang11g
Oracle 1820 1 0 16:08? 00:00:00 ora_arc2_seiang11g
Oracle 1822 1 0 16:08? 00:00:00 ora_arc3_seiang11g
Oracle 1824 1 0 16:08? 00:00:00 ora_qmnc_seiang11g
Oracle 1838 1 0 16:08? 00:00:00 ora_cjq0_seiang11g
Oracle 1850 1 0 16:08? 00:00:00 ora_q000_seiang11g
Oracle 1852 1 0 16:08? 00:00:00 ora_q001_seiang11g
Oracle 1945 1726 0 16:13 pts/1 00:00:00 ps-ef
Delete the / home/oracle directory directly, and I will directly mv the rm here.
[root@seiang11g ~] # cd / home
[root@seiang11g home] # ll
Total 4
Drwx- 15 oracle oinstall 4096 Aug 9 15:08 oracle
Drwx-. 3 seiang seiang 78 Jul 10 09:46 seiang
[root@seiang11g home] # mv oracle/ oracle.bak
[root@seiang11g home] #
[root@seiang11g home] # ll
Total 4
Drwx- 15 oracle oinstall 4096 Aug 9 15:08 oracle.bak
Drwx-. 3 seiang seiang 78 Jul 10 09:46 seiang
[root@seiang11g home] #
[root@seiang11g home] # su-oracle
Last login: Wed Aug 9 16:08:15 CST 2017 on pts/1
Su: warning: cannot change directory to / home/oracle: No such file or directory
-bash-4.2 $
-bash-4.2$ sqlplus / as sysdba
Bash: sqlplus: command not found...
-bash-4.2 $
-bash-4.2$ pwd
/ home
-bash-4.2 $
-bash-4.2$ whoami
Oracle
Start recovery:
Create a directory:
[root@seiang11g home] # pwd
/ home
[root@seiang11g home] # mkdir oracle
[root@seiang11g home] # chown oracle:oinstall oracle
[root@seiang11g home] # ll
Total 16
Drwxr-xr-x 5 oracle oinstall 8192 Aug 9 16:33 oracle
Drwx- 15 oracle oinstall 4096 Aug 9 15:08 oracle.bak
Drwx-. 3 seiang seiang 78 Jul 10 09:46 seiang
Copy the skeleton file:
[root@seiang11g oracle] # cp-R / etc/skel/.* / home/oracle/
[root@seiang11g oracle] # chown-R oracle:oinstall/home/oracle
[root@seiang11g oracle] # ls-al
Total 28
Drwxr-xr-x 3 oracle oinstall 8192 Aug 9 16:30.
Drwxr-xr-x. 5 root root 52 Aug 9 16:22..
-rw-r--r-- 1 oracle oinstall 18 Aug 9 16:29. Bash _ logout
-rw-r--r-- 1 oracle oinstall 193 Aug 9 16:29. Bash _ profile
-rw-r--r-- 1 oracle oinstall 231 Aug 9 16:29 .bashrc
Drwxr-xr-x 4 oracle oinstall 39 Aug 9 16:29 .mozilla
-rw- 1 oracle oinstall 0 Aug 9 16:29 .pwd.lock
-rw-r--r-- 1 oracle oinstall 163 Aug 9 16:29.
Modify the environment variables for the oracle user:
[root@seiang11g oracle] # vim .bash _ profile
# .bash _ profile
# Get the aliases and functions
If [- f ~ / .bashrc]; then
. ~ / .bashrc
Fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
Export PATH
Unset TNS_ADMIN
Export ORACLE_BASE=/u01/app/oracle
Export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
Export ORACLE_SID=seiang11g
Export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
Export PATH=$ORACLE_HOME/bin:$PATH
Alias sqlplus='rlwrap sqlplus'
Alias rman='rlwrap rman'
[root@seiang11g ~] # su-oracle
Last login: Wed Aug 9 16:16:48 CST 2017 on pts/2
[oracle@seiang11g ~] $
[oracle@seiang11g ~] $sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 9 16:32:54 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@seiang11g >
Back to normal. But if the Oracle data file exists in the / home/oracle directory, the recovery is much more complex than here.
Thank you for your reading, these are the contents of "mistakenly delete / home directory under Linux". After the study of this article, I believe you have a deeper understanding of how to delete / home directory under Linux by mistake, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.