Linux error number

本文详细列举了从errno.00到errno.132的系统错误代码及其含义,涵盖了操作未被允许、文件不存在、资源暂时不可用、内存分配失败等多种常见错误情况,是开发者排查系统级错误的实用指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

errno.00 is: Success
errno.01 is: Operation not permitted
errno.02 is: No such file or directory
errno.03 is: No such process
errno.04 is: Interrupted system call
errno.05 is: Input/output error
errno.06 is: No such device or address
errno.07 is: Argument list too long
errno.08 is: Exec format error
errno.09 is: Bad file descriptor
errno.10 is: No child processes
errno.11 is: Resource temporarily unavailable[资源临时不可用](连续发送数据时候回出此错,加延时)
errno.12 is: Cannot allocate memory
errno.13 is: Permission denied
errno.14 is: Bad address
errno.15 is: Block device required
errno.16 is: Device or resource busy
errno.17 is: File exists
errno.18 is: Invalid cross-device link
errno.19 is: No such device
errno.20 is: Not a directory
errno.21 is: Is a directory
errno.22 is: Invalid argument
errno.23 is: Too many open files in system
errno.24 is: Too many open files
errno.25 is: Inappropriate ioctl for device
errno.26 is: Text file busy
errno.27 is: File too large
errno.28 is: No space left on device
errno.29 is: Illegal seek
errno.30 is: Read-only file system
errno.31 is: Too many links
errno.32 is: Broken pipe[断开的管道](原因:the broken pipe error occurs if one end of the
TCP socket closes connection(using disconnect) or gets killed and the other
end tries to still write to it. An indication of a closed/terminated
connection is a return value of 0 when you try to read from that socket
using recv. After receiving such an error, if you try to still write to the
socket, your process gets sent the SIGPIPE signal which kills it. 
)
errno.33 is: Numerical argument out of domain
errno.34 is: Numerical result out of range
errno.35 is: Resource deadlock avoided
errno.36 is: File name too long
errno.37 is: No locks available
errno.38 is: Function not implemented
errno.39 is: Directory not empty
errno.40 is: Too many levels of symbolic links
errno.41 is: Unknown error 41
errno.42 is: No message of desired type
errno.43 is: Identifier removed
errno.44 is: Channel number out of range
errno.45 is: Level 2 not synchronized
errno.46 is: Level 3 halted
errno.47 is: Level 3 reset
errno.48 is: Link number out of range
errno.49 is: Protocol driver not attached
errno.50 is: No CSI structure available
errno.51 is: Level 2 halted
errno.52 is: Invalid exchange
errno.53 is: Invalid request descriptor
errno.54 is: Exchange full
errno.55 is: No anode
errno.56 is: Invalid request code
errno.57 is: Invalid slot
errno.58 is: Unknown error 58
errno.59 is: Bad font file format
errno.60 is: Device not a stream
errno.61 is: No data available
errno.62 is: Timer expired
errno.63 is: Out of streams resources
errno.64 is: Machine is not on the network
errno.65 is: Package not installed
errno.66 is: Object is remote
errno.67 is: Link has been severed
errno.68 is: Advertise error
errno.69 is: Srmount error
errno.70 is: Communication error on send
errno.71 is: Protocol error
errno.72 is: Multihop attempted
errno.73 is: RFS specific error
errno.74 is: Bad message
errno.75 is: Value too large for defined data type
errno.76 is: Name not unique on network
errno.77 is: File descriptor in bad state
errno.78 is: Remote address changed
errno.79 is: Can not access a needed shared library
errno.80 is: Accessing a corrupted shared library
errno.81 is: .lib section in a.out corrupted
errno.82 is: Attempting to link in too many shared libraries
errno.83 is: Cannot exec a shared library directly
errno.84 is: Invalid or incomplete multibyte or wide character
errno.85 is: Interrupted system call should be restarted
errno.86 is: Streams pipe error
errno.87 is: Too many users
errno.88 is: Socket operation on non-socket
errno.89 is: Destination address required
errno.90 is: Message too long
errno.91 is: Protocol wrong type for socket
errno.92 is: Protocol not available
errno.93 is: Protocol not supported
errno.94 is: Socket type not supported
errno.95 is: Operation not supported
errno.96 is: Protocol family not supported
errno.97 is: Address family not supported by protocol
errno.98 is: Address already in use
errno.99 is: Cannot assign requested address
errno.100 is: Network is down
errno.101 is: Network is unreachable
errno.102 is: Network dropped connection on reset
errno.103 is: Software caused connection abort
errno.104 is: Connection reset by peer[l连接被对端重置]
errno.105 is: No buffer space available
errno.106 is: Transport endpoint is already connected
errno.107 is: Transport endpoint is not connected
errno.108 is: Cannot send after transport endpoint shutdown
errno.109 is: Too many references: cannot splice
errno.110 is: Connection timed out
errno.111 is: Connection refused
errno.112 is: Host is down
errno.113 is: No route to host
errno.114 is: Operation already in progress
errno.115 is: Operation now in progress
errno.116 is: Stale NFS file handle
errno.117 is: Structure needs cleaning
errno.118 is: Not a XENIX named type file
errno.119 is: No XENIX semaphores available
errno.120 is: Is a named type file
errno.121 is: Remote I/O error
errno.122 is: Disk quota exceeded
errno.123 is: No medium found
errno.124 is: Wrong medium type
errno.125 is: Operation canceled
errno.126 is: Required key not available
errno.127 is: Key has expired
errno.128 is: Key has been revoked
errno.129 is: Key was rejected by service
errno.130 is: Owner died
errno.131 is: State not recoverable
errno.132 is: Unknown error 132
132-255 全是Unknown error

<think>我们正在处理的是MongoDB的mongos进程启动时报告的错误:"child process failed, exited with error number 14"。错误号14在Linux系统中通常对应EFAULT(Bad address),即进程试图访问无效的内存地址。结合引用[4]的内容,该错误可能与文件权限和未正常关闭有关。 根据引用[4]中的案例,错误14的常见原因包括: 1. 没有正常关闭MongoDB(例如使用kill -9强制终止)。 2. 使用不同用户启动MongoDB导致文件权限问题(例如用root启动,但systemctl服务配置的用户是mongo)。 因此,我们可以按照以下步骤进行排查和解决: ### 步骤1:检查文件权限 由于mongos进程需要访问配置文件、数据目录和日志文件等,确保这些文件的所有权和权限正确非常重要。 1. **确认mongos运行的用户**:通常mongos服务会以特定的用户(如mongod或mongo)运行。检查服务配置文件(如`/usr/lib/systemd/system/mongos.service`)中指定的用户。 2. **检查相关文件和目录的权限**:确保数据目录、日志文件路径以及配置文件等都属于mongos运行的用户,并且该用户有读写权限。 例如,如果mongos运行的用户是`mongod`,数据目录为`/data/mongos`,日志文件为`/var/log/mongodb/mongos.log`,则执行: ```bash sudo chown -R mongod:mongod /data/mongos sudo chown mongod:mongod /var/log/mongodb/mongos.log ``` ### 步骤2:检查是否已有mongos进程在运行 如果之前启动的mongos没有正常关闭,可能会导致端口被占用或锁文件存在,从而阻止新的进程启动。 1. **检查进程**: ```bash ps aux | grep mongos ``` 如果发现已有mongos进程,尝试用正确的方式停止它(如使用`kill`命令发送SIGTERM信号,而不是SIGKILL)。 2. **检查锁文件**:mongos在启动时会创建锁文件(通常在数据目录中)。如果上次关闭不正常,锁文件可能未被清除。删除锁文件(如果有): ```bash rm -f /data/mongos/mongos.lock # 请根据实际数据目录调整 ``` ### 步骤3:检查日志 启动mongos时,不要使用`--fork`参数,这样可以直接在控制台看到错误信息。例如: ```bash sudo -u mongod mongos --config /etc/mongos.conf ``` 注意:确保以正确的用户(这里是mongod)运行命令。 ### 步骤4:检查配置文件 检查mongos的配置文件(如`/etc/mongos.conf`)是否正确,特别是以下配置项: - `configDB`:指向配置服务器的地址 - `port`:监听的端口 - `logpath`:日志文件路径 - `pidFilePath`:进程ID文件路径 确保这些配置项指向的路径存在,并且mongos运行的用户有权限访问。 ### 步骤5:检查端口冲突 如果mongos配置的端口已被其他进程占用,启动会失败。使用以下命令检查端口占用情况: ```bash netstat -tulnp | grep <port> ``` 其中`<port>`是mongos配置的端口(默认为27017)。 ### 步骤6:修复文件系统错误 如果MongoDB所在的分区有文件系统错误,也可能导致内存映射文件访问失败。可以尝试对数据目录所在的分区进行`fsck`检查(需要先卸载分区,因此需谨慎操作)。 ### 步骤7:使用GDB调试(高级) 如果上述步骤未能解决问题,可以尝试使用GDB调试mongos进程。首先,确保系统安装了GDB和MongoDB的调试符号包(如果可用)。然后运行: ```bash gdb --args mongos --config /etc/mongos.conf ``` 在GDB中运行`run`命令,当程序崩溃时,使用`bt`命令查看堆栈跟踪。 ### 典型解决方案总结 根据引用[4]的经验,最常见的解决方案是: 1. **确保正确关闭mongos**:如果之前有运行中的mongos,使用正确的方式关闭(如通过mongo shell发送shutdown命令)。 2. **修复文件权限**:将数据目录、日志文件等关键路径的所有权更改为mongos运行的用户(如mongod)。 3. **清理残留文件**:删除锁文件(如果有)。 如果问题仍然存在,请提供启动时控制台输出的错误信息(不使用`--fork`参数)以便进一步分析。 生成的相关问题: 1. 如何正确配置mongos以连接MongoDB分片集群? 2. 如何解决MongoDB启动时的端口冲突问题? 3. 如何为MongoDB服务配置SELinux策略? 4. 在systemd服务中如何正确设置MongoDB的启动参数?</think>### 解决 MongoDB mongos 启动错误 "child process failed, exited with error number 14" 该错误通常由**文件权限问题**或**异常关闭导致的数据损坏**引起,以下是系统级排查和解决方案: --- #### 1. 检查文件权限(关键步骤) 错误号14(EFAULT)最常见原因是mongos进程无权访问数据文件: ```bash # 查看数据目录权限(根据你的配置替换路径) ls -ld /var/lib/mongo /data/mongos # 修复权限(假设mongos服务用户为mongod) sudo chown -R mongod:mongod /var/lib/mongo sudo chown -R mongod:mongod /data/mongos # 如果使用自定义数据目录 ``` > **注意**:如果之前用root启动过mongos(如`sudo mongos --fork`),会导致文件属主错误[^4] --- #### 2. 清理异常关闭残留 强制终止可能导致锁文件残留: ```bash # 删除锁文件(路径在配置文件中查找) sudo rm -f /var/lib/mongo/mongod.lock # 默认位置 sudo rm -f /data/mongos/mongod.lock # 自定义位置 ``` --- #### 3. 检查配置文件 确认关键配置项正确(特别是数据目录路径): ```bash # 查看mongos配置文件 grep -E "shardsvr|configDB|dbpath|pidFilePath" /etc/mongos.conf ``` 确保: - `dbpath` 指向正确的数据目录 - `pidFilePath` 有写入权限 - `configDB` 配置服务器地址正确 --- #### 4. 前台启动获取详细日志 去掉`--fork`参数查看实时错误: ```bash sudo -u mongod mongos --config /etc/mongos.conf ``` 观察输出中是否有以下关键信息: - `Failed to unlink socket file`(套接字文件残留) - `Permission denied`(权限问题) - `Invalid argument`(配置错误) --- #### 5. 检查端口冲突 ```bash # 检查默认端口27017是否被占用 sudo netstat -tulnp | grep 27017 # 如果冲突,在配置文件中修改端口: net: port: 27018 ``` --- #### 6. 修复数据文件(最终手段) 如果怀疑数据损坏: 1. 备份数据目录 2. 尝试修复: ```bash sudo -u mongod mongos --config /etc/mongos.conf --repair ``` --- ### 完整解决流程 ```mermaid graph TD A[启动失败 error 14] --> B[检查数据目录权限] B -->|权限错误| C[chown修复属主] B -->|权限正常| D[清理lock文件] D --> E[前台启动查看日志] E -->|显示套接字错误| F[删除socket文件] E -->|显示配置错误| G[检查configDB设置] E -->|显示端口冲突| H[修改端口] F/G/H --> I[重新启动服务] ``` > **重要提示**: > 如果使用systemd管理服务,修复后执行: > ```bash > sudo systemctl daemon-reload > sudo systemctl start mongos > ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Simple-Soft

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值