Neo4j và haproxy: Một số thủ thuật và phương pháp hay nhất

mục tiêu của bài đăng trên blog đó là cung cấp cấu hình haproxy hợp lý phù hợp với hầu hết các cụm neo4j. nó bao gồm các nhu cầu cụ thể của neo4j (xác thực, độ dính, định tuyến yêu cầu) phù hợp cho việc triển khai thông thường.
một số từ để giới thiệu
khi chạy một cụm neo4j, bạn thường muốn đặt nó bằng một bộ cân bằng tải. bản thân bộ cân bằng tải không phải là một phần của neo4j vì rất nhiều khách hàng đã có bộ cân bằng tải phần cứng trong cơ sở hạ tầng của họ. trong trường hợp họ không có hoặc muốn một số giải pháp dễ thực hiện mà công cụ được đề xuất là haproxy .
trong một cụm neo4j hoàn toàn có thể chạy bất kỳ hoạt động nào (đọc và ghi) trên bất kỳ thành viên cụm nào. tuy nhiên về hiệu suất, bạn nên gửi yêu cầu ghi trực tiếp đến master và gửi yêu cầu chỉ đọc cho tất cả thành viên cluster hoặc chỉ cho các nô lệ - tùy thuộc vào mức độ bận rộn của master.
những gì chúng ta cần che
ngày nay hầu hết mọi người tương tác với neo4j bằng cách gửi các lệnh cypher thông qua điểm cuối cypher giao dịch . điểm cuối này luôn sử dụng một bài đăng http bất kể lệnh cypher có nhằm thực hiện thao tác đọc hoặc ghi hay không. điều này gây ra một số khó khăn cho việc cân bằng tải vì chúng ta cần phân biệt đọc và ghi.
một cách tiếp cận cho việc này là sử dụng tiêu đề htttp tùy chỉnh bổ sung ở phía máy khách. giả sử bất kỳ yêu cầu nào cần thực hiện ghi đều nhận được một x-write:1
tiêu đề trong yêu cầu. thì haproxy chỉ cần kiểm tra tiêu đề này trong và acl và liên kết acl này với phần phụ trợ chỉ chứa cá thể chính.
một ý tưởng khác là trình cân bằng tải kiểm tra tải trọng của yêu cầu (hay còn gọi là lệnh cypher bạn đang gửi). nếu trọng tải đó chứa các mệnh đề ghi như tạo, hợp nhất, đặt, xóa, loại bỏ hoặc cắt bỏ thì rất có thể đó là một thao tác ghi được chuyển hướng đến chính. may mắn thay, haproxy có capbilites để kiểm tra tải trọng và áp dụng các trận đấu regex.
cách tiếp cận thứ ba sẽ là gói gọn từng trường hợp sử dụng của bạn thành một tiện ích mở rộng không được quản lý và sử dụng cypher, traversal api hoặc core api bên trong làm chi tiết triển khai. bằng cách sử dụng ngữ nghĩa của phần còn lại một cách thích hợp mà bạn sử dụng để đọc, đặt, đăng và xóa để viết. chúng cũng có thể được sử dụng trong acl của haproxy rất dễ dàng.
một vấn đề khác mà chúng tôi phải giải quyết khi thiết lập bộ cân bằng tải là xác thực. kể từ neo4j 2.2, cơ sở dữ liệu được bảo vệ theo mặc định bằng tên người dùng và mật khẩu. tất nhiên chúng ta có thể tắt tính năng đó đi, nhưng nếu vấn đề bảo mật là vấn đề cần quan tâm thì bạn nên bật tính năng này. kết hợp với haproxy, chúng ta cần lưu ý rằng haproxy cũng cần sử dụng xác thực để kiểm tra trạng thái của nó để xác định ai có sẵn và ai là chủ.
đề xuất thiết lập
tôi đã dành một chút thời gian để tìm ra một cấu hình haproxy giải quyết tất cả các điểm được đề cập ở trên. chúng ta hãy xem xét từng phần có liên quan bên dưới - phần còn lại, tôi ủy thác cho tài liệu tuyệt vời cho haproxy . xin lưu ý rằng cấu hình này yêu cầu phiên bản haproxy gần đây:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
chi tiết vinh quang
xác định danh sách kiểm soát truy cập:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
các điều kiện khai báo acl sẽ được sử dụng sau này. chúng tôi cần xác định xem có yêu cầu đến không:
- có http phương thức đăng, đặt hoặc xóa (l.16)
- có một tiêu đề yêu cầu cụ thể
x-write:1
- chứa một trong những từ kỳ diệu trong tải trọng để xác định một bài viết: tạo, hợp nhất, xóa, loại bỏ, đặt
- được nhắm mục tiêu vào điểm cuối cypher giao dịch
lưu trữ một biến chỉ ra điểm cuối tx:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
chúng tôi thực hiện một thủ thuật khó chịu ở đây: chúng tôi lưu trữ một biến bên trong chứa một boolean tùy thuộc vào mức độ ướt mà yêu cầu dành cho điểm cuối tx. sau này chúng tôi tham chiếu trở lại biến đó. lý do là haproxy không thể truy cập acls trong các phần khác của tệp cấu hình.
quyết định phần phụ trợ sẽ được sử dụng (hay còn gọi là chúng tôi đọc hay viết):
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
các acls được định nghĩa ở trên quyết định yêu cầu nên được hướng đến phần phụ trợ nào. chúng tôi có một điểm cuối cho chủ của cụm neo4j và một điểm cuối khác cho nhóm tất cả các cá thể neo4j có sẵn (chủ và nô lệ). một yêu cầu được gửi đến chủ nếu:
- các
x-write:1
tiêu đề được thiết lập, hoặc - yêu cầu chạm vào điểm cuối tx cypher và nó chứa một trong những từ kỳ diệu.
- nó là một bài đăng, đặt hoặc xóa.
kiểm tra trạng thái của các phiên bản neo4j, cuối cùng bằng xác thực:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
một chương trình phụ trợ cần kiểm tra xem thành viên nào của nó có sẵn. do đó neo4j có một điểm cuối còn lại thể hiện trạng thái của cá thể. trong trường hợp chúng tôi sử dụng xác thực neo4j, các yêu cầu tới điểm cuối trạng thái cần được xác thực. nhờ stackoverflow, tôi đã phát hiện ra rằng bạn có thể thêm a authorization
vào các yêu cầu này. như thường lệ, giá trị cho tiêu đề xác thực là một chuỗi được mã hóa base64 của “<tên người dùng>: <mật khẩu>”. trên một dòng lệnh unix sử dụng:
echo "neo4j:123"| base64
trong trường hợp bạn đã tắt xác thực trong neo4j, hãy sử dụng các dòng nhận xét để thay thế.
độ dính cho điểm cuối tx:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
bằng cách sử dụng biến được lưu trữ trước đó của chúng tôi, chúng tôi lấy lại giá trị và sử dụng nó để khai báo một acl trong phần phụ trợ này. để đảm bảo mọi yêu cầu cho cùng một số giao dịch được gửi đến cùng một phiên bản neo4j, chúng tôi tạo một bảng dính để lưu trữ id giao dịch. bạn có thể muốn áp dụng kích thước của bảng đó (ở đây là 1k) theo nhu cầu của mình, cũng như thời gian hết hạn phải phù hợp với cài đặt org.neo4j.server.transaction.timeout của neo4j. nó mặc định là 60s, vì vậy nếu chúng tôi hết hạn mục nhập bảng dính sau 70s thì chúng tôi đang ở bên an toàn. nếu một phản hồi http từ điểm cuối tx có location
tiêu đề chúng tôi lưu trữ từ thứ 6 của nó - đó là số giao dịch - trong bảng dính. nếu chúng tôi đạt điểm cuối tx, chúng tôi sẽ kiểm tra xem từ thứ 4 của đường dẫn yêu cầu (id giao dịch) có được tìm thấy trong bảng dính hay không. nếu vậy, yêu cầu sẽ được gửi lại đến cùng một máy chủ, nếu không, chúng tôi sử dụng chính sách mặc định (round-robin).
xác định các trường hợp cụm neo4j:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
những dòng này chứa một danh sách tất cả các trường hợp cụm. đảm bảo căn chỉnh giá trị maxconn với số lượng max_server_threads. theo mặc định neo4j sử dụng 10 luồng cho mỗi lõi cpu. vì vậy 32 là một giá trị tốt cho một hộp 4 lõi.
Giao diện thống kê của haproxy:
global
daemon
maxconn 256
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8090
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\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/available
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 s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
backend neo4j-master
option httpchk get /db/manage/server/ha/master http/1.0\r\nauthorization:\ basic\ bmvvngo6mtiz
#option httpchk get /db/manage/server/ha/master
server s1 127.0.0.1:7474 maxconn 32 check
server s2 127.0.0.1:7475 maxconn 32 check
server s3 127.0.0.1:7476 maxconn 32 check
listen admin
bind *:8080
stats enable
stats realm haproxy\ statistics
stats auth admin:123
haproxy cung cấp một bảng điều khiển trạng thái đẹp. trong hầu hết các trường hợp, bạn muốn bảo vệ điều đó bằng mật khẩu.
phần kết luận
tôi hy vọng bài đăng này có thể cung cấp cho bạn một số thông tin chi tiết về cách sử dụng haproxy trước một cụm neo4j một cách hiệu quả. tất nhiên tôi biết rằng kinh nghiệm và kiến thức của tôi về haproxy còn hạn chế. vì vậy tôi đánh giá cao mọi phản hồi để cải thiện cấu hình được mô tả ở đây.
Có thể bạn quan tâm
