错误整体记录
rsync备份服务类
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服务类
1.Permission denied
2.Read-only file system
nginx服务类
1.404 Not Found
2.403 Forbidden
3,3.Cannot assign requested address
4.304 Not Modified
5.conflicting server name
6.hosts没有添加解析
7.not terminated by ";"
8.重启或启动nginx提示错误
9.401 Authorization Required
10.File not found.
11 .Connection refused
mysql相关故障
1.进入mysql报错
2.数据库不允许远程连接
错误详细
rsync
1.not a regular file
[root@backup ~]# scp /etc 172.16.1.31:/tmp/
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:
/etc: not a regular file##不是·一个·普通文件
scp默认只能复制普通文件 与cp类似
加上-r 即可
2.remote command not found
172.16.1.31:/tmp
[email protected]'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]
远程端命令找不到
远程服务器中没有这个命令
检查远程服务器是否安装了rsync 没有yum安装即可
3.Connection refused
连接拒绝
检查是否能ping通对应服务器或者rsync服务端修改完配置文件后是否重启服务
[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 [email protected]::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]
错误并没有直接告诉我们是什么,我们需要看下执行日志
查看日志
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]
错误日志表示目录所有者为rsync
解决:第一个错误:修改文件所有者为rsync就可以了
chmod root:root /etc/rsync.password
第二个错误:修改目录所有者为rsync
chown rsync:rsync /data
5.password file must not be other-accessible
密码文件不能被他人访问
[root@nfs01 ~]# rsync -avz /etc/hostname [email protected]::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]
很明显提示直接告诉我们了,现在密码文件是对外人开放的·。把权限设置为600即可
解决
修改权限为600
chmod 600 /etc/rsync.password
NFS服务类
1.password mismatch
auth failed on module backup from (172.16.1.7) for rsync_backup: password mismatch
nfs
wrong fs type
错误的文件系统类型 nfs文件系统无法识别
没有安装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. helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
2.Permission denied
没有权限,拒绝访问
[root@web01 ~]# touch /data/w/oldboy2.txt
touch: cannot touch ‘/data/w/oldboy2.txt’: Permission denied
尝试在共享目录中创建文件,却提示权限拒绝。
解决:
检查下服务端共享目录的所有者是否是默认虚拟用户或者指定的虚拟用户。
[root@nfs01 ~]# ll -d /app/w
drwxr-xr-x 2 root root 43 May 23 08:08 /app/w
把共享目录所有者修改为用户映射对应的虚拟用户即可
[root@nfs01 ~]# chown www:www /app/w
3. Read-only file system
只读文件系统
[root@web01 ~]# touch /data/r/oldboy.txt
touch: cannot touch ‘/data/r/oldboy.txt’: Read-only file system
尝试在共享目录中创建文件提示只读文件系统
解决
检查nfs配置文件中是否设置了只读权限
[root@nfs01 ~]# cat /etc/exports
#share /app/r
/app/r 172.16.1.0/24(ro,sync,all_squash,anonuid=888,anongid=888)
ro表示权限为只读。rw 表示可读,可写
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配置文件中设置all_squash参数并指定 NFS 的用户虚拟用户后。在客户端创建文件所有者却显示为uid和gid.
吧
解决
在客户端创建一个同样的用户即可
[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服务类
1.403 Forbidden
首页文件不存在 默认找首页文件 403
或没有权限访问
解决
检查站点目录下是否有名为index.html首页文件。或者权限是否为陌生人可见
[root@web01 /usr/share/nginx/html/www]# ll
total 0
[root@web01 /usr/share/nginx/html/www]# curl www.oldboy.com
403 Forbidden
403 Forbidden
nginx/1.16.0
[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
403 Forbidden
403 Forbidden
nginx/1.16.0
404 Not Found
请求的资源资源不存在
解决
站点目录下没有你想要的文件资源
[root@web01 /etc/nginx/conf.d]# curl www.oldboy.com/oldboy.txt
404 Not Found
404 Not Found
nginx/1.16.0
3.Cannot assign requested address
无法分配指定的ip地址,本地没有10.0.0.9ip
解决
配置nginx基于ip的虚拟主机后,检查语法提示无法分配ip。临时添加个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: 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
域名冲突:有两个或几个虚拟主机的域名相同了
解决
修改完域名后提示域名冲突,
[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过滤下是否有相同的域名
[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没有添加解析
没有配置hosts解析,用curl命令访问nginx网站时提示
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 ";"
没有以分号结尾
[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.重启或启动nginx提示错误
[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 关闭服务
再启动 systemctl start nginx 就可以了
9.401 Authorization Required
server模块中对网站添加的密码权限,需要输入密码才能查看网站
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; 这一行,是否是正确的。
我出现过的错误是少了个f 排查大半天。
11.File not found.
文件找不到
排查思路:
部署LNMP环境的时候,创建一个html结尾的静态资源,一个以php结尾的动态资源。访问静态资源可以找到,访问动态资源却提示找不到。
[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网站配置文件
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;
}
}
错误出现在第二个location里没有指定站点目录
解决办法有两个第一个就是在第一个location之前指定一个站点目录。
第二个就是在第二个location里指定一个站点目录。
mysql相关
进入mysql报错
[root@web01 ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决
mysql没有启动,启动mariadb即可解决
[root@web01 ~]# systemctl start mariadb
2.mysql数据库不允许远程登录
[root@nfs01 ~]# mysql -uwordpress -p -h 172.16.1.31
Enter password:
ERROR 1045 (28000): Access denied for user 'wordpress'@'nfs01' (using password: YES)
解决
第一种原因是用户对数据库没有远程权限.授权用户远程连接权限即可
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)
用户权限发生改变的后没有刷新用户权限。刷新用户权限或者重新启动mariadb即可解决
MariaDB [(none)]> flush privileges;
或者
systemctl restart mariadb
第四种原因 密码错误。检查操作记录。授权新的密码
操作记录会被放在当前用户下一个隐藏文件里
[root@nfs01 ~]# ll .mysql_history
-rw------- 1 root root 321 Jun 12 19:58 .mysql_history
确认密码不多后,重新授权就行
grant all on wordpress.* to 'wordpress'@'172.16.1.%' identified by '123456';