Welcome to Centmin Mod Community
Become a Member

Install Xenforo CentOS 7.x How To Install Elasticsearch 7.x for Xenforo

Discussion in 'Centmin Mod User Tutorials & Guides' started by Sunka, Mar 6, 2020.

  1. Sunka

    Sunka Well-Known Member

    1,140
    312
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +508
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    How To Install Elasticsearch 7.x for Xenforo


    This is tutorial for installing (not upgrading) elasticsearch 7 on centos.
    If I am missing something, please post here.

    Delete first old one if you have installed and install fresh new one elasticsearch v7
    Code (Text):
    yum remove elasticsearch


    Installing elasticsearch 7

    Code (Text):
    rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
    

    Code (Text):
    nano /etc/yum.repos.d/elasticsearch.repo
    

    insert this:
    Code (Text):
    [elasticsearch]
    name=Elasticsearch repository for 7.x packages
    baseurl=https://artifacts.elastic.co/packages/7.x/yum
    gpgcheck=1
    gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    enabled=1
    autorefresh=1
    type=rpm-md
    

    If you do not have java installed, install it (elasticsearch itself includes a bundled version of OpenJDK, but, just to be sure).
    Java v11 is what you want to install. You can have both version (v.8 and v.11) but I removed v8 and installed v11
    Code (Text):
    yum remove java-1.8.0-openjdk
    

    Code (Text):
    yum -y install java-11-openjdk
    


    Code (Text):
    yum install --enablerepo=elasticsearch elasticsearch
    

    Code (Text):
    nano /etc/elasticsearch/elasticsearch.yml
    

    at the end of file add this:
    Code (Text):
    cluster.name: CUSTOM NAME OF YOUR CLUSTER (same name "should" be inserted into your XenForo field in Admin Control Panel in field Elasticsearch Index Name)
    network.host: localhost
    http.port: 9200
    node.name: ANOTHER CUSTOM NAME
    cluster.initial_master_nodes: ANOTHER CUSTOM NAME (same as line above, and use all lowercase)
    


    Also, in template /etc/elasticsearch/jvm.options change/modify the path -Djava.io.tmpdir=
    Code (Text):
    -Djava.io.tmpdir=/home/elasticsearch
    


    Then (thanks @rdan )
    Code (Text):
    mkdir /home/elasticsearch
    


    and

    Code (Text):
    chown -R elasticsearch:elasticsearch /home/elasticsearch/
    



    set how much ram you will add for elasticsearch - 512 megabytes is set in example (both Xms and Xmx must have same value)
    Code (Text):
    nano /etc/elasticsearch/jvm.options
    

    Code (Text):
    -Xms512m
    -Xmx512m
    



    Code (Text):
    service elasticsearch start
    

    Code (Text):
    systemctl daemon-reload
    

    Code (Text):
    systemctl enable elasticsearch.service
    

    Code (Text):
    systemctl start elasticsearch.service
    


    test if everything OK (give 1-2 minute after restarting elasticsearch)
    Code (Text):
    curl -XGET 'localhost:9200'
    

    If everything OK, you will see something like this in your CLI
    Code (Text):
    # curl -XGET 'localhost:9200'
    {
      "name" : "xxxx",
      "cluster_name" : "xxxxx",
      "cluster_uuid" : "4nAffvfpSGG-RE4ou1ttFA",
      "version" : {
        "number" : "7.6.0",
        "build_flavor" : "default",
        "build_type" : "rpm",
        "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
        "build_date" : "2020-02-06T00:09:00.449973Z",
        "build_snapshot" : false,
        "lucene_version" : "8.4.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    


    Also, just in case run command and choose Java 11 (if it will list more than 1 java version):
    Code (Text):
    alternatives --config java
    


    Also, it is better that you not use shard replica if Elasticsearch is on same server.
    So for make by default no replica shards, run this command

    Code (Text):
    curl -XPUT "localhost:9200/_template/all" -H'Content-Type: application/json' -d'
    {
      "template": "*",
      "settings": {
        "number_of_replicas": 0,
        "number_of_shards": 1
      }
    }
    '
    


    To see if you have unassigned replica shards run:

    Code (Text):
    curl -s -XGET http://localhost:9200/_cat/shards | fgrep UNASSIGNED
    


    To delete unassigned replica shards run:

    Code (Text):
    curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "http://localhost:9200/{}"
    


    Then deleted the index. After that go to ElasticSearch Setup in Xenforo ACP then rebuilt the index without deleting.

    Minimum version of XenForo Enhanced Search you have installed for elasticsearch 7 is 2.0 I think!

    After you installed elastic search, configure relevant options for enhanced search in your Xenforo ACP and rebuild index (all).
    It is better and faster to rebuild index through cli. So:

    Trunucate old index first (if you have it):
    Code (Text):
    cd /PATH/TO/YOUR/XENFERO/INSTALL/public/
    
    // SOMETHING LIKE: cd /home/nginx/domains/your_domain.com/public/
    

    and then

    Rebuild search with trunucating index before that
    Code (Text):
    php cmd.php xf-rebuild:search --truncate
    

    or just rebuild without trunucating index
    Code (Text):
    php cmd.php xf-rebuild:search
    


    And how it looks in elasticsearch setup page in xenforo ACP

    setup.png
     
    Last edited: Apr 13, 2020
  2. negative

    negative Active Member

    404
    49
    28
    Apr 11, 2015
    Ratings:
    +96
    Local Time:
    7:57 AM
    1.9.10
    10.1.11
    Thanks for guide.

    How is the performance difference instead of version 6 on xenforo ?
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    3,826
    370
    83
    May 31, 2014
    Ratings:
    +712
    Local Time:
    7:57 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    @Sunka
    You may need to add info about log rotating Elastic search logs :)
     
  4. modder

    modder Member

    40
    3
    8
    Dec 6, 2019
    Ratings:
    +6
    Local Time:
    12:57 PM
    It works!! Thanks!

    Just a little advice. Maybe you should specify in which file the following line should be modified in your tutorial. It's /etc/elasticsearch/jvm.options

     
    Last edited: Mar 10, 2020
  5. Sunka

    Sunka Well-Known Member

    1,140
    312
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +508
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    It is specifed


    This?
    For me I think same, because my forum is not so big (300000 posts, 1000 active users in month)
     
  6. modder

    modder Member

    40
    3
    8
    Dec 6, 2019
    Ratings:
    +6
    Local Time:
    12:57 PM
    I know it's my problem. I actually thought it's that file... :smuggrin:

    [​IMG]
     
  7. pamamolf

    pamamolf Premium Member Premium Member

    3,826
    370
    83
    May 31, 2014
    Ratings:
    +712
    Local Time:
    7:57 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    @Sunka

    No

    I am talking for Elastic search system log files rotation at: /var/log/elastic/blabla.log

    Every day is a new file there and we should have a log rotation every x days as we have at /var/log/ for Nginx and Php .... :)

    Thank you
     
  8. Sunka

    Sunka Well-Known Member

    1,140
    312
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +508
    Local Time:
    6:57 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Edited first post.
    Thanks
     
  9. negative

    negative Active Member

    404
    49
    28
    Apr 11, 2015
    Ratings:
    +96
    Local Time:
    7:57 AM
    1.9.10
    10.1.11
    So, webmasters who install it advice that upgrade eleasticsearch to 7 from 6 ? How effect the performance ?
     
  10. pamamolf

    pamamolf Premium Member Premium Member

    3,826
    370
    83
    May 31, 2014
    Ratings:
    +712
    Local Time:
    7:57 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    How can i install a specific version of Elastic search like 7.6.x ?