本地环境执行如下命令:
docker pull couchbase/centos7-systemd
docker run -it couchbase/centos7-systemd bash
# 可能需要换源
yum update -y
sed -i "s/#\?keepcache=0/keepcache=1/g" /etc/yum.conf # 缓存安装包
rpm --import https://debian.neo4j.com/neotechnology.gpg.key
cat <<EOF> /etc/yum.repos.d/neo4j.repo
[neo4j]
name=Neo4j RPM Repository
baseurl=https://yum.neo4j.com/stable
enabled=1
gpgcheck=1
EOF
yum install -y neo4j
mkdir rpms
cp /var/cache/yum/x86_64/7/*/packages/*.rpm rpms/
tar -cJf rpms.tar.xz rpms
新开一个命令行窗口,执行如下命令:
docker cp <container-id>:/root/rpms.tar.xz .
scp rpms.tar.xz root@<server-host>:~/
登陆服务器后,执行如下命令:
tar xf rpms.tar.xz
cd rpms
python3 -c '
from pathlib import Path
fs=list(Path().rglob("*.rpm"))
import os
sudo="" if Path.home().name=="root" else "sudo "
cmd=sudo+"rpm -ivh "
install_all = lambda:sum(os.system(cmd+str(i))==0 for i in fs)
total=len(fs)
for _ in range(total):
success=install_all()
if success==total:
break
'
neo4j status
neo4j --version
systemctl enable neo4j # 设为开机自启动
cypher-shell # 进入控制台,修改默认密码
期间遇到了java版本不配置的问题,我装的是neo4j 4.4.25,它要求java 11
但系统之前安装了java 17,导致neo4j start失败,解决:
java -version
# 17
which java
# /usr/bin/java
ll `which java`
# /usr/bin/java -> /etc/alternatives/java
rm -f /etc/alternatives/java
ln -s /usr/lib/jvm/java-11/bin/java /etc/alternatives/java
java -version
# 11
javac -version
# 17
which javac
# /usr/bin/javac
ll `which javac`
# /usr/bin/javac -> /etc/alternatives/javac
rm -f /etc/alternatives/javac
ln -s /usr/lib/jvm/java-11/bin/javac /etc/alternatives/javac
javac -version
# 11
不确认是否还需要配置JAVA_HOME和CLASSPATH环境变量,总之全整完后,neo4j start就可以成功启动了