LoginSignup
8
3

More than 5 years have passed since last update.

Neo4jをCentOSにインストールする

Posted at

はじめに

最近仕事でよくグラフデータベースの話が出てくる。RDBはともかくのことMongoやElasticsearchくらいしか触ってなくて「グラフデータベースってなんだろ」と思い触ってみることにしました。インストール自体は簡単でしたがメモしておきます。

環境

CentOS7 (Vagrant)
Neo4j 3.4.1 (当時)

手順

手順は以下です

前準備

JDKを入れておきます.とりあえずあれば動くとのことっぽいので適当に入れておきます

yum install java-1.8.0-openjdk

Neo4j のインストール

メディアを落としていれるのが定番ぽかったですが今回はyum を使って入れます。
ここらへんを参考にしました
 How to List and Install Neo4j Versions using yum
レファレンスはここを参照

# Key の取得
cd /tmp
wget http://debian.neo4j.org/neotechnology.gpg.key
rpm --import neotechnology.gpg.key

# リポジトリ追加
cat <<EOF>  /etc/yum.repos.d/neo4j.repo
[neo4j]
name=Neo4j Yum Repo
baseurl=http://yum.neo4j.org/stable
enabled=1
gpgcheck=1
EOF

# インストール
yum install neo4j

無事に入ったらバージョンを確認しておきます

[vagrant@neo ~]$ neo4j --version
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
neo4j 3.4.1

Neo4j の設定

ここの設定で少しはまった

limits.conf の編集

一度起動させてみる
bash:
sudo neo4j start

すると下記のようなエラーが出る

WARNING: Max 1024 open files allowed, minimum of 40 000 recommended. See the Neo4j manual.

開けるファイル数のリミットを増やせてきな警告が出るので設定を編集

/etc/security/limits.conf
neo4j   soft    nofile  40000
neo4j   hard    nofile  40000
root    soft    nofile  40000
root    hard    nofile  40000

起動の方法の変更

もう一度、さっきの neo4j start でエラーっぽいのが出る

[vagrant@neo bin]$ sudo neo4j start
Active database: graph.db
Directories in use:
  home:         /var/lib/neo4j
  config:       /etc/neo4j
  logs:         /var/log/neo4j
  plugins:      /var/lib/neo4j/plugins
  import:       /var/lib/neo4j/import
  data:         /var/lib/neo4j/data
  certificates: /var/lib/neo4j/certificates
  run:          /var/run/neo4j
Starting Neo4j.
/usr/share/neo4j/bin/neo4j: line 418: /var/run/neo4j/neo4j.pid: No such file or directory

また調べてみると、neo4j コマンドからではなくservce か systemctl で立ち上げろ、とのこと
参考 : Neo4j Start Error

リモートアクセスの許可

ここが一番ハマった。本来であればここまでやって http://localhost:7474 でコンソールでつながるのだが、リモート接続する場合はNeo4jの設定を変更するようです

ということで設定ファイルであるneo4j.confファイルの設定を変更します

/etc/neo4j/neo4j.conf
## 1か所め
# HTTP Connector. There must be exactly one HTTP connector.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=XXX.XXX.XXX.XXX:7474 ##サーバーのIP

## 2か所め
# Bolt connector
dbms.connector.bolt.listen_address=0.0.0.0:7687

参考 公式

Neo4jの再起動

ここで起動している場合は再起動します。もちろんservice やsystemctl からやります

接続確認

ここでもう一度 http://{IP Adress}:7474 でアクセスします

image.png

やった!!!これでコンソールに繋がりました

おわりに

やっとこれから触ることができます。もうちょっと日本語のドキュメントが増えてるとおもったのにあんまりなくて残念です。

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3