歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux 無法從本地字符界面(tty1-tty6)登陸深度解析

Linux 無法從本地字符界面(tty1-tty6)登陸深度解析

日期:2017/2/28 13:45:50   编辑:Linux教程

問題描述:

每次裝完Oracle數據庫之後,本地的tty1-tty6就無法登陸,只能通過tty或tty7圖形終端登陸。

問題現象:

輸入完用戶名密碼之後,自動彈回如下界面:




日志信息:

[root@nec3 ~]# tail -f /var/log/messages

Dec 13 09:27:58 nec3 init: tty (/dev/tty1) main process ended, respawning
Dec 13 09:28:03 nec3 init: tty (/dev/tty1) main process (2782) terminated with status 1
Dec 13 09:28:03 nec3 init: tty (/dev/tty1) main process ended, respawning
Dec 13 09:28:43 nec3 init: tty (/dev/tty1) main process (2787) terminated with status 1
Dec 13 09:28:43 nec3 init: tty (/dev/tty1) main process ended, respawning
Dec 13 09:29:51 nec3 init: tty (/dev/tty1) main process (2793) terminated with status 1
Dec 13 09:29:51 nec3 init: tty (/dev/tty1) main process ended, respawning

我們可以從上面的message日志中看到本地tty1登陸的這個動作,但是沒有報錯,那麼登陸無非要去進行用戶名和密碼驗證,那麼用戶密碼驗證信息會記錄在名為secure的日志中,如果報密碼錯誤日志中會顯示驗證失敗,日志條目為:FAILED LOGIN 1 FROM (null) FOR root, Authentication failure。

實際上我們在secure日志中看到的信息是Module is unknow以及無法打開pam_limits.so模塊。

[root@nec3 ~]# tail -f /var/log/secure

Dec 13 09:28:03 nec3 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Dec 13 09:28:03 nec3 login: Module is unknown
Dec 13 09:28:08 nec3 login: PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: cannot open shared object file: No such file or directory
Dec 13 09:28:08 nec3 login: PAM adding faulty module: /lib/security/pam_limits.so
Dec 13 09:28:43 nec3 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Dec 13 09:28:43 nec3 login: Module is unknown

日志分析:

根據上面的日志條目中我們可以看到有無效模塊,而這個無效的模塊信息是我們在數據庫安裝過程中添加到/etc/pam.d/login配置文件中的,我現在需要判斷下這個模塊是否存在,為什麼需要這個模塊。

[root@nec3 ~]# grep pam_limits /etc/pam.d/login

session required /lib/security/pam_limits.so

[root@nec3 ~]# ls -rtl /lib
lib/ lib64/
[root@nec3 ~]# ls -rtl /lib/security/pam*
ls: cannot access /lib/security/pam*: No such file or directory

那麼我們可以看到該模塊是不存在的,隨即我們再看下lib64這個目錄中是否有oracle安裝所需的該模塊。

[root@nec3 ~]# ls -rtl /lib64/security/pam_limits.so

-rwxr-xr-x. 1 root root 18592 Oct 7 2013 /lib64/security/pam_limits.so
那麼我們可以清楚的看到在這裡是存在這個模塊的。

問題處理:

既然已經看到問題的原因,那麼將會有如下三個解決方案:

1、 拷貝條目:

[root@nec3 ~]# cp /lib64/security/pam_limits.so /lib/security/pam_limits.so
[root@nec3 ~]# ls -rtl /lib/security/pam_limits.so
-rwxr-xr-x. 1 root root 18592 Oct 7 2013 /lib/security/pam_limits.so

2、 ln pam_limits.so
[root@nec3 ~]# ln -s /lib64/security/pam_limits.so /lib/security/pam_limits.so

3、 修改配置文件login為如下:
[root@nec3 ~]# grep pam_limits /etc/pam.d/login
session required /lib64/security/pam_limits.so

後記:

文中提到為什麼要用pam_limits.so這個模塊,因為我們在配置Oracle部署環境的時候配置了limits.conf限制文件,那麼我們要使這個配置生效,必須要確保pam_limits.so被加入到登陸配置文件中應用生效。

參考:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/chap-Oracle_9i_and_10g_Tuning_Guide-Setting_Shell_Limits_for_the_Oracle_User.html

That these limits work you also need to ensure that pam_limits is configured in the /etc/pam.d/system-auth file, or in /etc/pam.d/sshd for ssh, /etc/pam.d/su for su, or /etc/pam.d/login for local access and telnet and disable telnet for all log in methods. Here are examples of the two session entries in the /etc/pam.d/system-auth file:

Copyright © Linux教程網 All Rights Reserved