Script to create snapshot in Oracle ECE
In Oracle ECE patch set 3 , we need to take pricing snapshot before restart so that it can be recovered with same pricing data again. If snapshot is not taken then you will end up loosing all your pricing data in ECE cache. Then you have to go for PDC republish which may take more than 48 hrs (depending upon your price plan structure).
To avoid this situation I would recommend you to schedule snapshot creation in crontab so that always you have backup . You can put a simple login to delete snapshot older than 30 days as per your business policy.
Please find below steps to create pricing snapshot in oracle ECE using script .
- Create groovy with below lines of code .
import java.lang.management.*
import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
import groovy.swing.SwingBuilder
import javax.swing.WindowConstants as WC
import java.time.LocalDate
import java.time.format.DateTimeFormatter
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd")
LocalDate localDate = LocalDate.now()
snapService =
['ReplicatedFederatedCache','XRefFederatedCache'
]
def snapSList
def snapSuse = 'SCRIPT_'+dtf.format(localDate)
snapService.each {
def serverUrl = 'service:jmx:rmi:///jndi/rmi://<<full hostname of ece server>>:9999/jmxrmi'
String beanName =
"Coherence:type=Persistence,service=${it},responsibility=PersistenceCoordinator"
def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection
def dataSystem = new GroovyMBean(server, beanName)
//#snapSList = dataSystem.listArchivedSnapshots();
//#println "\nArchived snapshot of ${it} service"
//#println "\n$snapSList"
println "\nStart creating Snapshot ${snapSuse} for ${it}"
dataSystem.createSnapshot(snapSuse);
while ( dataSystem.Idle == false) {
Thread.sleep(1000)
println("\nwaiting for operation to complete");
}
}
2. Now execute this groovy file with below command :
groovy -cp $ECE_HOME/lib/spring-beans-4.3.6.RELEASE.jar create_snapshot.groovy
Don't forget to edit the spring jar version with your version.
Script with create snapshot with today;s date
Comments
Post a Comment