VM Boostrap
Normally I would use Chef to provision the VM. This is the manual configuration list to get a repeatable VM snapshot built.
We are running a RHEL 7.3 VM on top of either Windows 10 or MacOS 10
Register System
Attach Subscription
1. Change Networks and hostname (some services need differentiation in an HA environment)
[root@localhost ~]# vi /etc/hosts
[rootRHEL7@localhost ~]# hostnamectl set-hostname biometric-vm01
[rootRHEL6@localhost ~]# vi /etc/sysconfig/network
[root@localhost ~]# systemctl restart systemd-hostnamed
verify /etc/hosts has the correct ip set for the VM
If you have 2 NIC's in this case the wired nic is on a private internal subnet with no internet access and the wireless nic is our internet access - you will need to change the METRIC order. You need to set the internet live nic as the first in the routing sequence by setting the METRIC lowest on wireless and turning off DEFROUTE, IPV4_DEFROUTE, PEERDNS etc on the private wired nic.
Check regenerated
[root@nuc14-i3 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.100.1
Make the non-internet nic secondary
[root@nuc14-i3 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s25
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE=no
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="no"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s25"
UUID="938325b5-6c08-49eb-8044-8fd5dfe931fe"
DEVICE="enp0s25"
ONBOOT="yes"
PEERDNS=no
PEERROUTES=yes
IPV6_PEERDNS=no
IPV6_PEERROUTES=yes
METRIC=200
2. Install Java 8
[root@biometric-vm01 ~]# alternatives --config java
Selection Command
-----------------------------------------------
1 /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64/jre/bin/java
*+ 2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/bin/java
Ideally install the SUN/Oracle JDK
download from http://java.sun.com
3. yum update -y
firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo groupadd tomcat
sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
cd ~
http://apache.mirror.rafal.ca/tomcat/tomcat-8/v8.0.39/bin/apache-tomcat-8.0.39.tar.gz
sudo mkdir /opt/tomcat
sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
sudo chgrp -R tomcat conf
sudo chmod g+rwx conf
sudo chmod g+r conf/*
cd /opt
cd /opt
sudo chown -R tomcat tomcat/
sudo vi /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat8
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx4096M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID
[Install]
WantedBy=multi-user.target
72 sudo systemctl daemon-reload
73 sudo systemctl start tomcat
74 sudo systemctl enable tomcat
81 systemctl restart firewalld.service
[root@rhel73os0prod opt]# systemctl status tomcat.service
● tomcat.service - Apache Tomcat8
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2016-12-10 22:07:05 EST; 12s ago
Process: 4731 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 4738 (java)
CGroup: /system.slice/tomcat.service
└─4738 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava...
Dec 10 22:07:05 rhel73os0prod systemd[1]: Starting Apache Tomcat8...
Dec 10 22:07:05 rhel73os0prod systemd[1]: Started Apache Tomcat8.
[root@rhel73os0prod opt]# systemctl status tomcat.service
● tomcat.service - Apache Tomcat8
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2016-12-10 22:07:05 EST; 12s ago
Process: 4731 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 4738 (java)
CGroup: /system.slice/tomcat.service
└─4738 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava...
Dec 10 22:07:05 rhel73os0prod systemd[1]: Starting Apache Tomcat8...
Dec 10 22:07:05 rhel73os0prod systemd[1]: Started Apache Tomcat8.
5. Setup developer services
6. PostgreSQL install - for ORM services via Hibernate or better EclipseLink
7. MySQL install
http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
cd Downloads
yum repolist enabled | grep "mysql.*-community.*"
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum install mysql-community-server
Installing : mysql-community-common-5.7.12-1.el7.x86_64 1/6cd Downloads
yum repolist enabled | grep "mysql.*-community.*"
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum install mysql-community-server
Installing : mysql-community-libs-5.7.12-1.el7.x86_64 2/6
Installing : mysql-community-client-5.7.12-1.el7.x86_64 3/6
Installing : mysql-community-server-5.7.12-1.el7.x86_64 4/6
Installing : mysql-community-libs-compat-5.7.12-1.el7.x86_64 5/6
Erasing : 1:mariadb-libs-5.5.47-1.el7_2.x86_64 6/6
Verifying : mysql-community-client-5.7.12-1.el7.x86_64 1/6
Verifying : mysql-community-server-5.7.12-1.el7.x86_64 2/6
Verifying : mysql-community-common-5.7.12-1.el7.x86_64 3/6
Verifying : mysql-community-libs-5.7.12-1.el7.x86_64 4/6
Verifying : mysql-community-libs-compat-5.7.12-1.el7.x86_64 5/6
Verifying : 1:mariadb-libs-5.5.47-1.el7_2.x86_64 6/6
service mysqld start
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER User 'root'@'localhost' IDENTIFIED BY 'S';
/usr/bin/mysql_secure_installation
mysql -u root -p
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER User 'root'@'localhost' IDENTIFIED BY 'S';
/usr/bin/mysql_secure_installation
mysql -u root -p
mysql>create database biometric;
here
mysql>create user 'obrienlabs'@'192.168.0.21' IDENTIFIED BY 'OC';here
mysql>grant all on biometric.* to 'obrienlabs'@'192.168.0.21';
mysql> create user 'obriensystems'@'%' IDENTIFIED BY 'S';
mysql> grant all on biometric.* to 'obriensystems'@'%';
mysql>flush privileges;
mysql> create user 'obriensystems'@'%' IDENTIFIED BY 'S';
mysql> grant all on biometric.* to 'obriensystems'@'%';
mysql>flush privileges;
firewall-cmd --permanent --zone=public --add-service=mysql
firewall-cmd --permanent --zone=public --add-port=3306/tcp
systemctl restart firewalld.service
help hibernate run the following
#https://github.com/Elgg/Elgg/issues/8121
# remove ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES
SET GLOBAL sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
8. Neo4J install - for graph based nosql (a geohash tree for example)firewall-cmd --permanent --zone=public --add-port=3306/tcp
systemctl restart firewalld.service
help hibernate run the following
private TypedQuery<Record> getTypedCriteriaQuery(EntityManager entityManager, String user) {
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Record> query = cb.createQuery(Record.class);
Root<Record> target = query.from(Record.class);
// workaround for http://stackoverflow.com/questions/16348354/how-do-i-write-a-max-query-with-a-where-clause-in-jpa-2-0
SingularAttribute<? super Record, Long> anAttribute = entityManager.getMetamodel()
.entity(Record.class).getSingularAttribute("tsStop", Long.class);
query.orderBy(
cb.desc(target.get(anAttribute)));
query.where(
cb.equal(target.get("userId"), user));
TypedQuery<Record> typedQuery = entityManager.createQuery(query);
return typedQuery;
}
#https://github.com/Elgg/Elgg/issues/8121
# remove ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES
SET GLOBAL sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
9. JPA
Hibernate on Spring Repository
<?xml version="1.0"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:task="http://www.springframework.org/schema/task"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:p="http://www.springframework.org/schema/p"xmlns:util="http://www.springframework.org/schema/util"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/taskhttp://www.springframework.org/schema/task/spring-task.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util.xsd"><context:component-scan base-package="com....orm"/><context:annotation-config/><!-- mvc:annotation-driven/--><!-- tx:annotation-driven/--><!-- bean id="contextAwareMBeanServer" class="com.common.DefaultServerMBean" /><bean id="dbConfig" class="com.common.util.NspConfig" depends-on="contextAwareMBeanServer"><constructor-arg type="java.lang.String" index="0" name="aInFileName" value="pgsql.conf" /></bean--><!-- bean class="com..app.ts.bwcal.config.SwaggerConfig"/--><bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/><bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><!-- bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"--><property name="driverClass" value="org.postgresql.Driver" /><property name="jdbcUrl" value="jdbc:postgresql://127.0.0.1:6432/orbwdb?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory" /><property name="user" value="taskscheduler" /><property name="password" value="taskscheduler" /><property name="minPoolSize" value="10"/><property name="maxPoolSize" value="20"/><property name="acquireIncrement" value="2"/><property name="maxStatementsPerConnection" value="100"/><property name="testConnectionOnCheckin" value="true" /><property name="testConnectionOnCheckout" value="true" /><property name="idleConnectionTestPeriod" value="90" /><property name="preferredTestQuery" value="SELECT 1" /></bean><!-- bean id="liquibase2" class="liquibase.integration.spring.SpringLiquibase"><property name="dataSource" ref="dataSource" /><property name="changeLog" value="classpath:db/changelog/db-changelog-master.xml" /><property name="defaultSchema" value="taskscheduler" /></bean--><bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"><property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect"/><property name="generateDdl" value="true"/><property name="showSql" value="true"/></bean><bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"p:jpaVendorAdapter-ref="jpaAdapter"><property name="persistenceUnitName" value="openflow"></property><property name="dataSource" ref="dataSource"></property><property name="jpaProperties"><props><prop key="hibernate.hbm2ddl.auto">create-drop</prop><prop key="hibernate.flushMode">FLUSH_AUTO</prop><prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop></props></property></bean><bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"p:entityManagerFactory-ref="emf"/><tx:annotation-driven transaction-manager="txManager"/></beans>