2016-09-07 62 views
0

我在AWS上使用集群上的neo4j-enterprise-3.0.4,螺栓协议。我使用HAproxy来了解谁是主节点,谁是HA集群中的从节点。Neo4j HA with Haproxy(Neo.ClientError.Transaction.TransactionNotFound)

这是我HAProxy的的设置haproxy.cfg

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    chroot /var/lib/haproxy 
    stats socket /run/haproxy/admin.sock mode 660 level admin 
    stats timeout 30s 
    user haproxy 
    group haproxy 
    daemon 
    maxconn 256 
defaults 
    log global 
    mode tcp 
    option tcplog 
    option dontlognull 
    timeout connect 30s 
    timeout client 2h 
    timeout server 2h 
frontend http-in 
    bind *:81 
    acl write_method method POST DELETE PUT 
    acl write_hdr hdr_val(X-Write) eq 1 
    acl write_payload payload(0,0) -m reg -i CREATE|MERGE|SET|DELETE|REMOVE 
    acl tx_cypher_endpoint path_beg /db/data/transaction 
    http-request set-var(txn.tx_cypher_endpoint) bool(true) if tx_cypher_endpoint 
    use_backend neo4j-master if write_hdr 
    use_backend neo4j-master if tx_cypher_endpoint write_payload 
    use_backend neo4j-all if tx_cypher_endpoint 
    use_backend neo4j-master if write_method 
    default_backend neo4j-all 
backend neo4j-all 
    option httpchk GET /db/manage/server/ha/available HTTP/1.0\r\nAuthorization:\ Basic\ [code] 
    acl tx_cypher_endpoint var(txn.tx_cypher_endpoint),bool 
    stick-table type integer size 1k expire 70s # slightly higher with org.neo4j.server.transaction.timeout 
    stick match path,word(4,/) if tx_cypher_endpoint 
    stick store-response hdr(Location),word(6,/) if tx_cypher_endpoint 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
backend neo4j-master 
    option httpchk GET /db/manage/server/ha/master HTTP/1.0\r\nAuthorization:\ Basic\ [code] 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
listen admin 
    bind *:82 
    mode http 
    stats enable 
    stats uri /haproxy?stats 
    stats realm Haproxy\ Statistics 
    stats auth admin:admin 

有时我得到这个,当我想在浏览器

"errors": [ 
    { 
     "code": "Neo.ClientError.Transaction.TransactionNotFound", 
     "message": "Unrecognized transaction id. Transaction may have timed out and been rolled back." 
    } 
    ] 

而且我这个HAProxy的配置试图用暗号,但我仍然有一个同样的问题。这是我第二HAProxy的haproxy.cfg

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    chroot /var/lib/haproxy 
    stats socket /run/haproxy/admin.sock mode 660 level admin 
    stats timeout 30s 
    user haproxy 
    group haproxy 
    daemon 
    maxconn 256 
defaults 
    log global 
    mode tcp 
    option tcplog 
    option dontlognull 
    timeout connect 30s 
    timeout client 2h 
    timeout server 2h 
frontend http-in 
    bind *:81 
    acl write_method method POST DELETE PUT 
    acl write_hdr hdr_val(X-Write) eq 1 
    acl write_payload payload(0,0) -m reg -i CREATE|MERGE|SET|DELETE|REMOVE 
    acl tx_cypher_endpoint path_beg /db/data/transaction 
    http-request set-var(txn.tx_cypher_endpoint) bool(true) if tx_cypher_endpoint 
    use_backend neo4j-master if write_hdr 
    use_backend neo4j-master if tx_cypher_endpoint write_payload 
    use_backend neo4j-all if tx_cypher_endpoint 
    use_backend neo4j-master if write_method 
    default_backend neo4j-all 
backend neo4j-all 
    option httpchk GET /db/manage/server/ha/master HTTP/1.0\r\nAuthorization:\ Basic\ [code] 
    acl tx_cypher_endpoint var(txn.tx_cypher_endpoint),bool 
    stick-table type integer size 1k expire 70s # slightly higher with org.neo4j.server.transaction.timeout 
    stick match path,word(4,/) if tx_cypher_endpoint 
    stick store-response hdr(Location),word(6,/) if tx_cypher_endpoint 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
backend neo4j-master 
    option httpchk GET /db/manage/server/ha/slave HTTP/1.0\r\nAuthorization:\ Basic\ [code] 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
listen admin 
    bind *:82 
    mode http 
    stats enable 
    stats uri /haproxy?stats 
    stats realm Haproxy\ Statistics 
    stats auth admin:admin 

的设置,所以我不知道为什么会这样。这是因为HAproxyAWS螺栓。当我在http上切换协议时,一切正常,我没有错误。

后端的Neo4j浏览器模式HTTP选项喜欢,最后服务器

+0

您可能想突出显示两种配置之间的差异。 –

+0

@Frank Pavageau在第一个配置中,我使用后端neo4j-all 选项httpchk GET/db/manage/server/ha/available',然后在第二个我使用'backend neo4j-all 选项httpchk GET/db /服务器/公顷/ master'的 – NKD

回答

0

我加入到HAProxy的.CFG这个参数解决这个问题。现在HAproxy正在像charme一样工作,我不再有错误了。

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    chroot /var/lib/haproxy 
    stats socket /run/haproxy/admin.sock mode 660 level admin 
    stats timeout 30s 
    user haproxy 
    group haproxy 
    daemon 
    maxconn 256 
defaults 
    log global 
    mode tcp 
    option tcplog 
    option dontlognull 
    timeout connect 30s 
    timeout client 2h 
    timeout server 2h 
frontend http-in 
    bind *:81 
    acl write_method method POST DELETE PUT 
    acl write_hdr hdr_val(X-Write) eq 1 
    acl write_payload payload(0,0) -m reg -i CREATE|MERGE|SET|DELETE|REMOVE 
    acl tx_cypher_endpoint path_beg /db/data/transaction 
    http-request set-var(txn.tx_cypher_endpoint) bool(true) if tx_cypher_endpoint 
    use_backend neo4j-master if write_hdr 
    use_backend neo4j-master if tx_cypher_endpoint write_payload 
    use_backend neo4j-all if tx_cypher_endpoint 
    use_backend neo4j-master if write_method 
    default_backend neo4j-all 
frontend http-browse 
    bind *:83 
    mode http 
    default_backend neo4j-browser 
backend neo4j-all 
    option httpchk GET /db/manage/server/ha/available HTTP/1.0\r\nAuthorization:\ Basic\[code] 
    acl tx_cypher_endpoint var(txn.tx_cypher_endpoint),bool 
    stick-table type integer size 1k expire 70s # slightly higher with org.neo4j.server.transaction.timeout 
    stick match path,word(4,/) if tx_cypher_endpoint 
    stick store-response hdr(Location),word(6,/) if tx_cypher_endpoint 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
backend neo4j-master 
    option httpchk GET /db/manage/server/ha/master HTTP/1.0\r\nAuthorization:\ Basic\[code] 
    server neo4j-1 192.0.0.250:7687 check port 7474 
    server neo4j-2 192.0.0.251:7687 check port 7474 
    server neo4j-3 192.0.0.252:7687 check port 7474 
backend neo4j-browser 
    mode http 
    option prefer-last-server 
    option httpchk GET /db/manage/server/ha/master HTTP/1.0\r\nAuthorization:\ Basic\ [code] 
    server neo4j-1 192.0.0.250:7474 check 
    server neo4j-2 192.0.0.251:7474 check 
    server neo4j-3 192.0.0.252::7474 check 
listen admin 
    bind *:82 
    mode http 
    stats enable 
    stats uri /haproxy?stats 
    stats realm Haproxy\ Statistics 
    stats auth admin:admin