Figure introduction and installation of Neo4j database

Neo4j is the leader of today's market graph database. It has enterprise level functions such as scalability and high availability. It is the best choice to meet our needs.


What kind of problems does graph database solve?

Why Neo4j?


Relational databases can't handle relationships well


NoSQL database does not process relationships




Neo4j is a graphics database based on Java. To run neo4j, you need to start the JVM process, so you must install JDK of JAVA SE.


#Step 1: install jdk

wget -c http://download.cashalo.com/schema/auto_jdk.sh
source auto_jdk.sh

#Step 2: execute the following automatic installation script

#!/bin/bash
#neo4j installation
#1) set hosts binding
IP=`ifconfig|sed -n 2p|awk '{print $2}'|cut -d ":" -f2`
echo "$IP neo4j" >>/etc/hosts
#2) download and install neo4j
cd /home/tools
wget -c https://neo4j.com/artifact.php?name=neo4j-community-3.4.14-unix.tar.gz
tar zxvf artifact.php\?name\=neo4j-community-3.4.14-unix.tar.gz -C /usr/local/
ln -s /usr/local/neo4j-community-3.4.14 /usr/local/neo4j-community
#3) configure environment variables
cat >/etc/profile.d/neo4j <<EOF
export NEO4J_HOME=/usr/local/neo4j
export PATH=\$PATH:\$NEO4J_HOME/bin
EOF
source /etc/profile.d/neo4j
#4) configure resources
sed -i 's/#dbms.memory.heap.initial_size=512m/dbms.memory.heap.initial_size=2048m/g' /usr/local/neo4j-community/conf/neo4j.conf
sed -i 's/#dbms.memory.heap.max_size=512m/dbms.memory.heap.max_size=2048m/g' /usr/local/neo4j-community/conf/neo4j.conf
sed -i 's/#dbms.connectors.default_listen_address=0.0.0.0/dbms.connectors.default_listen_address=neo4j/g' /usr/local/neo4j-community/conf/neo4j.conf
#5) configure neo4j startup script
cat >/etc/init.d/neo4j <<EOF
#!/bin/bash
### BEGIN REDHAT INFO
# chkconfig: 2345 99 20
# description: Neo4j Graph Database server
SCRIPTNAME=\$0
NEO4J_CONF=/usr/local/neo4j-community/conf
NEO4J_HOME=/usr/local/neo4j-community
NEO_USER=root
NEO4J_ULIMIT_NOFILE=60000
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=neo4j
DAEMON=\${NEO4J_HOME}/bin/\${NAME}
PIDDIR=\${NEO4J_HOME}/run
PIDFILE=\${PIDDIR}/neo4j.pid
SCRIPTNAME=/etc/init.d/\${NAME}
SYSTEMCTL_SKIP_REDIRECT=1
[ -x "\$DAEMON" ] || exit 0
#[ -r \${NEO4J_CONF}/\${NAME}.conf ] && . \${NEO4J_CONF}/\${NAME}.conf
[ -n "\${NEO_USER}" ] || NEO_USER=\${NAME}
# Debian distros and SUSE
has_lsb_init()
{
  test -f "/lib/lsb/init-functions"
}
# RedHat/Centos distros
has_init()
{
  test -f "/etc/init.d/functions"
}
if has_lsb_init ; then
  . /lib/lsb/init-functions
elif has_init ; then
  . /etc/init.d/functions
else
  echo "Error: your platform is not supported by \${NAME}" >&2
  exit 1
fi
do_start()
{
  do_ulimit
  [ -d "\${PIDDIR}" ] || mkdir -p "\${PIDDIR}"
  chown "\${NEO_USER}:" "\${PIDDIR}"
  if has_lsb_init ; then
    start-stop-daemon --chuid \${NEO_USER} --start --quiet --oknodo --pidfile \${PIDFILE} --exec \${DAEMON} -- start
  else
    daemon --user="\${NEO_USER}" --pidfile="\${PIDFILE}" "\${DAEMON} start > /dev/null 2>&1 &"
  fi
}
do_stop()
{
  \${DAEMON} stop
}
do_status()
{
  if has_lsb_init ; then
    status_of_proc -p "\${PIDFILE}" "\${DAEMON}" "\${NAME}"
  else
    status -p "\${PIDFILE}" "\${NAME}"
  fi
}
do_ulimit()
{
  if [ -n "\${NEO4J_ULIMIT_NOFILE}" ]; then
    ulimit -n "\${NEO4J_ULIMIT_NOFILE}"
  fi
}
case "\$1" in
  start)
    do_start
    ;;
  stop)                                                          
    do_stop
    ;;
  status)
    do_status
    ;;
  restart|force-reload)
    do_stop && do_start
    ;;
  *)
    echo "Usage: \$SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac
EOF
#6) set permissions
chmod +x /etc/init.d/neo4j
#7) start neo4j
service neo4j start
#8) configure power on self start
chkconfig neo4j on






Tags: Database Java JDK PHP

Posted on Fri, 01 Nov 2019 03:26:01 -0700 by youqing