当前位置:   article > 正文

Linux安装neo4j_linux neo4j安装

linux neo4j安装

Linux/UNIX Install (tar)

  

  1. Open up your terminal/shell.
  2. Extract the contents of the archive, using:
    tar -xf <filecode>.
    For example,
    tar -xf neo4j-community-4.4.11-unix.tar.gz
  3. Place the extracted files in a permanent home on your server. The top level directory is referred to as NEO4J_HOME.
    • To run Neo4j as a console application, use:
      <NEO4J_HOME>/bin/neo4j console
    • To run Neo4j in a background process, use:
      <NEO4J_HOME>/bin/neo4j start
    • For additional commands see the Unix tarball installation documentation.
  4. Visit http://localhost:7474 in your web browser.
  5. Connect using the username 'neo4j' with default password 'neo4j'. You'll then be prompted to change the password.
  1. cd /usr/local/
  2. wget https://dist.neo4j.org/neo4j-community-4.4.11-unix.tar.gz
  3. tar -xf neo4j-community-4.4.11-unix.tar.gz

neo4j需要java环境,否则启动会报错:

Error: JAVA_HOME is not defined correctly.
  We cannot execute 

  1. [root@iZwz97bu0gr8vw0924itpzZ neo4j-community-4.4.11]# cd bin/
  2. [root@iZwz97bu0gr8vw0924itpzZ bin]# ll
  3. total 92
  4. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 2213 Aug 29 15:30 cypher-shell
  5. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 37704 Aug 29 15:30 LICENSES.txt
  6. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 36006 Aug 29 15:30 LICENSE.txt
  7. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 3554 Aug 29 15:49 neo4j
  8. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 3565 Aug 29 15:49 neo4j-admin
  9. -rwxr-xr-x 1 libstoragemgmt systemd-coredump 1959 Aug 29 15:30 NOTICE.txt
  10. drwxr-xr-x 2 libstoragemgmt systemd-coredump 30 Aug 29 16:33 tools
  11. [root@iZwz97bu0gr8vw0924itpzZ bin]# neo4j console
  12. bash: neo4j: command not found
  13. [root@iZwz97bu0gr8vw0924itpzZ bin]# ./neo4j console
  14. which: no java in (/home/admin/.local/bin:/home/admin/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
  15. Error: JAVA_HOME is not defined correctly.
  16. We cannot execute

 需要java11版本

  1. [root@iZwz97bu0gr8vw0924itpzZ bin]# ./neo4j console
  2. Error: A JNI error has occurred, please check your installation and try again
  3. Exception in thread "main" java.lang.UnsupportedClassVersionError: org/neo4j/server/startup/Neo4jCommand has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
  4. at java.lang.ClassLoader.defineClass1(Native Method)
  5. at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
  6. at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  7. at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
  8. at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  9. at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  10. at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  11. at java.security.AccessController.doPrivileged(Native Method)
  12. at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  13. at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
  14. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
  15. at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
  16. at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

 Java SE 版本和主要版本之间的映射:

Java SEMajor version
1.0.245
1.145
1.246
1.347
1.448
5.049
650
751
852
953
1054
1155
1256
1357
1458
1559
1660

表格取自:https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html

安装java环境

1. 下载jdk11

https://www.oracle.com/java/technologies/downloads/#java11

 2. 创建java目录

mkdir /usr/local/java/

 3. 使用FTP工具(filezilla等),拷贝到/usr/local/java

tar -zxvf jdk-11.0.16.1_linux-x64_bin.tar.gz -C /usr/local/java/

 4. 配置环境变量

vi /etc/profile

在/etc/profile文件末尾添加 

  1. export JAVA_HOME=/usr/local/java/jdk1.8.0_333
  2. export JRE_HOME=${JAVA_HOME}/jre
  3. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  4. export PATH=${JAVA_HOME}/bin:$PATH

使环境变量生效

source /etc/profile

2.完成安装后验证

java -version

配置并启用neo4j

配置

在安装目录下找到conf目录下的neo4j.conf文件

修改相应配置如下:

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

启动 

  1. 进入bin目录执行
  2. 后台启动:./neo4j start
  3. 前台启动:./neo4j console
  4. 查看状态:./neo4j status
  5. 停止:./neo4j stop
  6. 重启:./neo4j restart

客户端访问

http://服务器ip地址:7474/browser/

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/425116
推荐阅读
相关标签
  

闽ICP备14008679号