Linux安装neo4j
Posted Circle-C
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux安装neo4j相关的知识,希望对你有一定的参考价值。
Linux/UNIX Install (tar)
- Open up your terminal/shell.
- Extract the contents of the archive, using:
tar -xf
<filecode>.
For example,tar -xf neo4j-community-4.4.11-unix.tar.gz
- 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.
- To run Neo4j as a console application, use:
- Visit http://localhost:7474 in your web browser.
- Connect using the username 'neo4j' with default password 'neo4j'. You'll then be prompted to change the password.
cd /usr/local/
wget https://dist.neo4j.org/neo4j-community-4.4.11-unix.tar.gz
tar -xf neo4j-community-4.4.11-unix.tar.gz
neo4j需要java环境,否则启动会报错:
Error: JAVA_HOME is not defined correctly.
We cannot execute
[root@iZwz97bu0gr8vw0924itpzZ neo4j-community-4.4.11]# cd bin/
[root@iZwz97bu0gr8vw0924itpzZ bin]# ll
total 92
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 2213 Aug 29 15:30 cypher-shell
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 37704 Aug 29 15:30 LICENSES.txt
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 36006 Aug 29 15:30 LICENSE.txt
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 3554 Aug 29 15:49 neo4j
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 3565 Aug 29 15:49 neo4j-admin
-rwxr-xr-x 1 libstoragemgmt systemd-coredump 1959 Aug 29 15:30 NOTICE.txt
drwxr-xr-x 2 libstoragemgmt systemd-coredump 30 Aug 29 16:33 tools
[root@iZwz97bu0gr8vw0924itpzZ bin]# neo4j console
bash: neo4j: command not found
[root@iZwz97bu0gr8vw0924itpzZ bin]# ./neo4j console
which: no java in (/home/admin/.local/bin:/home/admin/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
Error: JAVA_HOME is not defined correctly.
We cannot execute
需要java11版本
[root@iZwz97bu0gr8vw0924itpzZ bin]# ./neo4j console
Error: A JNI error has occurred, please check your installation and try again
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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
Java SE 版本和主要版本之间的映射:
Java SE | Major version |
---|---|
1.0.2 | 45 |
1.1 | 45 |
1.2 | 46 |
1.3 | 47 |
1.4 | 48 |
5.0 | 49 |
6 | 50 |
7 | 51 |
8 | 52 |
9 | 53 |
10 | 54 |
11 | 55 |
12 | 56 |
13 | 57 |
14 | 58 |
15 | 59 |
16 | 60 |
表格取自: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文件末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_333
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
使环境变量生效
source /etc/profile
2.完成安装后验证
java -version
配置并启用neo4j
配置
在安装目录下找到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
启动
进入bin目录执行
后台启动:./neo4j start
前台启动:./neo4j console
查看状态:./neo4j status
停止:./neo4j stop
重启:./neo4j restart
客户端访问
http://服务器ip地址:7474/browser/
以上是关于Linux安装neo4j的主要内容,如果未能解决你的问题,请参考以下文章