JMX command line recipes for Alfresco revisited

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

 
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

$>open service:jmx:rmi:///jndi/rmi://localhost:50500/alfresco/jmxrmi -p change_asap -u controlRole
$>domain Alfresco
$>bean log4j:logger=org.alfresco.smb.protocol
#bean is set to log4j:logger=org.alfresco.smb.protocol

$>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

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

$>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:

$>bean Alfresco:Name=GlobalProperties    
#bean is set to Alfresco:Name=GlobalProperties
$>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

$>bean Alfresco:Name=SystemProperties                                     
#bean is set to Alfresco:Name=SystemProperties
$>get file.encoding
#mbean = Alfresco:Name=SystemProperties:
file.encoding = UTF-8;
$>get user.language
#mbean = Alfresco:Name=SystemProperties:
user.language = es;


HINT: Other possibility for opening the connection is:

$>jvms
1435     (m) - org.apache.catalina.startup.Bootstrap start
3230     ( ) - jmxterm-1.0-alpha-4-uber.jar
$>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:

$>bean Alfresco:Name=RepoServerMgmt
#bean is set to Alfresco:Name=RepoServerMgmt
$>get UserCountAll
#mbean = Alfresco:Name=RepoServerMgmt:
UserCountAll = 1;
$>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:

$>bean Alfresco:Category=fileServers,Type=Configuration,id1=default
#bean is set to Alfresco:Category=fileServers,Type=Configuration,id1=default
$>run stop

 
STOPPING AND RESTARTING SUBSYSTEMS (i.e: LDAP)

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

$>bean Alfresco:Category=Authentication,Type=Configuration,id1=managed,id2=ldap1
$>run stop

and later, when all it's correct

$>run start

 
LDAP USER RESYNC

Other common task may be resync our LDAP:

$>bean log4j:logger=org.alfresco.repo.security.sync
$>set priority DEBUG
$>bean Alfresco:Category=Synchronization,Type=Configuration,id1=default
$>run stop
$>run start
$>bean log4j:logger=org.alfresco.repo.security.sync
$>set priority INFO

And for full LDAP resync:

$>bean Alfresco:Category=Synchronization,Type=Configuration,id1=default
$>set synchronization.synchronizeChangesOnly false
$>run stop
$>run start

 

SETTING ALFRESCO IN READ ONLY MODE

$>bean Alfresco:Name=RepoServerMgmt
#bean is set to Alfresco:Name=RepoServerMgmt

$>get ReadOnly
#mbean = Alfresco:Name=RepoServerMgmt:
ReadOnly = false;

$>bean Alfresco:Category=sysAdmin,Type=Configuration,id1=default
#bean is set to Alfresco:Category=sysAdmin,Type=Configuration,id1=default

$>set server.allowWrite false
#Value of attribute server.allowWrite is set to false

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

$>bean Alfresco:Name=RepoServerMgmt
#bean is set to Alfresco:Name=RepoServerMgmt

$>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

00

More Blog Entries

0 Comments