小编Fat*_*ana的帖子

使用Elasticsearch进行Logstash

我正在尝试将Logstash与Elasticsearch连接,但无法使其正常工作.

这是我的logstash conf:

input {
  stdin {
    type => "stdin-type"
  }

  file {
    type => "syslog-ng"

    # Wildcards work, here :)
    path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
  }
}

output {
  stdout { }
  elasticsearch{
        type => "all"
        embedded => false
        host => "192.168.0.23"
        port => "9300"
        cluster => "logstash-cluster"
        node_name => "logstash"
        }
}
Run Code Online (Sandbox Code Playgroud)

我只是在elasticsearch.yml中更改了这些细节

cluster.name: logstash-cluster
node.name: "logstash"
node.master: false
network.bind_host: 192.168.0.23
network.publish_host: 192.168.0.23
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["localhost"]
Run Code Online (Sandbox Code Playgroud)

使用这些配置,我无法使Logstash连接到ES.有人可以建议我哪里出错吗?

elasticsearch logstash

14
推荐指数
2
解决办法
7万
查看次数

Python:cmd在提示符和空行时执行最后一个命令

这个问题可能不够明确.

让我详细说明一下.我正在使用python cmd库来实现我自己的CLI框架,当按下enter按钮而不键入任何命令时,它会执行最后一个命令.这不是我想做的.

mycli~: cmd --args
executes command
execution stops
mycli~:[hit enter button]
Run Code Online (Sandbox Code Playgroud)

然后它将再次执行cmd --args.但是我只是想换新线.

python cmd command-line-interface

12
推荐指数
2
解决办法
2120
查看次数

无法在Firefox上建立Websocket安全连接

我被Firefox搞砸了.我无法使Websocket工作.我使用Tornado Websocket并通过以下代码初始化它:

app = Application([(r'/mypath/ws', WSHandler)])
http_server = HTTPServer(app, ssl_options={
                "certfile": "~/certs/websocket.crt",
                "keyfile": "~/certs/websocket.key"
            })
http_server.listen("443")
Run Code Online (Sandbox Code Playgroud)

我在Javascript端初始化它像这样:

var WS = new WebSocket("wss://websocket.localhost/mypath/ws");
Run Code Online (Sandbox Code Playgroud)

此代码在Chrome上运行正常,同时我自己创建了证书并在HTTPS下运行该页面.但Firefox一直这样说:

Firefox can't establish a connection to the server at wss://websocket.localhost/mypath/ws.
Run Code Online (Sandbox Code Playgroud)

我谷歌它,发现太多的想法,但没有'''为我工作:(

任何帮助将不胜感激.

javascript python firefox tornado websocket

10
推荐指数
3
解决办法
2万
查看次数

Psycopg2 单引号异常

我在我的应用程序中使用 psycopg2。一切都很好,但是:当我插入包含单引号'的数据时,python 会抛出以下异常:

<class 'psycopg2.ProgrammingError'>: syntax error at or near "s"
Run Code Online (Sandbox Code Playgroud)

内容是这样的“儿童页面”

我找不到解决此问题的解决方案。我使用 python 字符串文字,例如:

"""INSERT INTO table (field_name) VALUES ('%s');"""
Run Code Online (Sandbox Code Playgroud)

我捕获异常并返回查询。我从 posgtre shell 运行这个查询,它工作正常。psycopg2 有什么问题吗?

python sql psycopg2

6
推荐指数
2
解决办法
1万
查看次数

Elasticsearch:如何找到未分配的分片并分配它们?

我的低源硬件配置机器上有 1 个节点、1 个分片、1 个副本架构。我必须将 Elasticsearch 堆大小保持在总内存的 20%,并且我将1k~1m文档索引到 Elasticsearch,以了解硬件配置。我有不同类型的机器,从2GB 到 16GB,但由于它们是32 位架构,我只能使用300m1.5GB 的最大内存作为堆大小。

由于某些原因,我不知道为什么,Elasticsearch 使用未分配的分片创建了一些索引,并使集群健康状况变为红色。我尝试在不创建新节点的情况下恢复和分配分片并将数据传输到其中,因为我不应该这样做。我还尝试使用此配置使用此命令重新路由索引:

curl -XPUT 'localhost:9200/_settings' -d '{
  "index.routing.allocation.disable_allocation": false
}'
Run Code Online (Sandbox Code Playgroud)

这是我的节点信息:

{
  name: mynode
  transport_address: inet[/192.168.1.4:9300]
  host: myhost
  ip: 127.0.0.1
  version: 1.0.0
  build: a46900e
  http_address: inet[/192.168.1.4:9200]
  thrift_address: /192.168.1.4:9500
  attributes: {
    master: true
  }
  settings: {
    threadpool: {
      search: {
        type: fixed
        size: 600
        queue_size: 10000
      }
      bulk: {
        type: fixed
        queue_size: 10000
        size: 600
      }
      index: { …
Run Code Online (Sandbox Code Playgroud)

python elasticsearch

5
推荐指数
1
解决办法
2343
查看次数

Subparsers.add_parser TypeError: __init__() 有一个意外的关键字参数“prog”

我需要实现一个 ArgParse 构建器来生成解析器并考虑子解析器和参数。我创建了一个装饰器来将子解析器声明为操作。这是包含装饰器的类:

class Controller(object):
    endpoints = None
    parser = None
    subparsers = None

    def __init__(self, endpoint=None):
        from src.app.commons.ArgParser import ArgParser
        if not self.parser:
            self.parser = ArgParser()
        # Get all 
        self.endpoints = utilities.conf_wrapper()
        self.mod = endpoint
        if not self.subparsers:
            self.subparsers = self.parser.add_subparsers(help=gettext('%s_SUBPARSER_HELP' % str(self.mod).upper()))
        self.parser.add_argument_group(self.mod, gettext('%s_GROUP_DESC' % str(self.mod).upper()))


    def endpoint(self, endpoint, **kwargs):
        """ Create an endpoint to define a method on behalf of subparser"""
        ref = self
        def decorator(f):
            """
            Create subparser for controller object
            @param f as a function …
Run Code Online (Sandbox Code Playgroud)

python argparse python-decorators

5
推荐指数
2
解决办法
2147
查看次数

MapperParsingException:没有在字段上声明的类型[date_hour_minute_second]的处理程序

我正在为Elasticsearch开发一个带Python Pyes客户端的驱动程序.我需要具有日期列的映射索引具有基于文档的格式No"date_hour_minute_second" http://www.elasticsearch.org/guide/reference/mapping/date-format/我还检查了pyes docs https://pyes.readthedocs.组织/ EN /最新/引导/参考/制图/日期format.html

当我在我的字段中使用"date_hour_minute_second"格式时,我得到了标题中提到的异常.

这是我的字段定义:

      "date": {
           "boost": 1.0,
           "store": "yes",
           "type": "date_hour_minute_second_fraction",
           "term_vector": "with_positions_offsets"
       }
Run Code Online (Sandbox Code Playgroud)

我无法弄明白为什么它会抛出一个例外,即使是文档说它是受支持的.

python elasticsearch pyes

3
推荐指数
1
解决办法
5788
查看次数

Glassfish:链接安全策略时出错

重启或重新部署应用程序到Glassfish时出错,我得到以下异常:

com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while loading the app : org.glassfish.deployment.common.DeploymentException: Error in linking security policy for appname -- Inconsistent Module State
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个问题?

glassfish

2
推荐指数
1
解决办法
4546
查看次数

Python将包含列表的dict对象转换为包含dict的列表

我想这个标题可能会让你有点困惑,但我确信有太多人面对这个问题而且他们中的大多数人可能知道如何解决它.

这是我的问题,我有一个像下面的字典对象:

{   'fields':
    ['Config', 'Device', 'Device Name', 'Config Name', 'description', 'ip', 'radius', 'ssid','vlan', 'channel', 'frequency', 'maxclients', 'username', 'password', 'enable_password','transport_protocol', 'personality', 'date_added', 'date_modified'],
    'results': [
    [23, 45, 'New test2 for demo', 'New test2 for demo', 'Default desc for device','192.168.0.100',13, '0', 0, 4, 'None', None, 'Cisco', 'Cisco', 'Cisco', 'Telnet', 'ios',datetime.datetime(2013, 3, 6, 13, 52, 14), datetime.datetime(2013, 3, 7, 14, 27, 39)],
    [23, 47, 'Test after a couple hours', 'New test2 for demo', 'Default desc for device','192.168.0.100', 13, '0', 0, 4, 'None', …
Run Code Online (Sandbox Code Playgroud)

python mapping dictionary list

1
推荐指数
1
解决办法
220
查看次数

new()的单个参数必须是HASH ref数据

我有一个perl脚本,它适用于perl版本5.8.8,但5.14得到了这个错误:匿名哈希中的元素奇数

这是我的代码:

$session->begin_privileged({ $_enable_password })
Run Code Online (Sandbox Code Playgroud)

以前它是这样的:

$session->begin_privileged( $_enable_password )
Run Code Online (Sandbox Code Playgroud)

而此时我收到此错误:

Single parameters to new() must be a HASH ref data
Run Code Online (Sandbox Code Playgroud)

我有类似上面的类型行,我得到相同的单个参数错误.

我用Google搜索,但找不到常规解决方案.

perl

1
推荐指数
1
解决办法
943
查看次数