錯(cuò)誤整體記錄
rsync備份服務(wù)類
1.not a regular file
2.remote command not found
3.Connection Refuse
4.sending incremental file list
5.password file must not be other-accessible
NFS服務(wù)類
1.Permission denied
2.Read-only file system
nginx服務(wù)類
1.404 Not Found
2.403 Forbidden
3,3.Cannot assign requested address
4.304 Not Modified
5.conflicting server name
6.hosts沒(méi)有添加解析
7.not terminated by ";"
8.重啟或啟動(dòng)nginx提示錯(cuò)誤
9.401 Authorization Required
10.File not found.
11 .Connection refused
mysql相關(guān)故障
1.進(jìn)入mysql報(bào)錯(cuò)
2.數(shù)據(jù)庫(kù)不允許遠(yuǎn)程連接
錯(cuò)誤詳細(xì)
rsync
1.not a regular file
[root@backup ~]# scp /etc 172.16.1.31:/tmp/
root@172.16.1.31's password:
Permission denied, please try again.
root@172.16.1.31's password:
/etc: not a regular file##不是·一個(gè)·普通文件
scp默認(rèn)只能復(fù)制普通文件 與cp類似
加上-r 即可
2.remote command not found
172.16.1.31:/tmp
root@172.16.1.31's password:
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at io.c(226) [sender=3.1.2]
遠(yuǎn)程端命令找不到
遠(yuǎn)程服務(wù)器中沒(méi)有這個(gè)命令
檢查遠(yuǎn)程服務(wù)器是否安裝了rsync 沒(méi)有yum安裝即可
3.Connection refused
連接拒絕
檢查是否能ping通對(duì)應(yīng)服務(wù)器或者rsync服務(wù)端修改完配置文件后是否重啟服務(wù)
[root@backup ~]# rsync -avz /etc 176.16.1.31:/tmp
ssh: connect to host 176.16.1.31 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
4.Permission denied
[root@nfs01 ~]# rsync -avz /etc/hostname rsync_backup@172.16.1.41::data --password-file /etc/rsync.password
sending incremental file list
rsync: ERROR: cannot stat destination "." (in data): Permission denied (13)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(635) [Receiver=3.1.2]
錯(cuò)誤并沒(méi)有直接告訴我們是什么,我們需要看下執(zhí)行日志
查看日志
2019/05/20 20:56:55 [16288] params.c:Parameter() - Ignoring badly formed line in config file: ignore errors
2019/05/20 20:56:55 [16288] connect from nfs01 (172.16.1.31)
2019/05/20 20:56:55 [16288] rsync to data/ from rsync_backup@nfs01 (172.16.1.31)
2019/05/20 20:56:55 [16288] receiving file list
2019/05/20 20:56:55 [16288] rsync: ERROR: cannot stat destination "." (in data): Permission denied (13)
2019/05/20 20:56:55 [16288] rsync error: errors selecting input/output files, dirs (code 3) at main.c(635) [Receiver=3.1.2]
錯(cuò)誤日志表示目錄所有者為rsync
解決:第一個(gè)錯(cuò)誤:修改文件所有者為rsync就可以了
chmod root:root /etc/rsync.password
第二個(gè)錯(cuò)誤:修改目錄所有者為rsync
chown rsync:rsync /data
5.password file must not be other-accessible
密碼文件不能被他人訪問(wèn)
[root@nfs01 ~]# rsync -avz /etc/hostname rsync_backup@172.16.1.41::data --password-file /etc/rsync.password
ERROR: password file must not be other-accessible
rsync error: syntax or usage error (code 1) at authenticate.c(196) [sender=3.1.2]
很明顯提示直接告訴我們了,現(xiàn)在密碼文件是對(duì)外人開(kāi)放的·。把權(quán)限設(shè)置為600即可
解決
修改權(quán)限為600
chmod 600 /etc/rsync.password
NFS服務(wù)類
1.password mismatch
auth failed on module backup from (172.16.1.7) for rsync_backup: password mismatch
nfs
wrong fs type
錯(cuò)誤的文件系統(tǒng)類型 nfs文件系統(tǒng)無(wú)法識(shí)別
沒(méi)有安裝nfs-utils
mount -t nfs 172.16.1.31:/data /mnt/
mount: wrong fs type, bad option, bad superblock on 172.16.1.31:/data,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
2.Permission denied
沒(méi)有權(quán)限,拒絕訪問(wèn)
[root@web01 ~]# touch /data/w/oldboy2.txt
touch: cannot touch ‘/data/w/oldboy2.txt’: Permission denied
嘗試在共享目錄中創(chuàng)建文件,卻提示權(quán)限拒絕。
解決:
檢查下服務(wù)端共享目錄的所有者是否是默認(rèn)虛擬用戶或者指定的虛擬用戶。
[root@nfs01 ~]# ll -d /app/w
drwxr-xr-x 2 root root 43 May 23 08:08 /app/w
把共享目錄所有者修改為用戶映射對(duì)應(yīng)的虛擬用戶即可
[root@nfs01 ~]# chown www:www /app/w
3. Read-only file system
只讀文件系統(tǒng)
[root@web01 ~]# touch /data/r/oldboy.txt
touch: cannot touch ‘/data/r/oldboy.txt’: Read-only file system
嘗試在共享目錄中創(chuàng)建文件提示只讀文件系統(tǒng)
解決
檢查nfs配置文件中是否設(shè)置了只讀權(quán)限
[root@nfs01 ~]# cat /etc/exports
#share /app/r
/app/r 172.16.1.0/24(ro,sync,all_squash,anonuid=888,anongid=888)
ro表示權(quán)限為只讀。rw 表示可讀,可寫(xiě)
4.-rw-r--r-- 1 888 888 0 May 23 08:09 oldboy1.txt
[root@web01 ~]# ll /data/w
total 0
-rw-r--r-- 1 888 888 0 May 23 08:09 oldboy1.txt
-rw-r--r-- 1 888 888 0 May 22 22:33 oldboy.txt
nfs配置文件中設(shè)置all_squash參數(shù)并指定 NFS 的用戶虛擬用戶后。在客戶端創(chuàng)建文件所有者卻顯示為uid和gid.
吧
解決
在客戶端創(chuàng)建一個(gè)同樣的用戶即可
[root@web01 ~]# groupadd -g 888 www
[root@web01 ~]# useradd -u 888 -g www -s /sbin/nologin -M www
[root@web01 ~]# id www
uid=888(www) gid=888(www) groups=888(www)
[root@web01 ~]# ll /data/w
total 0
-rw-r--r-- 1 www www 0 May 23 08:09 oldboy1.txt
-rw-r--r-- 1 www www 0 May 22 22:33 oldboy.txt
nginx服務(wù)類
1.403 Forbidden
首頁(yè)文件不存在 默認(rèn)找首頁(yè)文件 403
或沒(méi)有權(quán)限訪問(wèn)
解決
檢查站點(diǎn)目錄下是否有名為index.html首頁(yè)文件?;蛘邫?quán)限是否為陌生人可見(jiàn)
[root@web01 /usr/share/nginx/html/www]# ll
total 0
[root@web01 /usr/share/nginx/html/www]# curl www.oldboy.com
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.16.0</center>
</body>
</html>
[root@web01 /usr/share/nginx/html/www]# ll
total 4
-rw-r----- 1 root root 15 Jun 5 08:54 index.html
[root@web01 /usr/share/nginx/html/www]# curl www.oldboy.com
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.16.0</center>
</body>
</html>
404 Not Found
請(qǐng)求的資源資源不存在
解決
站點(diǎn)目錄下沒(méi)有你想要的文件資源
[root@web01 /etc/nginx/conf.d]# curl www.oldboy.com/oldboy.txt
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.16.0</center>
</body>
</html>
3.Cannot assign requested address
無(wú)法分配指定的ip地址,本地沒(méi)有10.0.0.9ip
解決
配置nginx基于ip的虛擬主機(jī)后,檢查語(yǔ)法提示無(wú)法分配ip。臨時(shí)添加個(gè)ip即可
[root@web01 /etc/nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to 10.0.0.9:80 failed (99: Cannot assign requested address)
nginx: configuration file /etc/nginx/nginx.conf test failed
ip addr add 10.0.0.9/24 dev eth0 label eth0:1
[root@web01 /usr/share/nginx/html/www]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:0f:39:5c brd ff:ff:ff:ff:ff:ff
inet 10.0.0.7/24 brd 10.0.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.0.0.9/24 scope global secondary eth0:2
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe0f:395c/64 scope link
valid_lft forever preferred_lft forever
4.304 Not Modified 用戶讀取瀏覽器緩存
5.conflicting server name
域名沖突:有兩個(gè)或幾個(gè)虛擬主機(jī)的域名相同了
解決
修改完域名后提示域名沖突,
[root@web01 /etc/nginx/conf.d]# nginx -t
nginx: [warn] conflicting server name "www.oldboy.com" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
grep過(guò)濾下是否有相同的域名
[root@web01 /etc/nginx/conf.d]# grep -R www.oldboy.com ../conf.d
../conf.d/01.www.conf: server_name www.oldboy.com;
../conf.d/default.conf: server_name www.oldboy.com;
6.hosts沒(méi)有添加解析
沒(méi)有配置hosts解析,用curl命令訪問(wèn)nginx網(wǎng)站時(shí)提示
nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:43
nginx: configuration file /etc/nginx/nginx.conf test failed
7.not terminated by ";"
沒(méi)有以分號(hào)結(jié)尾
[root@wed01 ~]# nginx -t
nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:43
nginx: configuration file /etc/nginx/nginx.conf test failed
8.重啟或啟動(dòng)nginx提示錯(cuò)誤
[root@web-204 html]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
解決
先使用systemctl stop nginx 關(guān)閉服務(wù)
再啟動(dòng) systemctl start nginx 就可以了
9.401 Authorization Required
server模塊中對(duì)網(wǎng)站添加的密碼權(quán)限,需要輸入密碼才能查看網(wǎng)站
auth_basic "Auth access Blog Input your password";
auth_basic_user_file /etc/nginx/htpasswd;
9. Connection refused
連接被解決
解決
檢查nginx主配置文件的include /etc/nginx/conf.d/*.conf; 這一行,是否是正確的。
我出現(xiàn)過(guò)的錯(cuò)誤是少了個(gè)f 排查大半天。
11.File not found.
文件找不到
排查思路:
部署LNMP環(huán)境的時(shí)候,創(chuàng)建一個(gè)html結(jié)尾的靜態(tài)資源,一個(gè)以php結(jié)尾的動(dòng)態(tài)資源。訪問(wèn)靜態(tài)資源可以找到,訪問(wèn)動(dòng)態(tài)資源卻提示找不到。
[root@web02 /usr/share/nginx/html/www]# curl 10.0.0.8/oldboy.txt
www.oldboy.com
[root@web02 /usr/share/nginx/html/www]# curl 10.0.0.8/oldboy.php
File not found.
檢查nginx網(wǎng)站配置文件
server {
listen 80;
server_name blog.oldboy.com;
access_log /var/log/nginx/access_www.log main;
location / {
root /usr/share/nginx/html/www;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(php|php5)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
錯(cuò)誤出現(xiàn)在第二個(gè)location里沒(méi)有指定站點(diǎn)目錄
解決辦法有兩個(gè)第一個(gè)就是在第一個(gè)location之前指定一個(gè)站點(diǎn)目錄。
第二個(gè)就是在第二個(gè)location里指定一個(gè)站點(diǎn)目錄。
mysql相關(guān)
進(jìn)入mysql報(bào)錯(cuò)
[root@web01 ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解決
mysql沒(méi)有啟動(dòng),啟動(dòng)mariadb即可解決
[root@web01 ~]# systemctl start mariadb
2.mysql數(shù)據(jù)庫(kù)不允許遠(yuǎn)程登錄
[root@nfs01 ~]# mysql -uwordpress -p -h 172.16.1.31
Enter password:
ERROR 1045 (28000): Access denied for user 'wordpress'@'nfs01' (using password: YES)
解決
第一種原因是用戶對(duì)數(shù)據(jù)庫(kù)沒(méi)有遠(yuǎn)程權(quán)限.授權(quán)用戶遠(yuǎn)程連接權(quán)限即可
grant all on wordpress.* to 'wordpress'@'172.16.1.%' identified by '123456';
第二種原因有空白用戶,把空白用戶刪掉就可以解決
MariaDB [(none)]> select user,host from mysql.user;
+-----------+------------+
| user | host |
+-----------+------------+
| root | 127.0.0.1 |
| wordpress | 172.16.1.% |
| root | ::1 |
| | localhost |
| root | localhost |
| wordpress | localhost |
| | nfs01 |
| root | nfs01 |
+-----------+------------+
MariaDB [(none)]> drop user ''@'nfs01' ;
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> drop user ''@'localhost' ;
Query OK, 0 rows affected (0.00 sec)
用戶權(quán)限發(fā)生改變的后沒(méi)有刷新用戶權(quán)限。刷新用戶權(quán)限或者重新啟動(dòng)mariadb即可解決
MariaDB [(none)]> flush privileges;
或者
systemctl restart mariadb
第四種原因 密碼錯(cuò)誤。檢查操作記錄。授權(quán)新的密碼
操作記錄會(huì)被放在當(dāng)前用戶下一個(gè)隱藏文件里
[root@nfs01 ~]# ll .mysql_history
-rw------- 1 root root 321 Jun 12 19:58 .mysql_history
確認(rèn)密碼不多后,重新授權(quán)就行
grant all on wordpress.* to 'wordpress'@'172.16.1.%' identified by '123456';