neo4j安装及内存分配

        Neo4j是一个高性能的,NOSQL图形数据库,它将结构化数据存储在网络上而不是表中,国内下载地址:ftp://neo4j.55555.io/neo4j/3.5.7/

1.安装jdk

jdk安装在root用户下

(1)检查自带jdk并卸载,检查命令如下:

rpm -qa|grep gcj 
rpm -qa|grep jdk 

(2)卸载jdk命令如下

rpm -e –nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

(3)解压jdk并配置环境变量

#解压安装包
tar -zxvf jdk-8u191-linux-x64.tar.gz
#配置环境变量
vi /etc/profile
#在文件内添加一下内容
export JAVA_HOME=/opt/jdk1.8.0_65
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

(4)刷新配置文件并检查Java版本

#刷新配置文件
source /etc/profile
#检查Java版本
java -version

2.安装neo4j

(1)解压neo4l

tar -zxvf  neo4j-community-3.5.7-unix.tar.gz

(2)修改配置文件,除54行需要放开,其他可根据需求自由修改

 vi neo4j-community-3.5.7/conf/neo4j.conf 

# 修改第22行load csv时l路径,在前面加个#,可从任意路径读取文件
#dbms.directories.import=import
# 修改35行和36行,设置JVM初始堆内存和JVM最大堆内存
# 生产环境给的JVM最大堆内存越大越好,但是要小于机器的物理内存
dbms.memory.heap.initial_size=5g
dbms.memory.heap.max_size=10g
# 修改46行,可以认为这个是缓存,如果机器配置高,这个越大越好
dbms.memory.pagecache.size=10g
# 修改54行,去掉改行的#,可以远程通过ip访问neo4j数据库
dbms.connectors.default_listen_address=0.0.0.0
# 默认 bolt端口是7687,http端口是7474,https关口是7473,不修改下面3项也可以
# 修改71行,去掉#,设置http端口为7687,端口可以自定义,只要不和其他端口冲突就行
#dbms.connector.bolt.listen_address=:7687
# 修改75行,去掉#,设置http端口为7474,端口可以自定义,只要不和其他端口冲突就行
dbms.connector.http.listen_address=:7474
# 修改79行,去掉#,设置http端口为7473,端口可以自定义,只要不和其他端口冲突就行
dbms.connector.https.listen_address=:7473
# 修改227行,去掉#,允许从远程url来load csv
dbms.security.allow_csv_import_from_file_urls=true
# 修改246行,允许使用neo4j-shell,类似于mysql 命令行之类的
dbms.shell.enabled=true
# 修改235行,去掉#,设置连接neo4j-shell的端口,一般都是localhost或者127.0.0.1,这样安全,其他地址的话,一般使用https就行
dbms.shell.host=127.0.0.1
# 修改250行,去掉#,设置neo4j-shell端口,端口可以自定义,只要不和其他端口冲突就行
dbms.shell.port=1337
# 修改254行,设置neo4j可读可写
dbms.read_only=false

(3)启动neo4j

./neo4j-community-3.5.7/bin/neo4j start 

 (4) 登录验证,访问地址:http://10.169.169.32:7474/browser/,默认用户:neo4j  默认密码:neo4j

3.neo4j内存分配方案优化

    若安装的服务器只应用于neo4j数据库,官方提供了一个最佳方案配置运行以下命令:

./neo4j-admin memrec --database=graph.db

   运行的内容为:

WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
# Memory settings recommendation from neo4j-admin memrec:
#
# Assuming the system is dedicated to running Neo4j and has 15600m of memory,
# we recommend a heap size of around 5000m, and a page cache of around 6600m,
# and that about 4000m is left for the operating system, and the native memory
# needed by Lucene and Netty.
#
# Tip: If the indexing storage use is high, e.g. there are many indexes or most
# data indexed, then it might advantageous to leave more memory for the
# operating system.
#
# Tip: The more concurrent transactions your workload has and the more updates
# they do, the more heap memory you will need. However, don't allocate more
# than 31g of heap, since this will disable pointer compression, also known as
# "compressed oops", in the JVM and make less effective use of the heap.
#
# Tip: Setting the initial and the max heap size to the same value means the
# JVM will never need to change the heap size. Changing the heap size otherwise
# involves a full GC, which is desirable to avoid.
#
# Based on the above, the following memory settings are recommended:
dbms.memory.heap.initial_size=5000m
dbms.memory.heap.max_size=5000m
dbms.memory.pagecache.size=6600m
#
# The numbers below have been derived based on your current data volume in database and index configuration of database 'graph.db'.
# They can be used as an input into more detailed memory analysis.
# Lucene indexes: 0k
# Data volume and native indexes: 123700k

若改服务器只安装neo4j,配置文件直接修改为如下,然后重启:

# 生产环境给的JVM最大堆内存越大越好,但是要小于机器的物理内存
dbms.memory.heap.initial_size=5000m
dbms.memory.heap.max_size=5000m
# 修改46行,可以认为这个是缓存,如果机器配置高,这个越大越好
dbms.memory.pagecache.size=6600m

注:若服务器还需安装其他应用 ,需要排除掉应用的内存需要,还需要给neo4j的索引等留有内存,配置按比例减小。

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值