2012年5月12日土曜日

[java]tomcat上のapache solrのBasic認証とマスタースレーブ設定


tomcatでのBasic認証はこちら。
http://osima.jp/blog/tomcat-auth/

$CATALINA_HOME/conf/tomcat-user.xml

    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="role_foo"/>
      <user username="foo" password="hogehoge" roles="role_foo"/>
    </tomcat-users>



$CATALINA_HOME/webapps/mywebapp/WEB-INF/web.xml 
    <web-app>
    
    ...省略
    
     <security-constraint>
      <web-resource-collection>
       <web-resource-name>Test</web-resource-name>
       <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
       <role-name>role1</role-name>
      </auth-constraint>
     </security-constraint>
     
     <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>Test</realm-name>
     </login-config>
     
     <security-role>
      <role-name>role1</role-name>
     </security-role>
    
    </web-app>
    



んで、もしSolrのマスターサーバがBasic認証かかるのであれば、
スレーブのsolrconfig.xmlで次の記述を入れる。
http://wiki.apache.org/solr/SolrReplication


        <str name="httpBasicAuthUser">username</str>
        <str name="httpBasicAuthPassword">password</str>




Slave


<requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="slave">

        <!--fully qualified url for the replication handler of master . It is possible to pass on this as a request param for the fetchindex command-->
        <str name="masterUrl">http://master_host:port/solr/corename/replication</str>

        <!--Interval in which the slave should poll master .Format is HH:mm:ss . If this is absent slave does not poll automatically.
         But a fetchindex can be triggered from the admin or the http API -->
        <str name="pollInterval">00:00:20</str>
        <!-- THE FOLLOWING PARAMETERS ARE USUALLY NOT REQUIRED-->
        <!--to use compression while transferring the index files. The possible values are internal|external
         if the value is 'external' make sure that your master Solr has the settings to honour the accept-encoding header.
         see here for details http://wiki.apache.org/solr/SolrHttpCompression
         If it is 'internal' everything will be taken care of automatically.
         USE THIS ONLY IF YOUR BANDWIDTH IS LOW . THIS CAN ACTUALLY SLOWDOWN REPLICATION IN A LAN-->
        <str name="compression">internal</str>
        <!--The following values are used when the slave connects to the master to download the index files.
         Default values implicitly set as 5000ms and 10000ms respectively. The user DOES NOT need to specify
         these unless the bandwidth is extremely low or if there is an extremely high latency-->
        <str name="httpConnTimeout">5000</str>
        <str name="httpReadTimeout">10000</str>

        <!-- If HTTP Basic authentication is enabled on the master, then the slave can be configured with the following -->
        <str name="httpBasicAuthUser">username</str>
        <str name="httpBasicAuthPassword">password</str>

     </lst>
</requestHandler>

0 件のコメント:

コメントを投稿