Get the most out of your Centmin Mod LEMP stack
Become a Member

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

    992
    270
    63
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +444
    Local Time:
    3:40 AM
    Nginx 1.15.0
    MariaDB 10.2.15
    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
     
    • Like Like x 4
    • Useful Useful x 2
    • Winner Winner x 1
    • Informative Informative x 1
  2. Chris

    Chris Member

    34
    5
    8
    Feb 27, 2015
    Ratings:
    +8
    Local Time:
    9:40 PM
    1.7
    10
    Thank you!
     
    • Like Like x 1
    • Friendly Friendly x 1
  3. pamamolf

    pamamolf Well-Known Member

    3,108
    294
    83
    May 31, 2014
    Ratings:
    +529
    Local Time:
    4:40 AM
    Nginx-1.13.x
    MariaDB 10.1.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

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 AM
    1.9.x
    10.1.x
    Why would you do that if you can install from the repo?
     
    • Agree Agree x 1
  5. pamamolf

    pamamolf Well-Known Member

    3,108
    294
    83
    May 31, 2014
    Ratings:
    +529
    Local Time:
    4:40 AM
    Nginx-1.13.x
    MariaDB 10.1.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

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 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

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 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

    35,048
    7,738
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,932
    Local Time:
    11:40 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    firewalled elasticsearch search is a must ! as with any remote server communication :)
     
  9. Revenge

    Revenge Active Member

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 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 Well-Known Member

    3,108
    294
    83
    May 31, 2014
    Ratings:
    +529
    Local Time:
    4:40 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    What command did you use for that?
     
  11. Revenge

    Revenge Active Member

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 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.
     
    • Like Like x 1
  12. eva2000

    eva2000 Administrator Staff Member

    35,048
    7,738
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,932
    Local Time:
    11:40 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    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.
     
    • Agree Agree x 1
  13. Revenge

    Revenge Active Member

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 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

    143
    57
    28
    Nov 16, 2015
    Ratings:
    +186
    Local Time:
    9:40 AM
    1.13.x
    MariaDB 10.1.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.
     
    • Informative Informative x 2
  15. pamamolf

    pamamolf Well-Known Member

    3,108
    294
    83
    May 31, 2014
    Ratings:
    +529
    Local Time:
    4:40 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Using:
    When i use:
    I am getting:
     
    Last edited: Feb 22, 2018
  16. pamamolf

    pamamolf Well-Known Member

    3,108
    294
    83
    May 31, 2014
    Ratings:
    +529
    Local Time:
    4:40 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    I reinstall it and now it works :)

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

    Revenge Active Member

    401
    84
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +299
    Local Time:
    2:40 AM
    1.9.x
    10.1.x
    Anyone here recommends a good tool or service to monitor Elastic Search?
     
  18. rdan

    rdan Premium Member Premium Member

    4,222
    1,027
    113
    May 25, 2014
    Ratings:
    +1,466
    Local Time:
    9:40 AM
    Mainline
    10.2
  19. Recep Baltas

    Recep Baltas New Member

    4
    2
    3
    Dec 11, 2015
    Ratings:
    +2
    Local Time:
    4:40 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 Premium Member Premium Member

    4,222
    1,027
    113
    May 25, 2014
    Ratings:
    +1,466
    Local Time:
    9:40 AM
    Mainline
    10.2
    Visit yourxfurl/admin.php?tools/phpinfo
    Look for: $_SERVER['DOCUMENT_ROOT']

    That the correct directory path.
     
    • Like Like x 1
    • Agree Agree x 1
    • Informative Informative x 1
..