Discover Centmin Mod today
Register Now

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,142
    313
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +510
    Local Time:
    1:28 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

    414
    49
    28
    Apr 11, 2015
    Ratings:
    +97
    Local Time:
    2:28 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,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    2:28 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

    44
    5
    8
    Dec 6, 2019
    Ratings:
    +8
    Local Time:
    7:28 AM
    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,142
    313
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +510
    Local Time:
    1:28 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

    44
    5
    8
    Dec 6, 2019
    Ratings:
    +8
    Local Time:
    7:28 AM
    I know it's my problem. I actually thought it's that file... :smuggrin:

    [​IMG]
     
  7. pamamolf

    pamamolf Premium Member Premium Member

    3,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    2:28 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,142
    313
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +510
    Local Time:
    1:28 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    Edited first post.
    Thanks
     
  9. negative

    negative Active Member

    414
    49
    28
    Apr 11, 2015
    Ratings:
    +97
    Local Time:
    2:28 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,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    2:28 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    How can i install a specific version of Elastic search like 7.6.x ?
     
  11. Revenge

    Revenge Active Member

    458
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +350
    Local Time:
    12:28 AM
    1.9.x
    10.1.x
    yum install elasticsearch-7.6.0-1.x86_64


    I just did that, because IPS 4.5.0 have a bug with Elasticsearch 7.7+. So i downgrade to that version.
    The bug is on Elasticsearch side, so we need to wait.
     
  12. pamamolf

    pamamolf Premium Member Premium Member

    3,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    2:28 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    What kind of bug?

    Did you post it in Public so i can follow it or is it on a private ticket?

    Thanks
     
  13. Revenge

    Revenge Active Member

    458
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +350
    Local Time:
    12:28 AM
    1.9.x
    10.1.x
    It was a private ticket.

     
  14. pamamolf

    pamamolf Premium Member Premium Member

    3,857
    378
    83
    May 31, 2014
    Ratings:
    +729
    Local Time:
    2:28 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    Weird as i thought that 7.7 was supported for 4.5.1 ....
     
  15. Andy

    Andy Premium Member Premium Member

    477
    77
    28
    Aug 6, 2014
    Ratings:
    +109
    Local Time:
    7:28 PM
    Just install elasticsearch 7.9.2 via yum update and when I went to restart it, it reports failure

    status elasticsearch.service
    ‚óŹ elasticsearch.service - Elasticsearch
    Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Tue 2020-09-29 15:23:47 UTC; 3min 10s ago
    Docs: https://www.elastic.co
    Process: 23204 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
    Main PID: 23204 (code=exited, status=1/FAILURE)

    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: Error: A fatal exception has occurred. Program will exit.
    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:126)
    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88)
    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:137)
    Sep 29 15:23:47 main.quantnet.com systemd-entrypoint[23204]: at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:95)
    Sep 29 15:23:47 main.quantnet.com systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
    Sep 29 15:23:47 main.quantnet.com systemd[1]: Failed to start Elasticsearch.
    Sep 29 15:23:47 main.quantnet.com systemd[1]: Unit elasticsearch.service entered failed state.
    Sep 29 15:23:47 main.quantnet.com systemd[1]: elasticsearch.service failed.
     
  16. Andy

    Andy Premium Member Premium Member

    477
    77
    28
    Aug 6, 2014
    Ratings:
    +109
    Local Time:
    7:28 PM
    Looks like I have to uninstall elasticsearch and install it again and it solved the issue.
     
  17. negative

    negative Active Member

    414
    49
    28
    Apr 11, 2015
    Ratings:
    +97
    Local Time:
    2:28 AM
    1.9.10
    10.1.11
    @eva2000

    I've set the following file
    Code (Text):
    nano /etc/elasticsearch/elasticsearch.yml


    like;

    Code (Text):
    cluster.name: forum
    network.host: localhost
    http.port: 9200
    node.name: forum
    cluster.initial_master_nodes: forum


    But i see that i configured it on xenforo panel as forumelastic, so they are different ..

    Forum search and elastic looks as works well.

    May be any problem with that config and what may the problem?