You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.4 KiB

6 years ago
6 years ago
  1. # Install some tools
  2. yum -y install net-tools wget htop iftop sysstat tcpdump vim git tar unzip psmisc
  3. # Additional packages
  4. yum -y install net-snmp-utils net-snmp
  5. yum -y install bind-utils mailx
  6. # Install OpenNMS repository
  7. rpm -Uvh http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm
  8. rpm --import http://yum.opennms.org/OPENNMS-GPG-KEY
  9. # Install OpenNMS without any setup
  10. yum -y install rrdtool
  11. yum -y install opennms
  12. yum -y install jrrd2
  13. yum clean all
  14. # Set Java
  15. /opt/opennms/bin/runjava -s
  16. # Initialize PostgreSQL database
  17. postgresql-setup initdb
  18. # Set authentication from ident to md5
  19. sed -i 's/all 127\.0\.0\.1\/32 ident/all 127.0.0.1\/32 md5/g' /var/lib/pgsql/data/pg_hba.conf
  20. sed -i 's/all ::1\/128 ident/all ::1\/128 md5/g' /var/lib/pgsql/data/pg_hba.conf
  21. # Enable and start PostgreSQL with systemd
  22. systemctl start postgresql
  23. systemctl enable postgresql
  24. # Create opennms user with password and database
  25. sudo -u postgres psql -c "CREATE USER opennms WITH PASSWORD 'opennms';"
  26. sudo -u postgres psql -c "CREATE DATABASE opennms;"
  27. sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE opennms to opennms;"
  28. # Create OpenNMS database configuration
  29. printf '<?xml version="1.0" encoding="UTF-8"?>
  30. <datasource-configuration>
  31. <connection-pool factory="org.opennms.core.db.C3P0ConnectionFactory"
  32. idleTimeout="600"
  33. loginTimeout="3"
  34. minPool="50"
  35. maxPool="50"
  36. maxSize="50" />
  37. <jdbc-data-source name="opennms"
  38. database-name="opennms"
  39. class-name="org.postgresql.Driver"
  40. url="jdbc:postgresql://localhost:5432/opennms"
  41. user-name="%s"
  42. password="%s" />
  43. <jdbc-data-source name="opennms-admin"
  44. database-name="template1"
  45. class-name="org.postgresql.Driver"
  46. url="jdbc:postgresql://localhost:5432/template1"
  47. user-name="%s"
  48. password="%s" />
  49. </datasource-configuration>' opennms opennms opennms opennms \
  50. > /opt/opennms/etc/opennms-datasources.xml
  51. # Initialize OpenNMS database schema
  52. /opt/opennms/bin/install -dis
  53. echo "org.opennms.rrd.storeByForeignSource=true" >> /opt/opennms/etc/opennms.properties
  54. # Configure OpenNMS to use RRDtool
  55. echo "org.opennms.rrd.strategyClass=org.opennms.netmgt.rrd.rrdtool.MultithreadedJniRrdStrategy" >> /opt/opennms/etc/rrd-configuration.properties
  56. echo "org.opennms.rrd.interfaceJar=/usr/share/java/jrrd2.jar" >> /opt/opennms/etc/rrd-configuration.properties
  57. echo "opennms.library.jrrd2=/usr/lib64/libjrrd2.so" >> /opt/opennms/etc/rrd-configuration.properties
  58. # Enable and start OpenNMS with systemd
  59. systemctl start opennms
  60. systemctl enable opennms
  61. firewall-cmd --zone=public --permanent --add-port=8980/tcp
  62. cat <<EOF > /etc/issue
  63. ____ _ _ __ __ _____
  64. / __ \ | \ | | \/ |/ ____|
  65. | | | |_ __ ___ _ __ | \| | \ / | (___
  66. | | | | '_ \ / _ \ '_ \| . ` | |\/| |\___ \
  67. | |__| | |_) | __/ | | | |\ | | | |____) |
  68. \____/| .__/ \___|_| |_|_| \_|_| |_|_____/
  69. | |
  70. |_|
  71. ***** Host *****
  72. IP address: \4
  73. Credentials: root / secret
  74. ***** OpenNMS *****
  75. URL: http://\4:8980/opennms
  76. credentials: admin / admin
  77. ***** Grafana *****
  78. URL: http://\4:3000
  79. credentials: admin / admin
  80. \S
  81. Kernel \r on an \m
  82. EOF