排错向 1
MongoDB 启动失败
systemctl status mongodb
看到服务一直还没启动就 crash 了
首先查看硬盘是否满了:
df -h
硬盘君表示不想背锅(
然后查看 /var/log/mongodb/mongod.log
日志
tail -100 /var/log/mongodb/mongod.log
查看日志发现是滚太新了:
{"t":{"$date":"2022-12-26T13:32:57.085+09:00"},"s":"F", "c":"CONTROL", "id":20573, "ctx":"initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"4.4\" }. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value, expected '5.0' or '5.3' or '6.0. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 5.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/5.0/#upgrade-procedures."}}
其中介绍了数据库文件的兼容格式的版本号,然后指了一下文档。
大概意思就是说,您都把我更新到6.x了,我的数据库文件就不兼容以前 4.x 时代的屎山格式了,如果你还要用的话,请先降级到 5.x 然后输入命令让我更新。
当然,我相信您都搜到这来了,肯定是要懒人包结果吧?
首先我们还是先完整备份一下文件比较保险点:
tar zcvf db-bin-backup.tar.gz /var/lib/mongodb/
然后我们要找到旧版的二进制文件,解压或者安装回去:
Arch Linux:
ls /var/cache/pacman/pkg/ | grep mongo
# 不出意外肯定没有,因为 mongodb 是在 aur 里面的
# cd ~/.cache
~/.c/y/mongodb-bin (master)> ll
total 275M
drwxr-xr-x 2 root root 4.0K Apr 29 2022 etc/
-rw-r--r-- 1 h h 30K Apr 29 2022 LICENSE
-rw-r--r-- 1 h h 46M Apr 29 2022 mongodb-bin-5.0.8-1-aarch64.pkg.tar.xz
-rw-r--r-- 1 h h 46M Jun 11 2022 mongodb-bin-5.0.9-1-aarch64.pkg.tar.xz
-rw-r--r-- 1 h h 39M Dec 26 13:30 mongodb-bin-6.0.3-1-aarch64.pkg.tar.xz
-rw-r--r-- 1 h h 17M Apr 29 2022 mongodb-org-mongos_5.0.8_aarch64.deb
-rw-r--r-- 1 h h 17M Jun 11 2022 mongodb-org-mongos_5.0.9_aarch64.deb
-rw-r--r-- 1 h h 18M Dec 26 13:27 mongodb-org-mongos_6.0.3_aarch64.deb
-rw-r--r-- 1 h h 23M Apr 29 2022 mongodb-org-server_5.0.8_aarch64.deb
-rw-r--r-- 1 h h 23M Jun 11 2022 mongodb-org-server_5.0.9_aarch64.deb
-rw-r--r-- 1 h h 25M Dec 26 13:27 mongodb-org-server_6.0.3_aarch64.deb
-rw-r--r-- 1 h h 13M Apr 29 2022 mongodb-org-shell_5.0.8_aarch64.deb
-rw-r--r-- 1 h h 13M Jun 11 2022 mongodb-org-shell_5.0.9_aarch64.deb
(以下略)
# pacman -U mongodb-bin-5.0.9-1-aarch64.pkg.tar.xz
# 这样就降级成功了
其它系统: 大概自己去偷一下旧版的包 https://repo.mongodb.org/apt/debian/dists/bullseye/mongodb-org/5.0/main/binary-amd64/ 还有 https://pkgs.org/ 直接搜索就好
找到带 server 的包,下载到服务器,解压 deb 文件:
cd /tmp
mkdir mongo-deb
cd mongo-deb
wget https://repo.mongodb.org/apt/debian/dists/bullseye/mongodb-org/5.0/main/binary-amd64/mongodb-org-server_5.0.9_amd64.deb
ar x mongodb-org-server_5.0.9_amd64.deb
tar xvf data.tar.xz
然后手动启动下服务端,可以在 screen 里面跑:
screen /usr/bin/mongod --config /etc/mongodb.conf
(也可以把文件移到 /usr/bin 强行替换直接开跑就是了,坏了不要找我)
然后我们登录 mongosh 更新一下:
~# mongosh
test> db.adminCommand( { setFeatureCompatibilityVersion: '5.0' })
{ ok: 1 }
# 这里,在升级到 6.x 版本后可以再执行一遍 '6.0' 的命令 然后大概三四年不用因为这个翻车了
回弹 ok 后我们重新启动下 MongoDB (怕 systemd 已经放弃治疗了)
systemctl restart mongodb
可以发现还是启动不能的状态,我们继续看日志:
{"t":{"$date":"2022-12-26T13:45:40.655+09:00"},"s":"E", "c":"WT", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":13,"message":"[1672029940:654393][1778638:0xffffa4b38440], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: __posix_open_file, 805: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied"}}
{"t":{"$date":"2022-12-26T13:45:40.658+09:00"},"s":"E", "c":"WT", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":13,"message":"[1672029940:658109][1778638:0xffffa4b38440], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: __posix_open_file, 805: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied"}}
{"t":{"$date":"2022-12-26T13:45:40.658+09:00"},"s":"E", "c":"WT", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":13,"message":"[1672029940:658517][1778638:0xffffa4b38440], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: __posix_open_file, 805: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied"}}
{"t":{"$date":"2022-12-26T13:45:40.658+09:00"},"s":"W", "c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}
{"t":{"$date":"2022-12-26T13:45:40.658+09:00"},"s":"F", "c":"STORAGE", "id":28595, "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"13: Permission denied"}}
可以看到是权限问题。
因为我们之前是临时启动的 mongodb 是以非 mongodb 账户执行的,所以文件权限被改了,于是 chown 一下就好:
chown http:http /var/lib/mongodb -R
完整启动日志参考:
{"t":{"$date":"2022-12-26T13:32:56.316+09:00"},"s":"I", "c":"CONTROL", "id":20698, "ctx":"-","msg":"***** SERVER RESTARTED *****"}
{"t":{"$date":"2022-12-26T13:32:56.341+09:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2022-12-26T13:32:56.343+09:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-12-26T13:32:56.354+09:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2022-12-26T13:32:56.371+09:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2022-12-26T13:32:56.371+09:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2022-12-26T13:32:56.372+09:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2022-12-26T13:32:56.372+09:00"},"s":"I", "c":"CONTROL", "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2022-12-26T13:32:56.374+09:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1773477,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","host":"jp-rito"}}
{"t":{"$date":"2022-12-26T13:32:56.374+09:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.3","gitVersion":"f803681c3ae19817d31958965850193de067c516","openSSLVersion":"OpenSSL 1.1.1s 1 Nov 2022","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"aarch64","target_arch":"aarch64"}}}}
{"t":{"$date":"2022-12-26T13:32:56.374+09:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"NAME=\"Arch Linux ARM\"","version":"Kernel 5.19.8-1-aarch64-ARCH"}}}
{"t":{"$date":"2022-12-26T13:32:56.374+09:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongodb.conf","net":{"bindIp":"127.0.0.1","port":27017},"processManagement":{"timeZoneInfo":"/usr/share/zoneinfo"},"storage":{"dbPath":"/var/lib/mongodb","journal":{"enabled":false}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2022-12-26T13:32:56.378+09:00"},"s":"W", "c":"STORAGE", "id":22271, "ctx":"initandlisten","msg":"Detected unclean shutdown - Lock file is not empty","attr":{"lockFile":"/var/lib/mongodb/mongod.lock"}}
{"t":{"$date":"2022-12-26T13:32:56.380+09:00"},"s":"I", "c":"STORAGE", "id":22270, "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/var/lib/mongodb","storageEngine":"wiredTiger"}}
{"t":{"$date":"2022-12-26T13:32:56.380+09:00"},"s":"W", "c":"STORAGE", "id":22302, "ctx":"initandlisten","msg":"Recovering data from the last clean checkpoint."}
{"t":{"$date":"2022-12-26T13:32:56.380+09:00"},"s":"I", "c":"STORAGE", "id":22297, "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem","tags":["startupWarnings"]}
{"t":{"$date":"2022-12-26T13:32:56.381+09:00"},"s":"I", "c":"STORAGE", "id":22315, "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=5396M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,remove=true,path=journal,compressor=snappy),builtin_extension_config=(zstd=(compression_level=6)),file_manager=(close_idle_time=600,close_scan_interval=10,close_handle_minimum=2000),statistics_log=(wait=0),json_output=(error,message),verbose=[recovery_progress:1,checkpoint_progress:1,compact_progress:1,backup:0,checkpoint:0,compact:0,evict:0,history_store:0,recovery:0,rts:0,salvage:0,tiered:0,timestamp:0,transaction:0,verify:0,log:0],,log=(enabled=false),"}}
{"t":{"$date":"2022-12-26T13:32:57.044+09:00"},"s":"I", "c":"STORAGE", "id":4795906, "ctx":"initandlisten","msg":"WiredTiger opened","attr":{"durationMillis":663}}
{"t":{"$date":"2022-12-26T13:32:57.045+09:00"},"s":"I", "c":"RECOVERY", "id":23987, "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
{"t":{"$date":"2022-12-26T13:32:57.068+09:00"},"s":"W", "c":"CONTROL", "id":22120, "ctx":"initandlisten","msg":"Access control is not enabled for the database. Read and write access to data and configuration is unrestricted","tags":["startupWarnings"]}
{"t":{"$date":"2022-12-26T13:32:57.068+09:00"},"s":"W", "c":"CONTROL", "id":5123300, "ctx":"initandlisten","msg":"vm.max_map_count is too low","attr":{"currentValue":65530,"recommendedMinimum":102400,"maxConns":51200},"tags":["startupWarnings"]}
{"t":{"$date":"2022-12-26T13:32:57.085+09:00"},"s":"F", "c":"CONTROL", "id":20573, "ctx":"initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"4.4\" }. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value, expected '5.0' or '5.3' or '6.0. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 5.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/5.0/#upgrade-procedures."}}
{"t":{"$date":"2022-12-26T13:32:57.086+09:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":15000}}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"REPL", "id":4794602, "ctx":"initandlisten","msg":"Attempting to enter quiesce mode"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"-", "id":6371601, "ctx":"initandlisten","msg":"Shutting down the FLE Crud thread pool"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"NETWORK", "id":20562, "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"CONTROL", "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"-", "id":20520, "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"CONTROL", "id":4784908, "ctx":"initandlisten","msg":"Shutting down the PeriodicThreadToAbortExpiredTransactions"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"REPL", "id":4784909, "ctx":"initandlisten","msg":"Shutting down the ReplicationCoordinator"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"SHARDING", "id":4784910, "ctx":"initandlisten","msg":"Shutting down the ShardingInitializationMongoD"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"REPL", "id":4784911, "ctx":"initandlisten","msg":"Enqueuing the ReplicationStateTransitionLock for shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"-", "id":4784912, "ctx":"initandlisten","msg":"Killing all operations for shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"-", "id":4695300, "ctx":"initandlisten","msg":"Interrupted all currently running operations","attr":{"opsKilled":2}}
{"t":{"$date":"2022-12-26T13:32:57.089+09:00"},"s":"I", "c":"TENANT_M", "id":5093807, "ctx":"initandlisten","msg":"Shutting down all TenantMigrationAccessBlockers on global shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.090+09:00"},"s":"I", "c":"COMMAND", "id":4784913, "ctx":"initandlisten","msg":"Shutting down all open transactions"}
{"t":{"$date":"2022-12-26T13:32:57.091+09:00"},"s":"I", "c":"REPL", "id":4784914, "ctx":"initandlisten","msg":"Acquiring the ReplicationStateTransitionLock for shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.091+09:00"},"s":"I", "c":"INDEX", "id":4784915, "ctx":"initandlisten","msg":"Shutting down the IndexBuildsCoordinator"}
{"t":{"$date":"2022-12-26T13:32:57.091+09:00"},"s":"I", "c":"NETWORK", "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2022-12-26T13:32:57.091+09:00"},"s":"I", "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2022-12-26T13:32:57.092+09:00"},"s":"I", "c":"ASIO", "id":22582, "ctx":"MigrationUtil-TaskExecutor","msg":"Killing all outstanding egress activity."}
{"t":{"$date":"2022-12-26T13:32:57.092+09:00"},"s":"I", "c":"COMMAND", "id":4784923, "ctx":"initandlisten","msg":"Shutting down the ServiceEntryPoint"}
{"t":{"$date":"2022-12-26T13:32:57.092+09:00"},"s":"I", "c":"CONTROL", "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"CONTROL", "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"CONTROL", "id":4784928, "ctx":"initandlisten","msg":"Shutting down the TTL monitor"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"CONTROL", "id":6278511, "ctx":"initandlisten","msg":"Shutting down the Change Stream Expired Pre-images Remover"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"CONTROL", "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"CONTROL", "id":4784930, "ctx":"initandlisten","msg":"Shutting down the storage engine"}
{"t":{"$date":"2022-12-26T13:32:57.093+09:00"},"s":"I", "c":"STORAGE", "id":22320, "ctx":"initandlisten","msg":"Shutting down journal flusher thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22321, "ctx":"initandlisten","msg":"Finished shutting down journal flusher thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22322, "ctx":"initandlisten","msg":"Shutting down checkpoint thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22323, "ctx":"initandlisten","msg":"Finished shutting down checkpoint thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":20282, "ctx":"initandlisten","msg":"Deregistering all the collections"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22317, "ctx":"initandlisten","msg":"WiredTigerKVEngine shutting down"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22318, "ctx":"initandlisten","msg":"Shutting down session sweeper thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":22319, "ctx":"initandlisten","msg":"Finished shutting down session sweeper thread"}
{"t":{"$date":"2022-12-26T13:32:57.101+09:00"},"s":"I", "c":"STORAGE", "id":4795902, "ctx":"initandlisten","msg":"Closing WiredTiger","attr":{"closeConfig":"leak_memory=true,"}}
{"t":{"$date":"2022-12-26T13:32:57.114+09:00"},"s":"I", "c":"STORAGE", "id":4795901, "ctx":"initandlisten","msg":"WiredTiger closed","attr":{"durationMillis":13}}
{"t":{"$date":"2022-12-26T13:32:57.114+09:00"},"s":"I", "c":"STORAGE", "id":22279, "ctx":"initandlisten","msg":"shutdown: removing fs lock..."}
{"t":{"$date":"2022-12-26T13:32:57.114+09:00"},"s":"I", "c":"-", "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-12-26T13:32:57.114+09:00"},"s":"I", "c":"CONTROL", "id":20565, "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2022-12-26T13:32:57.114+09:00"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":62}}
hostapd 无法开机启动
发现 hostapd 无法开机启动,然后发现是当 hostapd 启动的时候 wlan0 驱动还没起来:
root@cn-mahiru ~ [4]# systemctl status hostapd
× hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Loaded: loaded (/usr/lib/systemd/system/hostapd.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2022-12-28 17:55:52 CST; 4min 42s ago
Duration: 643ms
Main PID: 394 (code=exited, status=1/FAILURE)
CPU: 28ms
Dec 28 17:55:52 cn-mahiru hostapd[394]: nl80211: Driver does not support authentication/association or connect commands
Dec 28 17:55:52 cn-mahiru hostapd[394]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Dec 28 17:55:52 cn-mahiru hostapd[394]: Could not read interface wlan0 flags: No such device
Dec 28 17:55:52 cn-mahiru hostapd[394]: nl80211 driver initialization failed.
Dec 28 17:55:52 cn-mahiru hostapd[394]: wlan0: interface state UNINITIALIZED->DISABLED
Dec 28 17:55:52 cn-mahiru hostapd[394]: wlan0: AP-DISABLED
Dec 28 17:55:52 cn-mahiru hostapd[394]: wlan0: CTRL-EVENT-TERMINATING
Dec 28 17:55:52 cn-mahiru hostapd[394]: hostapd_free_hapd_data: Interface wlan0 wasn't started
Dec 28 17:55:52 cn-mahiru systemd[1]: hostapd.service: Main process exited, code=exited, status=1/FAILURE
Dec 28 17:55:52 cn-mahiru systemd[1]: hostapd.service: Failed with result 'exit-code'.
然后一堆服务在等网络
network-online.target
完成才启动,开机好久。
写个上线脚本:
root@cn-mahiru ~# cat /bin/wait-wlan0.sh
#!/bin/sh
while ! ip a show wlan0 | grep -F 'UP'
do
sleep 1
done
编辑 hostapd.service
:
root@cn-mahiru ~# systemctl edit hostapd --full
在 [Service]
中添加
ExecStartPre=/bin/sh /bin/wait-wlan0.sh
完整 Service 参考:
[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
After=network.target
[Service]
ExecStartPre=/bin/sh /bin/wait-wlan0.sh
ExecStart=/usr/bin/hostapd /etc/hostapd/hostapd.conf
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target