0
点赞
收藏
分享

微信扫一扫

oracle数据库的操作系统密码忘记操作方法

oracle数据库一般很少操作服务器重启,而且一般都是oracle用户操作,久了很容易忘记依赖的操作系统root密码,我司在运维过程中要求服务器必须定期重启,就发现部分oracle数据库操作系统密码忘记情况,现对这种情况总结清密方法如下:

一、先停oracle数据库

 su - oracle

lsnrctl stop && sqlplus / as sysdba

shutdown immediate 或者shutdown abort (如应用未关闭的情况下,不建议直接shutdown,否则非常慢)

如不小心用了shutdown,停止很久无法停止,可按如下脚本执行链接删除:

netstat -naolp|grep `hostname -I | awk '{print $1}'`:1521|grep EST |awk {'print $7'} |cut -d '/' -f1 |sort |uniq |xargs kill -9 杀掉oracle上的所有连接进程

netstat -na|grep 10.60.89.1:1521 |awk {'print $5'} |cut -d':' -f4 |sort |uniq  查找oracle数据连接的机器

netstat -naolp|grep 10.60.89.1:1521 |awk {'print $7'} |cut -d '/' -f1 |sort |uniq 查找连接oracle的应用

二、强制断电重启,清root密码

重启系统,在 GRUB 启动菜单界面,选择要启动的内核(通常第一个选项);按下 e 键进入编辑模式;找到以 linux16 开头的行,将光标移动到此行的末尾。

添加 rd.break 参数(注意前面加一个空格),然后按 Ctrl + X 或 F10 启动系统;系统会进入一个临时的救援 shell(通常是 switch_root:/#),

此时文件系统是只读的。需要重新挂载为可读写:mount -o remount,rw /sysroot

切换到真实根文件系统:chroot /sysroot

修改root密码:passwd root

如果启用了SELinux,还需执行:touch /.autorelabel

退出chroot环境: exit

退出救援shell:exit

至此密码修改完成,系统自动重启。

三、配置oracle随机启动,注意根据实际情况确认是否需要随机启动

vim /etc/rc.local增加如下:

su - oracle -c "sh /home/oracle/orastart.sh" 

orastart.sh脚本如下:

lsnrctl start

sqlplus / as sysdba <<EOF

startup

exit

举报

相关推荐

0 条评论