Thursday, February 11, 2021

Neo4J Installation on CentOS

note: This was some internal documentation I wrote a couple years ago.. based on neo4j 3.5.14 for CentOS, but with some small adjustments you can perform against newer versions, and other Linux distros..



# Patch your new CentOS installation:
yum -y update
yum -y install epel-release
# I like htop
yum -y install htop

# First, you'll need the yum repository and key.
rpm --import https://debian.neo4j.org/neotechnology.gpg.key
cat <<EOF>  /etc/yum.repos.d/neo4j.repo
[neo4j]
name=Neo4j RPM Repository
baseurl=https://yum.neo4j.org/stable
enabled=1
gpgcheck=1
EOF

# View available versions/editions:
yum list neo4j

# I'm going to install the latest community edition, so here we go:
yum -y install neo4j-3.5.14-1

#verify installation
rpm -qa | grep neo

# Increase the open file limits for the neo4j service
#https://community.neo4j.com/t/warning-max-1024-open-files-allowed-minimum-of-40000-recommended-see-the-neo4j-manual/3679/7

systemctl edit neo4j.service

# Paste the following values into the file and save:

* soft nofile 40000
* hard nofile 40000


#create firewall service template for neo4j bolt, http, and https protocols (modify if you do not want to allow all 3)
cat <<EOF>> /usr/lib/firewalld/services/neo4j.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>neo4j</short>
  <description>Neo4j is an ACID-compliant graph database management system developed by Neo4j, Inc.  Neo4j supports clients using either the Bolt binary protocol or HTTP/HTTPS.</description>
    <port protocol="tcp" port="7687"/>
  <port protocol="tcp" port="7474"/>
  <port protocol="tcp" port="7473"/>
</service>
EOF

# Add our newly created service to the firewall, reload and verify
firewall-cmd --permanent --add-service=neo4j
firewall-cmd --reload
firewall-cmd --list-services

# If you have SELinux you'll need to do this as well:
semanage port -a -t http_port_t -p tcp 7474
semanage port -a -t http_port_t -p tcp 7473
semanage port -a -t http_port_t -p tcp 7687


# Change the default password
cd /usr/bin

neo4j-admin set-initial-password Password1

# Configure neo4j connector to allow network connections
# use an editor to modify /etc/neo4j/neo4j.conf
# uncomment the line dbms.connectors.default_listen_address=0.0.0.0 if you want to accept non-local network connections

#You should adjust your memory settings.  For recommendations see
# https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin-memrec/

# Add any plugins.  I can't live without APOC, so here we go:
cd /var/lib/neo4j/plugins

wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.6/apoc-3.5.0.6-all.jar

# and because I am connecting with SQL Server, I will need the SQL JDBC 7.x jar
cd /tmp
wget https://download.microsoft.com/download/2/F/C/2FC75210-EDDE-464C-8E54-45C0291032FF/sqljdbc_7.0.0.0_enu.tar.gz

tar -xzf sqljdbc_7.0.0.0_enu.tar.gz
cp /tmp/sqljdbc_7.0/enu/mssql-jdbc-7.0.0.jre8.jar /var/lib/neo4j/plugins/

# I also want Advantage (SAP Sybase) JDBC:
cd /tmp
wget http://devzone.advantagedatabase.com/dz/download.aspx?Key=iE/9IfXlCOePTGOfVrmGwsL+4iRlo8+R -O adsinstall.jar
unzip adsinstall.jar -d /tmp/ads
cp /tmp/ads/jdbc/adsjdbc.jar  /var/lib/neo4j/plugins/

# Configure neo4j service to start automatically
systemctl enable neo4j
systemctl start neo4j