Centos 7.5 源码包安装neo4j图形数据库

Neo4j 图形数据库的硬件和软件需求:
      Minimum        Recommended
CPU    Intel Core i3  Intel Core i7/IBM POWER8
Memory 2GB            16—32GB or more
Disk   10GB SATA      SSD w/ SATA
Filesystem ext4       ext4, ZFS

Java:
  OpenJDK 8
  Oracle Java 8
  IBM Java 8
OS:
  Ubuntu 14.04, 16.04; Debian 8, 9; CentOS 6, 7; Fedora, Red Hat, Amazon Linux
  Windows Server 2012, 2016
Architectures:
  x86/OpenPOWER (POWER8) 
Neo4j的下载:
#wget  https://neo4j.com/artifact.php?name=neo4j-community-3.4.9-unix.tar.gz
#mv artifact.php\?name\=neo4j-community-3.4.9-unix.tar.gz neo4j-community-3.4.9-unix.tar.gz 
 
#下载JDK:
# wget http://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1c8617c5452694857ad95c3ee230/jdk-8u192-linux-x64.rpm?AuthParam=1540259927_da64181999184a9f87623081e6db372e
# mv jdk-8u192-linux-x64.rpm\?AuthParam\=1540259927_da64181999184a9f87623081e6db372e  jdk-8u192-linux-x64.rpm

JDK的安装:
安装(直接使用rpm的JDK安装即可 或者使用tar.gz 解压安装)
#rpm -ivh jdk-8u192-linux-x64.rpm
 验证:
#java -version  
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


Neo4j的目录规划:
 neo4j的程序目录:/usr/local/neo4j
 neo4j的数据目录:/data/neo4j/data
 neo4j的日志目录:/data/neo4j/logs

# tar -xzvf neo4j-community-3.4.9-unix.tar.gz -C /usr/local/
# mv /usr/local/neo4j-community-3.4.9/ /usr/local/neo4j
设置环境变量:
echo > /etc/profile.d/neo4j.sh <<EOF
export NEO4J_HOME=/usr/local/neo4j
export PATH=$PATH:$NEO4J_HOME/bin
EOF
source /etc/profile.d/neo4j.sh
--环境变量的验证:
# neo4j
neo4j         neo4j-admin   neo4j-import  neo4j-shell   
#版本查询
# neo4j version
neo4j 3.4.9

Neo4j的内存配置:
可以使用工具进行评估的:假设主机的物理内存为32G,数据存储为graph.db
# neo4j-admin memrec --memory=32G --database=graph.db
# Memory settings recommendation from neo4j-admin memrec:
#
# Assuming the system is dedicated to running Neo4j and has 32G of memory,
# we recommend a heap size of around 12g, and a page cache of around 12g,
# and that about 8g 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=12g
dbms.memory.heap.max_size=12g
dbms.memory.pagecache.size=12g
#
# 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: 0.0
# Data volume and native indexes: 73728.0
--创建目录:
#mkdir -p /data/neo4j/{data,logs}

neo4j的参数配置:
# cat /usr/local/neo4j/conf/neo4j.conf | grep -v ^#|uniq

dbms.directories.data=/data/neo4j/data
dbms.directories.logs=/data/neo4j/logs

dbms.directories.import=import

dbms.memory.heap.initial_size=4096m
dbms.memory.heap.max_size=4096m

dbms.memory.pagecache.size=10g

dbms.connectors.default_listen_address=0.0.0.0

dbms.connector.bolt.enabled=true

dbms.connector.http.enabled=true

dbms.connector.https.enabled=true

dbms.threads.worker_count=6

dbms.logs.http.enabled=true

dbms.logs.http.rotation.keep_number=5

dbms.logs.http.rotation.size=20m
dbms.logs.gc.enabled=true

dbms.logs.gc.options=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution

dbms.logs.gc.rotation.keep_number=5

dbms.logs.gc.rotation.size=20m

dbms.logs.debug.rotation.size=20m

dbms.logs.debug.rotation.keep_number=5

dbms.tx_log.rotation.retention_policy=1 days

dbms.shell.enabled=true
dbms.shell.host=0.0.0.0
dbms.shell.port=1337

dbms.jvm.additional=-XX:+UseG1GC

dbms.jvm.additional=-XX:-OmitStackTraceInFastThrow

dbms.jvm.additional=-XX:+AlwaysPreTouch

dbms.jvm.additional=-XX:+UnlockExperimentalVMOptions
dbms.jvm.additional=-XX:+TrustFinalNonStaticFields

dbms.jvm.additional=-XX:+DisableExplicitGC

dbms.jvm.additional=-Djdk.tls.ephemeralDHKeySize=2048

dbms.jvm.additional=-Djdk.tls.rejectClientInitiatedRenegotiation=true

dbms.windows_service_name=neo4j

dbms.jvm.additional=-Dunsupported.dbms.udc.source=tarball
dbms.jvm.additional=-Duser.timezone=utc+08


dbms.security.auth_enabled=true

dbms.logs.query.enabled=true
dbms.logs.query.threshold=1
dbms.logs.query.rotation.keep_number=7
dbms.logs.query.rotation.size=20m
dbms.logs.query.parameter_logging_enabled=true
dbms.logs.query.time_logging_enabled=true
dbms.logs.query.allocation_logging_enabled=true
dbms.logs.query.page_logging_enabled=true
dbms.transaction.timeout=10s

dbms.index.default_schema_provider=lucene+native-2.0

dbms.connector.bolt.thread_pool_min_size=10
dbms.connector.bolt.thread_pool_max_size=100
dbms.connector.bolt.thread_pool_keep_alive=10m
dbms.index_sampling.background_enabled=true
dbms.index_sampling.update_percentage=5
cypher.statistics_divergence_threshold=0.75
注意:
重点关注的参数:
1.开启远程登录访问:
dbms.connectors.default_listen_address=0.0.0.0
2.指定neo4j的数据目录和日志目录,事务日志轮训的周期(默认为1天)
dbms.directories.data=/data/neo4j/data
dbms.directories.logs=/data/neo4j/logs
dbms.tx_log.rotation.retention_policy=1 days
3.指定neo4j的中的JVM内存:初始内存和最大内存一样,具体视主机内存配置 主机内存的50%。
dbms.memory.heap.initial_size=4096m
dbms.memory.heap.max_size=4096m
4.设置内存:
用于映射存储文件的内存量,以字节为单位(可用单位为k,m或g).如果服务器上只使用neo4j数据库,则通常建议留2-G内存给操作系统使用,留给JVM足够的内存来保存所有事务的状态和查询上下文,剩下的用于页面缓存(page cache)
    neo4j默认假定为专用服务器,此值为物理RAM的50%减去最大的Java堆大小。
假设主机内存为32G,即为16G-dbms.memory.heap.max_size的值。
也可以手动指定。
5.neo4j的并发线程: 默认为1,设置为主机CPU核心数的50%即可,视具体情况而定。
dbms.threads.worker_count=6
其他参数按照默认的即可。
6.neo4j默认会收集服务器的信息,需要关闭:
dbms.udc.enabled=false

--neo4j数据库的启动:
--启动关闭:
Usage: neo4j { console | start | stop | restart | status | version }

--启动:
# /usr/local/neo4j/bin/neo4j start
# /usr/local/neo4j/bin/neo4j start
Active database: graph.db
Directories in use:
  home:         /usr/local/neo4j
  config:       /usr/local/neo4j/conf
  logs:         /data/neo4j/logs
  plugins:      /usr/local/neo4j/plugins
  import:       /usr/local/neo4j/import
  data:         /data/neo4j/data
  certificates: /usr/local/neo4j/certificates
  run:          /usr/local/neo4j/run
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
Started neo4j (pid 28391). It is available at http://0.0.0.0:7474/
There may be a short delay until the server is ready.
See /data/neo4j/logs/neo4j.log for current status.

启动的日志信息查看:/data/neo4j/logs/neo4j.log
# cat /data/neo4j/logs/neo4j.log

--neo4j的登录:
1.登录方式之neo4j-shell(标记为废弃):
# neo4j-shell -host 10.19.75.102 -port 1337 -name shell
Welcome to the Neo4j Shell! Enter 'help' for a list of commands. Please note that neo4j-shell is deprecated and to be replaced by cypher-shell.
NOTE: Remote Neo4j graph database service 'shell' at port 1337

neo4j-sh (?)$ help
Available commands: alias begin call cd commit create cypher dbinfo drop dump env explain export foreach gsh help index jsh load ls man match merge mknode mkrel mv optional paths planner profile pwd return rm rmnode rmrel rollback runtime schema set start trav unwind using with
Use man <command> for info about each command.
Please note that neo4j-shell is deprecated and to be replaced by cypher-shell.
neo4j-sh (?)$ dbinfo
USAGE: dbinfo -(g|l) <bean name> [list of attribute names].
--退出:
neo4j-sh (?)$ exit
--
2.登录方式之cypher-shell(推荐)
# cypher-shell  --address 10.19.75.102 --username neo4j --password password
Connected to Neo4j 3.4.9 at bolt://10.19.75.102: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> 
neo4j> :help

Available commands:
  :begin    Open a transaction
  :commit   Commit the currently open transaction
  :exit     Exit the logger
  :help     Show this help message
  :history  Print a list of the last commands executed
  :param    Set the value of a query parameter
  :params   Prints all currently set query parameters and their values
  :rollback Rollback the currently open transaction

For help on a specific command type:
    :help command


For help on cypher please visit:
    https://neo4j.com/docs/developer-manual/current/cypher/
--退出:
neo4j>:exit
3.登录方式之浏览器:
http://10.19.75.102:7474/browser/	
连接方式:
Connect to Neo4j
Database access requires an authenticated connection.
Connect URL  bolt://10.19.75.102:7687
Username     neo4j
Password  

4.登录方式之neo4j-client:
第三方开源的客户端工具:https://github.com/cleishm/libneo4j-client/releases
帮助信息参考:https://github.com/cleishm/libneo4j-client
不过在Ubuntu上可以直接安装,在CentOS版本则需要到https://build.opensuse.org/package/binaries/home:cleishm/libcypher-parser/RHEL_7
https://build.opensuse.org/package/binaries/home:cleishm/libneo4j-client/CentOS_7
下载x86上的RPM包。
完成之后:
# neo4j-client -u neo4j localhost
The authenticity of host 'localhost:7687' could not be established.
TLS certificate fingerprint is c3fd315daa16489a6c5f0c69293f08cc2567a180914c907dc544e93fb295b38bd46e87cd14168304c8fb52c6a35be31ca5e9a722c9542fb1bae39d257ad0f3f9.
Would you like to trust this host (NO/yes/once)? yes
Password: 
neo4j-client 2.2.0
Enter `:help` for usage hints.
Connected to 'neo4j://neo4j@localhost:7687' [Neo4j/3.4.9]
neo4j>


--初始化的密码:
初始化neo4j的密码:
neo4j默认提供的用户名和密码为neo4j/neo4j.
若初始化密码需要在neo4j没有启动的时候:执行如下命令:
/usr/local/neo4j/bin/neo4j-admin set-initial-password <password>
实例:
# /usr/local/neo4j/bin/neo4j-admin set-initial-password password
Changed password for user 'neo4j'.
若启动之后初始化密码需要删除/data/neo4j/data/dbms/auth文件
#/usr/local/neo4j/bin/neo4j stop
# rm -rf /data/neo4j/data/dbms/auth 
# /usr/local/neo4j/bin/neo4j-admin set-initial-password password
Changed password for user 'neo4j'.

--neo4j的目录和常用端口:
目录:         配置参数                          读写执行权限
Configuration  /usr/local/neo4j/conf/neo4j.conf  R
Data          dbms.directories.data              RW
logs          dbms.directories.logs              RW
Metrics       dbms.directories.metrics           RW
Import        dbms.directories.import            R
Bin           /usr/local/neo4j/bin               X
Lib           dbms.directories.lib               R
Plugins       dbms.directories.plugins           R
日志:
neo4j.log neo4j运行的标准输出日志
debug.log  debug的时候产生的日志信息
http.log  http API的请求日志信息
gc.log   JVM的Garbage Collection日志信息
query.log  慢查询日志信息(仅限企业版)
security.log 安全信息日志(仅限企业版)

默认的端口:
项目名称    端口号      参数名 
backups     6362-6372  dbms.backup.enabled=true ,127.0.0.1:6362-6372
HTTP        7474       dbms.connector.https.listen_address=:7474
HTTPS       7473       dbms.connector.http.listen_address=:7473
Bolt        7687       dbms.connector.bolt.listen_address=:7687
Neo4j-shell 1337       dbms.shell.port=1337
Graphite    2003       metrics.graphite.server=:2003
Prometheus  2004       metrics.prometheus.enabled=false,metrics.prometheus.endpoint=localhost:2004
JMX         3637       dbms.jvm.additional=-Dcom.sun.management.jmxremote.port=3637

Causal Cluster 5000, 6000, 7000  causal_clustering.discovery_listen_address=127.0.0.1:5000,causal_clustering.transaction_listen_address=127.0.0.1:6000,causal_clustering.raft_listen_address=127.0.0.1:7000
HA Cluster    5001, 6001  ha.host.coordination=0.0.0.0:5001-5099,ha.host.data=0.0.0.0:6001-6011



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值