2016-09-07 59 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