Learn about Centmin Mod LEMP Stack today
Register Now

Xenforo How To Install Elasticsearch 6.x for Xenforo

Discussion in 'Centmin Mod User Tutorials & Guides' started by Sunka, Nov 30, 2017.

  1. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    10:46 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    This is tutorial for installing (not upgrading) elasticsearch 6 on centos.
    If I am missing something, please post here.

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


    Installing elasticsearch 6

    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-6.x]
    name=Elasticsearch repository for 6.x packages
    baseurl=https://artifacts.elastic.co/packages/6.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 (at least v8), install it
    Code (Text):
    yum -y install java-1.8.0-openjdk
    

    Code (Text):
    yum -y install 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
    

    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):
    mkdir /etc/elasticsearch/scripts/
    

    Code (Text):
    cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/
    

    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" : "xxxxxx",
      "cluster_name" : "xxxxx",
      "cluster_uuid" : "ZLDl3yghRIa6MBvRGLBPzg",
      "version" : {
        "number" : "6.0.0",
        "build_hash" : "8f0685b",
        "build_date" : "2017-11-10T18:41:22.859Z",
        "build_snapshot" : false,
        "lucene_version" : "7.0.1",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      },
      "tagline" : "You Know, for Search"
    }


    Minimum version of XenForo Enhanced Search you have installed for elasticsearch 6 is 1.1.8

    After you installed elastic search, configure relevant options for enhanced search in your Xenforo ACP and rebuild index (all)

    acpoption.png




    And how it looks in elasticsearch setup page in xenforo ACP

    acp.png
     
  2. Chris

    Chris Member

    51
    10
    8
    Feb 27, 2015
    Ratings:
    +15
    Local Time:
    4:46 AM
    1.7
    10
    Thank you!
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    11:46 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    What about installing it using:

    Code:
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.rpm
    
    rpm -ivh elasticsearch-6.1.1.rpm
    
    systemctl enable elasticsearch
    systemctl start elasticsearch
    ?
     
  4. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Why would you do that if you can install from the repo?
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    11:46 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Don't know the difference that's why i am asking ....

    I just thought that my way will cause also issues when an upgrade will be out ....
     
  6. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Anyone here tried installing Elasticsearch in a different server instead of localhost?

    If i add this: network.host: 0.0.0.0, it works but everyone have access to the elasticsearch. If i define to correct IP Address of the server that needs access to the Elasticsearch, it does not work.
     
  7. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Well, i solved it with a workaround. Blocked port 9200 in iptables for all ip's less the one i want.
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,529
    12,212
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,781
    Local Time:
    7:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    firewalled elasticsearch search is a must ! as with any remote server communication :)
     
  9. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    I opened port 9200, then i was thinking to bind the IP in elasticsearch that i wanted to allow access.

    But the better way to do this is with iptables(or firewalld), i agree with you.

    When i was searching in Google to find a solution for the reason that i was not being able to bind a public IP, i found out many people with the same problem and their fix was to just use 0.0.0.0 without blocking in iptables, which basically makes their elasticsearch open to the whole world...
     
  10. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    11:46 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    What command did you use for that?
     
  11. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Code:
    iptables -A INPUT -p tcp --dport 9200 -s 8.8.8.8 -j ACCEPT
    
    iptables -A INPUT -p tcp --dport 9200 -j DROP
    Change 8.8.8.8 for the ip you want to give access to port 9200.
     
  12. eva2000

    eva2000 Administrator Staff Member

    54,529
    12,212
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,781
    Local Time:
    7:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI, for centmin mod users don't need to do iptables command as CSF Firewall by default blocks 9200 port from inbound or outbound access (remote usage) so usually, only need to whitelist the remote server's ip address in CSF Firewall to only allow that IP to communicate over port 9200 - see post 2 at CSF - CSF Firewall info for specific instructions of allowing only a specific IP to connect in/out bound for port 9200. Inbound rules would be on remote server if your remote elasticsearch server was running CSF Firewall and outbound rules would Centmin Mod web server that connects to the remote elasticsearch server.
     
  13. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Are there any differences in terms of performance between using elasticsearch in localhost or in another server? (both servers with the same hardware)
     
  14. Xon

    Xon Active Member

    173
    61
    28
    Nov 16, 2015
    Ratings:
    +229
    Local Time:
    5:46 PM
    1.15.x
    MariaDB 10.3.x
    No performance difference.

    Note; Elasticsearch has some fairly exotic methods of network binding.

    Network Settings | Elasticsearch Reference [6.1] | Elastic

    Code:
    network.host: _site:ipv4_
    
    This will bind to the first non-routable ipv4 address on the system.
     
  15. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    11:46 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Using:
    When i use:
    I am getting:
     
    Last edited: Feb 22, 2018
  16. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    11:46 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    I reinstall it and now it works :)

    So please ignore my above post....
     
  17. Revenge

    Revenge Active Member

    469
    93
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +354
    Local Time:
    9:46 AM
    1.9.x
    10.1.x
    Anyone here recommends a good tool or service to monitor Elastic Search?
     
  18. rdan

    rdan Well-Known Member

    5,446
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    5:46 PM
    Mainline
    10.2
  19. Recep Baltas

    Recep Baltas New Member

    5
    3
    3
    Dec 11, 2015
    Ratings:
    +3
    Local Time:
    11:46 AM
    I'm stuck here:

    cp -a /path/to/xenforoinstall/library/XenES/_scripts/*.groovy /etc/elasticsearch/scripts/

    Getting error:

    cp: cannot stat `/public_html/sosyal/library/XenES/_scripts/*.groovy': No such file or directory

    Logged in as root^^

    Logged in as hosting account, same...
     
  20. rdan

    rdan Well-Known Member

    5,446
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    5:46 PM
    Mainline
    10.2
    Visit yourxfurl/admin.php?tools/phpinfo
    Look for: $_SERVER['DOCUMENT_ROOT']

    That the correct directory path.