AWS:启动安装了APOC的Neo4j实例

安装Neo4j之后,我要做的第一件事就是安装APOC库 ,但是我发现在AWS上旋转服务器时这是一个手动过程,所以我想简化一下。

已经有一个安装Neo4j 3.2.0的Neo4j AMI,我的同事Michael指出,我们可以通过编写脚本并将其作为UserData发送来将APOC下载到正确的文件夹中。

在过去的两周中,我一直在使用JavaScript进行一些工作,因此我认为我将使用AWS库自动执行所有步骤。 您可以在GitHub上找到完整的脚本 。

脚本的UserData部分实际上非常简单:

该脚本创建一个密钥对,安全组,在端口22(SSH),7474(HTTP),7473(HTTPS)和7687(Bolt)上打开该安全组。 创建的服务器是m3.medium ,但是您可以根据需要将其更改为其他名称 。

#!/bin/bash
curl -L https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.2.0.3/apoc-3.2.0.3-all.jar -O
sudo cp apoc-3.2.0.3-all.jar /var/lib/neo4j/plugins/

我们可以这样运行它:

$ node neo4j-with-apoc.js 
Creating a Neo4j server
Key pair created. Save this to a file - you'll need to use it if you want to ssh into the Neo4j server
-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----
Created Group Id:
Opened Neo4j ports
Instance Id: 
Your Neo4j server is now ready!
You'll need to login to the server and change the default password:
https://ec2-ip-address.compute-1.amazonaws.com:7473 or http://ec2-ip-address.compute-1.amazonaws.com:7474
User:neo4j, Password:

我们需要等待几秒钟,Neo4j才能启动,但是可以通过指定的URI访问它。

一旦可以访问,我们可以使用用户名neo4j和密码登录
。 然后将指示我们选择一个新密码。

然后,我们可以运行以下查询来检查是否已安装APOC:

call dbms.procedures() YIELD name
WHERE name starts with "apoc"
RETURN count(*)
 
╒══════════╕
│"count(*)"│
╞══════════╡
│214       │
└──────────┘

太好了,它奏效了,现在我们可以让Neo4j和APOC满足我们的要求了! 如果我们想通过SSH进入服务器,我们也可以通过以下方式做到这一点:首先将命令行上打印的私钥保存到文件中,然后执行以下命令:

$ cat aws-private-key.pem
-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----
 
$ chmod 600 aws-private-key.pem
 
$ ssh -i aws-private-key.pem [email protected]
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-1013-aws x86_64)
 
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
 
  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud
 
106 packages can be updated.
1 update is a security update.
 
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

您可以通过运行以下命令来启动/停止neo4j:

$ /etc/init.d/neo4j 
Usage: /etc/init.d/neo4j {start|stop|status|restart|force-reload}

您可能会在bin文件夹中找到的其他命令可以在这里找到:

$ ls -lh /usr/share/neo4j/bin/
total 48K
-rwxr-xr-x 1 neo4j adm   15K May  9 09:22 neo4j
-rwxr-xr-x 1 neo4j adm  5.6K May  9 09:22 neo4j-admin
-rwxr-xr-x 1 root  root  612 May 12 00:03 neo4j-awspasswd
-rwxr-xr-x 1 neo4j adm  5.6K May  9 09:22 neo4j-import
-rwxr-xr-x 1 neo4j adm  5.6K May  9 09:22 neo4j-shell
drwxr-xr-x 2 neo4j adm  4.0K May 11 22:13 tools

让我知道这是否有帮助以及您是否有任何建议/改进。

翻译自: https://www.javacodegeeks.com/2017/10/aws-spinning-neo4j-instance-apoc-installed.html

你可能感兴趣的:(linux,mysql,python,ubuntu,docker)