版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/programmer_at/article/details/69483529
动机
采用REST来远程访问neo4j的数据库
同时在本地浏览器查看数据是否添加正确(neo4j的可视化界面x.x.x.x:7474/browser)
即,通过HTTP协议来与neo4j进行交互
环境配置
Linux 版本
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.3.1611 (Core)
Release: 7.3.1611
Codename: Core
neo4j版本
neo4j-community-3.0.7
修改neo4j.conf
修改$NEO4_HOME/con/neo4j.conf,注意:
- 第8,9行:bolt连接
- 第14,15行:http连接
- 第21,22行:https连接
至于选择哪一种连接方式,取决于开发使用哪一种访问数据库的方式。
0 #*****************************************************************
1 # Network connector configuration
2 #*****************************************************************
3
4 # Bolt connector
5 dbms.connector.bolt.type=BOLT
6 dbms.connector.bolt.enabled=true
7 dbms.connector.bolt.tls_level=OPTIONAL
8 # To have Bolt accept non-local connections, uncomment this line
9 # dbms.connector.bolt.address=0.0.0.0:7687
10
11 # HTTP Connector
12 dbms.connector.http.type=HTTP
13 dbms.connector.http.enabled=true
14 # To accept non-local HTTP connections, uncomment this line
15 # dbms.connector.http.address=0.0.0.0:7474
16
17 # HTTPS Connector
18 dbms.connector.https.type=HTTP
19 dbms.connector.https.enabled=true
20 dbms.connector.https.encryption=TLS
21 # To accept non-local HTTPS connection, change 'localhost' to '0.0.0.0'
22 dbms.connector.https.address=localhost:7473
23
24 # Number of Neo4j worker threads.
25 #dbms.threads.worker_count=
26
27 #*****************************************************************
28 # Logging configuration
29 #*****************************************************************
在 开头的“动机”就讲的很明白,使用HTTP协议,所以将15行的注释去掉。
firewall
开放防火墙相应的端口
firewall-cmd --zone=public --permanent --add-port=7474/tcp
firewall-cmd --reload #一定不要忘记这句话
firewall-cmd --list-ports # 查看端口是否打开成功
Testing
在你的浏览器中地址栏输入:http://<服务器ip地址>:7474/browser/
即可看到