Skip to content

Instantly share code, notes, and snippets.

import javax.jcr.Node;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.event.EventUtil;
import org.apache.sling.event.JobProcessor;
import org.apache.sling.jcr.api.SlingRepository;
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
cd <Your Mongo bin Location>
# You can also configure port using configuration file
./mongo --port <PORT>
rs.initiate()
# Check the conf that it is not part of replica set yet
rs.conf()
#This is your second Mongo Instance, Make sure that your other Mongo Instance is already set up
rs.add("<HOST>:<PORT>")
#This is your Third Mongo Instance (You need to have odd number of instances for election to work)
rs.add("<HOST>:<PORT>")
# Unpack AEM jar using
java -jar <AEM Jar> -unpack
# Go to bin directory
cd crx-quickstart/bin
#Change syour start script
vi start
#Set runmode to crx3mongo
cd <Mongo bin directory>
use admin
db.shutdownServer()
#Take Backup
./mongodump --dbpath ../data/<NAME OF DB> -o dataout
# Now set up new Mongo DB servers that you want to add in replica set Instruction above
# Now start your existing Mongo Using following command, Note that this time we are using replSet
# You can also do this using Mongo DB configuration file
./mongod --port 27017 --dbpath <your DB path> --replSet <Replica set Name> &
#Connect to the mongodb instance
cd <Mongo bin directory>
./mongo
# Show all db
show dbs
# Check status of replica set
rs.status()
# If this is secondary you need to do
rs.slaveOk()
# Use database (Use AEM DB or DB you chose)
use <data-base-name>
#Install Docker Client
yum -y remove docker
yum install docker-io
yum -y update docker-io
#This will start docker deamon
service docker start
#Install docker registry
yum install python-devel libevent-devel python-pip gcc xz-devel
python-pip install docker-registry[bugsnag,newrelic,cors]
@yupadhyay
yupadhyay / aem_docker_image.sh
Created March 13, 2015 17:40
Docker file for creating initial AEM image. This Assumes that you already have AEM jar file. You already have compiled version of httpd. You have JDK folder. Before using this you have to make sure that they all are placed in same folder where Docker file is
FROM centos
#Install and set java home
RUN mkdir -p /export/apps/jdk
ADD JDK-1_7_0_51 /export/apps/jdk/JDK-1_7_0_51
ENV JAVA_HOME /export/apps/jdk/JDK-1_7_0_51
ENV PATH $PATH:$JAVA_HOME/bin
#Install CQ Author
RUN mkdir -p /export/apps/aem/author
WORKDIR /export/apps/aem/author
ADD cq5-publish-p4503.jar /export/apps/aem/author/cq5-author-p4502.jar
@yupadhyay
yupadhyay / build_aem_docker_image.sh
Created March 13, 2015 17:44
Command to create docker Image
#Make sure that you run this command from same directory where docker file is
#Also makes sure that all files are at same location
docker build --tag="localhost:5000/wemblog/microsites_aem:5.6" .
#Make sure that image exist before push
docker images
#Push image to registry
docker push localhost:5000/wemblog/microsites_aem:5.6
@yupadhyay
yupadhyay / docker_change_location.sh
Created March 13, 2015 18:01
By default docker get installed under /var/lib/docker . If you don't have enough space there then you might have to do following
#Check if /var is getting filled
df -k
#If /var space is not more than 50GB do following
sudo su
#Stop Docker
service docker stop
#Copy all files to folder that have enough space
#usually in linux boxes there is enough space under /export
#Create a dummy directory 'mkdir /export/apps/docker'
cp -R /var/lib/docker/ <Your other folder>