ONgDB集羣測試

ONgDB項目是neo4j企業版的一個開源分支。另外ONgDB的發起組織也在快速更新。目前最新是3.6.0版本,與企業版neo4j-3.6.0版本功能基本一致。目前企業版neo4j已經更新到4.0版本,最大的特點是支持分庫操作,ONgDB還不支持分庫操作。

一、安裝虛擬機

使用VMware虛擬機安裝CentOS7,搭建三個節點的集羣。
在這裏插入圖片描述
CentOS7是服務器常用的常用的操作系統,一般安裝好系統之後JDK8默認就安裝了。三臺機器用戶名均爲ongdb,密碼123456。虛擬機裝好之後繼續操作。
1、配置hosts

vim /etc/hosts
# 新增如下內容
192.168.91.128  node-1
192.168.91.129  node-2
192.168.91.130  node-3

2、配置可打開文件數

vim /etc/security/limits.conf
# 新增如下內容
neo4j soft nofile 40000
neo4j hard nofile 40000

二、關閉防火牆

# 查看防火牆狀態
systemctl status firewalld.service
# 關閉防火牆
systemctl disable firewalld.service

三、配置互信

1、修改SSH配置文件

vim /etc/ssh/sshd_config 
# 找到下列行 去掉註釋井號#
 RSAAuthentication yes //字面意思..允許RSA認證
 PubkeyAuthentication yes //允許公鑰認證
 AuthorizedKeysFile .ssh/authorized_keys //公鑰存放在.ssh/au..文件中
# 保存退出。
# 修改後需要重啓ssh
systemctl restart sshd      
# 分別在host1,host2和host3上執行上述命令。

2、生成密碼對

ssh-keygen -t rsa     
# 直接回車幾次,可在默認路徑~/.ssh/下生成私鑰idrsa公鑰idrsa.pub。
# 分別在host1,host2和host3上執行上述命令

3、 生成authorized_keys

# 將host2、host3的公鑰傳到host1上。
# 在host2上輸入
scp /home/ongdb/.ssh/id_rsa.pub ongdb@host1:~/.ssh/id_rsa.pub.host2

# 在host3上輸入
scp /home/ongdb/.ssh/id_rsa.pub ongdb@host1:~/.ssh/id_rsa.pub.host3

# 以上命令目前還需要輸入目標機用戶密碼。
# 在host1上輸入
cd ~/.ssh/  
ls  

# 查看idrsa.pub.host2、idrsa.pub.host3是否已經傳輸過來。
$ cat id_rsa.pub >> authorized_keys
$ cat id_rsa.pub.host2 >> authorized_keys 
$ cat id_rsa.pub.host3 >> authorized_keys     

# 生成authorized_keys。
# 給authorized_keys修改權限
chmod 644 authorized_keys 

# 利用scp把該文件傳送到host2、host3的.ssh/下
scp authorized_keys hadoop@host2:~/.ssh/
scp authorized_keys hadoop@host3:~/.ssh/

4、 驗證

# 測試在host1下輸入
$ssh host2   
$exit
$ssh host3   
$exit  
# 應該都不需要密碼。 這三個互聯都應該不需要密碼。

四、節點修改密碼

節點在啓動之後必須要先進shell修改密碼,首次進入默認的用戶密碼都是neo4j。

[ongdb@node-1 ongdb-node-1]$ bin/cypher-shell 
username: neo4j
password: *****
Connected to Neo4j 3.5.16 at bolt://localhost:7687 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j> CALL dbms.changePassword('123456');
0 rows available after 320 ms, consumed after another 2 ms
neo4j> 

五、配置兩個CORE節點

ongdb-node-1配置

#*****************************************************************
# Network connector configuration
#*****************************************************************

dbms.connectors.default_listen_address=0.0.0.0
dbms.connectors.default_advertised_address=node-1

# Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687

# HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=:7473

#*****************************************************************
# Causal Clustering Configuration
#*****************************************************************
dbms.mode=CORE

causal_clustering.minimum_core_cluster_size_at_formation=2
causal_clustering.minimum_core_cluster_size_at_runtime=2
causal_clustering.initial_discovery_members=node-1:5000,node-2:5001
causal_clustering.discovery_listen_address=:5000

# Remote debugging
dbms.jvm.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

# algo|apoc|* plugins
dbms.security.procedures.unrestricted=algo.*,apoc.*,*
apoc.export.file.enabled=true
apoc.import.file.enabled=true

#********************************************************************
# Prometheus monitor
#********************************************************************
# Enable the Prometheus endpoint. Default is 'false'.
metrics.prometheus.enabled=true
# The default is localhost:2004.
metrics.prometheus.endpoint=localhost:2004

ongdb-node-2配置

#*****************************************************************
# Network connector configuration
#*****************************************************************

dbms.connectors.default_listen_address=0.0.0.0
dbms.connectors.default_advertised_address=node-2

# Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687

# HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=:7473

#*****************************************************************
# Causal Clustering Configuration
#*****************************************************************
dbms.mode=CORE

causal_clustering.minimum_core_cluster_size_at_formation=2
causal_clustering.minimum_core_cluster_size_at_runtime=2
causal_clustering.initial_discovery_members=node-1:5000,node-2:5001
causal_clustering.discovery_listen_address=:5000

# Remote debugging
dbms.jvm.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

# algo|apoc|* plugins
dbms.security.procedures.unrestricted=algo.*,apoc.*,*
apoc.export.file.enabled=true
apoc.import.file.enabled=true

#********************************************************************
# Prometheus monitor
#********************************************************************
# Enable the Prometheus endpoint. Default is 'false'.
metrics.prometheus.enabled=true
# The default is localhost:2004.
metrics.prometheus.endpoint=localhost:2004

六、增加一個只讀READ_REPLICA節點

ongdb-node-3配置

#*****************************************************************
# Network connector configuration
#*****************************************************************

dbms.connectors.default_listen_address=0.0.0.0
dbms.connectors.default_advertised_address=node-3

# Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687

# HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=:7473

#*****************************************************************
# Causal Clustering Configuration
#*****************************************************************
dbms.mode=READ_REPLICA

causal_clustering.minimum_core_cluster_size_at_formation=2
causal_clustering.minimum_core_cluster_size_at_runtime=2
causal_clustering.initial_discovery_members=node-1:5000,node-2:5001,node-3:5002
causal_clustering.discovery_listen_address=:5002

# Remote debugging
dbms.jvm.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

# algo|apoc|* plugins
dbms.security.procedures.unrestricted=algo.*,apoc.*,*
apoc.export.file.enabled=true
apoc.import.file.enabled=true

#********************************************************************
# Prometheus monitor
#********************************************************************
# Enable the Prometheus endpoint. Default is 'false'.
metrics.prometheus.enabled=true
# The default is localhost:2004.
metrics.prometheus.endpoint=localhost:2004

七、檢驗apoc和algo插件

CALL algo.list()
CALL apoc.config.list()

八、查看集羣成員角色

CALL dbms.cluster.overview()
CALL dbms.cluster.role()

在這裏插入圖片描述
kill掉節點2,之後再看一下:
在這裏插入圖片描述

九、更多信息

apoc與Neo4j的版本對應關係及下載
algo與Neo4j的版本對應關係及下載
自定義插件包
ONgDB下載 - 本次測試使用的版本3.5.16
相關插件包與配置文件的下載

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章