Open IT Experts for Enterprise

Zylk empresa de desarrollo de ecommerce

JMX command line recipes for Alfresco revisited

Cesar Capillas
Cesar Capillas

I compiled here below some simple JMX recipes for Alfresco with the
help of JMXTerm.

  • http://www.cyclopsgroup.org/projects/jmxterm/index.htm
  • http://jared.ottleys.net/alfresco/alfresco-jmx-from-the-command-line/
  • http://ecmarchitect.com/archives/2010/08/18/1209

SETTING LOG4J LEVELS (FOR CIFS)

In many cases, we have to deal with problems in production
environments (for example with CIFS). We can’t reboot but we must take
a look. For example, so:

zylk@scgd:~/jmxterm-1.0-alpha-4$ java -jar jmxterm-1.0-alpha-4-uber.jar

gt;open service:jmx:rmi:///jndi/rmi://localhost:50500/alfresco/jmxrmi -p change_asap -u controlRole

gt;domain Alfresco

gt;bean log4j:logger=org.alfresco.smb.protocol #bean is set to log4j:logger=org.alfresco.smb.protocol

gt;info #mbean = log4j:logger=org.alfresco.smb.protocol #class name = org.apache.log4j.jmx.LoggerDynamicMBean # attributes %0 - name (java.lang.String, r) %1 - priority (java.lang.String, rw) # operations %0 - void addAppender(java.lang.String class name,java.lang.String appender name) #there's no notifications

gt;get priority #mbean = log4j:logger=org.alfresco.smb.protocol: priority = ERROR;

gt;set priority DEBUG #mbean = log4j:logger=org.alfresco.smb.protocol: priority = DEBUG;

HINT: info provides the attributes to get and set, and
operations to run

CHECK ALFRESCO GLOBAL PROPERTIES

We can not know all the properties of the repository (many of
them in repository.properties file). We can get the «real»
information and explore them with:


gt;bean Alfresco:Name=GlobalProperties #bean is set to Alfresco:Name=GlobalProperties

gt;get authentication.chain #mbean = Alfresco:Name=GlobalProperties: authentication.chain = external1:external,ldap1:ldap,alfrescoNtlm1:alfrescoNtlm;

HINT: Take advantage of the autocomplete option for beans and properties

CHECK SYSTEM PROPERTIES

Sometimes you may need to access to system properties too


gt;bean Alfresco:Name=SystemProperties #bean is set to Alfresco:Name=SystemProperties

gt;get file.encoding #mbean = Alfresco:Name=SystemProperties: file.encoding = UTF-8;

gt;get user.language #mbean = Alfresco:Name=SystemProperties: user.language = es;

HINT: Other possibility for opening the connection is:


gt;jvms 1435 (m) - org.apache.catalina.startup.Bootstrap start 3230 ( ) - jmxterm-1.0-alpha-4-uber.jar

gt;open 1435 -u controlRole -p change_asap #Connection to 1435 is opened

HINT: If you are connected to Alfresco server locally, you can type
only open 1435

HOW TO KNOW WHO MANY PEOPLE IS CONNECTED TO THE REPOSITORY

Sometimes is useful:


gt;bean Alfresco:Name=RepoServerMgmt #bean is set to Alfresco:Name=RepoServerMgmt

gt;get UserCountAll #mbean = Alfresco:Name=RepoServerMgmt: UserCountAll = 1;

gt;run listUserNamesAll #calling operation listUserNamesAll of mbean Alfresco:Name=RepoServerMgmt #operation returns: [ zylk ]

DISABLING FILESERVERS

For any reason, you may want to disable a subsystem temporally:


gt;bean Alfresco:Category=fileServers,Type=Configuration,id1=default #bean is set to Alfresco:Category=fileServers,Type=Configuration,id1=default

gt;run stop

STOPPING AND RESTARTING SUBSYSTEMS (i.e: LDAP)

Or just maybe, disallow authentication LDAP user during a
maintainance operation


gt;bean Alfresco:Category=Authentication,Type=Configuration,id1=managed,id2=ldap1

gt;run stop

and later, when all it’s correct


gt;run start

LDAP USER RESYNC

Other common task may be resync our LDAP:


gt;bean log4j:logger=org.alfresco.repo.security.sync

gt;set priority DEBUG

gt;bean Alfresco:Category=Synchronization,Type=Configuration,id1=default

gt;run stop

gt;run start

gt;bean log4j:logger=org.alfresco.repo.security.sync

gt;set priority INFO

And for full LDAP resync:


gt;bean Alfresco:Category=Synchronization,Type=Configuration,id1=default

gt;set synchronization.synchronizeChangesOnly false

gt;run stop

gt;run start

SETTING ALFRESCO IN READ ONLY MODE


gt;bean Alfresco:Name=RepoServerMgmt #bean is set to Alfresco:Name=RepoServerMgmt

gt;get ReadOnly #mbean = Alfresco:Name=RepoServerMgmt: ReadOnly = false;

gt;bean Alfresco:Category=sysAdmin,Type=Configuration,id1=default #bean is set to Alfresco:Category=sysAdmin,Type=Configuration,id1=default

gt;set server.allowWrite false #Value of attribute server.allowWrite is set to false

gt;get server.allowWrite #mbean = Alfresco:Category=sysAdmin,Type=Configuration,id1=default: server.allowWrite = false;

gt;bean Alfresco:Name=RepoServerMgmt #bean is set to Alfresco:Name=RepoServerMgmt

gt;get ReadOnly #mbean = Alfresco:Name=RepoServerMgmt: ReadOnly = true;

SETTING ALFRESCO IN READ ONLY MODE VIA JMX SCRIPT

From the command line, you can get or set values of the
repository. For example, setting ReadOnly mode (maintenance mode –
preparing a migration or a backup).

$ echo get -s -b Alfresco:Name=RepoServerMgmt ReadOnly | java -jar jmxterm-1.0-alpha-4-uber.jar -l service:jmx:rmi:///jndi/rmi://localhost:50500/alfresco/jmxrmi -p change_asap -u controlRole -v silent -n

$ echo set -b Alfresco:Category=sysAdmin,Type=Configuration,id1=default server.transaction.allow-writes false | java -jar jmxterm-1.0-alpha-4-uber.jar -l service:jmx:rmi:///jndi/rmi://localhost:50500/alfresco/jmxrmi -p change_asap -u controlRole -v silent -n

http://wiki.cyclopsgroup.org/jmxterm/embed

Si te ha parecido interesante comparte este post en RRS

Facebook
LinkedIn
Telegram
Email

Leer más sobre temas relacionados

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *