一次断电开关机后,网站的信息无法浏览了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
代码查源
我们代码会有连接的有以下的组件:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
- Solr cloud
- MySQL
- Oracle
- HBase
一个一个检查,首先排除了MySQL和Oracle,不然我们都无法登录了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
检查Solr
登录solr admin的网站,查看节点是否全是绿色的。
http://xxx:8983/solr/#/~cloud
发现全部断线,虽然服务已经在运行,但是需要重启。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
# 1. 开启各个服务器上的zookeeper
# 2. 关闭solr 后再重启
/data/zookeeper-3.4.6/bin/zkServer.sh start
/data/solr/solr-6.3.0/bin/solr stop -all
/data/solr/solr-6.3.0/bin/solr start -force
经过折腾,全部绿色,网站搜索服务正常,但是详情信息无法加载。
内容详情页面主要用到了是HBase,那么HBase一定出现了问题。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
检查HBase
登录管理页面查看。
看不出任何问题,但是后面的监控信息却为空的,说明还是存在问题的,我们打开master 的ui界面查看状态。
发现Region Servers的信息为空,确定了我的猜测。
开始登录HBase shell查看。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
bin/hbase shell
list
list命令的时候出现了错误:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet
at org.apache.hadoop.hbase.master.HMaster.checkServiceStarted()
at org.apache.hadoop.hbase.master.MasterRpcServices.isMasterRunning()
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$()
at org.apache.hadoop.hbase.ipc.RpcServer.call()
at org.apache.hadoop.hbase.ipc.CallRunner.run()
at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop()
at org.apache.hadoop.hbase.ipc.RpcExecutor$()
at java.lang.Thread.run()
....
util.FSUtils: Waiting for dfs to exit safe mode
通信出现了问题,于是打开了HDFS查看是否开启了安全模式。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
Security is off.
Safe mode is ON. The reported blocks 4028 needs additional 7 blocks to reach the threshold 1.0000 of total blocks 4035. The number of live datanodes 5 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
3,236 files and directories, 4,038 blocks = 7,274 total filesystem object(s).
Heap Memory used 127.18 MB of 2.96 GB Heap Memory. Max Heap Memory is 2.96 GB.
Non Heap Memory used 90.57 MB of 92.66 MB Commited Non Heap Memory. Max Non Heap Memory is <unbounded>.
长时间进入了安全模式,需要关闭安全模式文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
hdfs dfsadmin -safemode leave
报错文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
safemode: Access denied for user root. Superuser privilege is required
查看运行hdfs是哪个用户文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
ps -ef | grep 'hdfs'
su hdfs
hdfs dfsadmin -safemode leave
再次刷新hbase ui
再次刷新网站信息,展示出来了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
总结
本次出现问题是由于Hdfs长时间进入安全模式引起的。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
HDFS 安全模式的理解
安全模式是hadoop的一种保护机制,用于保证集群中的数据块的安全性。当集群启动的时候,会首先进入安全模式。当系统处于安全模式时会检查数据块的完整性。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
在配置文件中定义了一个最小的副本的副本率。
正常情况下,安全模式会运行一段时间自动退出的,只需要我们稍等一会就行了,到底等多长时间呢,我们可以通过web查看安全模式退出的剩余时间。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
本次,并没有说明时间,差不多等待了大于10个小时了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html
命令hadoop fs –safemode get 查看安全模式状态
命令hadoop fs –safemode enter 进入安全模式状态
命令hadoop fs –safemode leave 离开安全模式状态
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/19155.html