ONgDB项目是neo4j企业版的一个开源分支。另外ONgDB的发起组织也在快速更新。目前最新是3.6.0版本,与企业版neo4j-3.6.0版本功能基本一致。目前企业版neo4j已经更新到4.0版本,最大的特点是支持分库操作,ONgDB还不支持分库操作。
群号码:1061594137
一、安装虚拟机
使用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
相关插件包与配置文件的下载