info

使用Redis实现分布式锁

☆樱花仙子☆ 提交于 2019-12-05 04:25:45
1.实现分布式锁的几种方案 1.Redis实现 (推荐) 2.Zookeeper实现 3.数据库实现 Redis实现分布式锁 * * 在集群等多服务器中经常使用到同步处理一下业务,这是普通的事务是满足不了业务需求,需要分布式锁 * * 分布式锁的常用3种实现: * 0.数据库乐观锁实现 * 1.Redis实现 --- 使用redis的setnx()、get()、getset()方法,用于分布式锁,解决死锁问题 * 2.Zookeeper实现 * 参考:http://surlymo.iteye.com/blog/2082684 * http://www.jb51.net/article/103617.htm * http://www.hollischuang.com/archives/1716?utm_source=tuicool&utm_medium=referral * 1、实现原理: 基于zookeeper瞬时有序节点实现的分布式锁,其主要逻辑如下(该图来自于IBM网站)。大致思想即为:每个客户端对某个功能加锁时,在zookeeper上的与该功能对应的指定节点的目录下,生成一个唯一的瞬时有序节点。判断是否获取锁的方式很简单,只需要判断有序节点中序号最小的一个。当释放锁的时候,只需将这个瞬时节点删除即可。同时,其可以避免服务宕机导致的锁无法释放,而产生的死锁问题。 2、优点

2、wepy安装后提示Cannot read property 'addDeps' 参考自https://www.cnblogs.com/yuanchaoyong/p/11614400.html

梦想与她 提交于 2019-12-05 04:16:30
摘抄自https://www.cnblogs.com/yuanchaoyong/p/11614400.html wepy安装步骤 $ npm install @wepy/cli -g # 全局安装 WePY CLI 工具 $ wepy init standard myproj # 使用 standard 模板初始化项目 $ cd myproj # 进入到项目目录 $ npm install # 安装项目依赖包 $ npm run dev # 监听并且编译项目 wepy build --watch运行后提示ERR Cannot read property 'addDeps' of undefined。 上面这是1.7.x的安装后运行进行以上提示,而我们安装的是2.x, git上已经更新安装方式,第一步 npm install @wepy/cli -g 更改为npm install @wepy/cli@next -g 1. npm install @wepy/cli@next -g 2. wepy init standard myproject 3. cd myproject 4. npm install 5. wepy build --watch 按照此步骤安装后运行结果 [16:17:21] info build app start... [16:17:22] info app

如何在.NET Core控制台程序中使用依赖注入

放肆的年华 提交于 2019-12-05 04:13:09
原文: 如何在.NET Core控制台程序中使用依赖注入 背景介绍 # 依赖注入(Dependency Injection), 是面向对象编程中的一种设计原则,可以用来减低代码之间的耦合度。在.NET Core MVC中 我们可以在 Startup.cs 文件的 ConfigureService 方法中使用服务容器 IServiceCollection 注册接口及其实现类的映射。 例如,当我们需要访问Http上下文时,我们需要配置 IHttpContextAccessor 接口及其实现类 HttpContextAccessor Copy public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); } 那么当我们编写一个.NET Core控制台程序的时候,我们该如何使用依赖注入呢? 使用内置依赖注入 # 在.NET Core中,内置依赖注入模块使用的程序集是 Microsoft.Extensions.DependencyInjection

hadoop 报错:Error: Could not find or load main class

僤鯓⒐⒋嵵緔 提交于 2019-12-05 04:05:57
Error: Could not find or load main class 报这个错是因为当前运行的 .class 文件不在 hadoop-env.sh文件中 export HADOOP_CLASSPATH=${HADOOP_HOME}//你运行的*.class 文件所在路径 [john@localhost ch02]$ ls input output pom.xml src target [john@localhost ch02]$ export $HADOOP_CLASSPATH=target/classes bash: export: `build/classes=target/classes': not a valid identifier [john@localhost ch02]$ export HADOOP_CLASSPATH=target/classes [john@localhost ch02]$ echo $HADOOP_CLASSPATH target/classes [john@localhost ch02]$ hadoop MaxTemperature input/sample.txt output 14/12/13 12:27:14 INFO Configuration.deprecation: session.id is deprecated.

ELK展示NGINX访问IP地理位置图

╄→尐↘猪︶ㄣ 提交于 2019-12-05 04:03:06
一、设置NGINX日志格式 [root@zabbix_server ~]# vim /etc/nginx/nginx.conf log_format access_json_log '{"@timestamp":"$time_local",' '"http_host":"$http_host",' '"clinetip":"$remote_addr",' '"request":"$request",' '"status":"$status",' '"size":"$body_bytes_sent",' '"upstream_addr":"$upstream_addr",' '"upstream_status":"$upstream_status",' '"upstream_response_time":"$upstream_response_time",' '"request_time":"$request_time",' '"http_referer":"$http_referer",' '"http_user_agent":"$http_user_agent",' '"http_x_forwarded_for":"$http_x_forwarded_for"}'; access_log /var/log/nginx/access.log access_json_log; 二

php批量检查https证书有效期

假装没事ソ 提交于 2019-12-05 03:57:23
function get_cert_info($domain){ $context = stream_context_create(['ssl' => [ 'capture_peer_cert' => true, 'capture_peer_cert_chain' => true, ], ]); $client = stream_socket_client("ssl://".$domain.":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); if($client==false) { return false; } $params = stream_context_get_params($client); $cert = $params['options']['ssl']['peer_certificate']; $cert_info = openssl_x509_parse($cert); return $cert_info; } $domain = 'www.baidu.com'; $cert_info = get_cert_info($domain); $validTo_time_t = $cert_info['validTo_time_t']; $validTo_time_d = date('Y-m-d

solrcloud启动节点结果

岁酱吖の 提交于 2019-12-05 03:56:21
0 [main] INFO org.eclipse.jetty.server.Server – jetty-8.1.10.v20130312 30 [main] INFO org.eclipse.jetty.deploy.providers.ScanningAppProvider – Deployment monitor /home/zcwangjb/programs/solr-4.8.0/solrcloud/node1/contexts at interval 0 38 [main] INFO org.eclipse.jetty.deploy.DeploymentManager – Deployable added: /home/zcwangjb/programs/solr-4.8.0/solrcloud/node1/contexts/solr-jetty-context.xml 1422 [main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor – NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet 1500 [main] INFO org.apache.solr.servlet

docker etcd

依然范特西╮ 提交于 2019-12-05 03:52:59
Etcd 简介 Etcd CoreOS 团队于 2013 年6月发起的开源项目,它的目标是构建一个高可用的分布式键值( key-value )仓库,遵循 Apache v2许可,基于 Go 语言实现,接触过分布式系统的读者应该知道,分布式系统中最基本的问题之一就是实现信息的共识,在此基础上才能实现对服务配置信息的管理、服务的发现、更新、同步,等等 而要解决这些问题,往往需要利用一套能保证一致性的分布式数据库系统,比如经典的 Apache ZooKeeper 项目 ,采用了 Paxos 算法来实现数据的强一致性。 Etcd 专门为集群环境设计,采用了更为简洁的 Raft 共识算法,Raft 是一套通过选举主节点来实现分布式系统一致性的算法,同样可以实现数据强一致性,并支持集群节点状态管理和服务自动发现等 Etcd 在进行设计的时候重点考虑了下面四个要素: 口简单:支持 RESTfulAPI和gRPCAPI; 口安全: 基于 TLS 式实 安全连接访 口快速: 支持每 一万次 并发写操作,超时控制在毫秒量级 口可靠: 支持分布式结构 基于 Raft 算法实现一致性 通常情况下,用户使用 Etcd 可以在多个节点上启动多个实例,并将它们添加为 个集群。同一个集群中的 Etcd 实例将会自动保持彼此信息的一致性,这意味着分布在各个节点上的应用也将获取到一致的信息。 安装和使用 Etcd

dubbo项目启动报错,无法加载org.apache.zookeeper.server.ZooTrace

半腔热情 提交于 2019-12-05 03:41:07
INFO: Server startup in 3425 ms 七月 11, 2017 3:06:04 下午 org.apache.catalina.loader.WebappClassLoaderBase loadClass INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.zookeeper.server.ZooTrace. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact. java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1777) at org.apache.catalina.loader

Caused by java lang ClassNotFoundException org apache comm

微笑、不失礼 提交于 2019-12-05 03:36:12
分享一下我老师大神的人工智能教程!零基础,通俗易懂! http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴! 1、错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop }2014-7-10 23:23:53 org.apache.catalina.core.AprLifecycleListener init信息: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8.2014-7-10 23:23:53 org.apache.catalina.core.AprLifecycleListener init信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].2014-7-10 23:23:53 org.apache.catalina.core.AprLifecycleListener