Environment requirement: JDK1.8
Install ElasticSearch for standalone
(1) Upload the downloaded ElasticSearch-6.2.3.tar. gz file
Command: rz
(2) Decompress
Run the tar -zxvf elasticsearch-6.2.3.tar.gz command
(3) Rename the folder that is pressurized
Command: mv ElasticSearch -6.2.3 master
(4) Modify the configuration file to allow cross-domain access
Enter Mater: CD Master
Run conf: CD config
Edit the configuration file: vi elasticSearch.yml
Type “I” to enter edit mode and go to the last line
Feature:
http.cors.enabled: true
http.cors.allow-origin: “*”
There must be a space after the colon, otherwise an error will be reported
Press Esc and type: qw to save the Settings and exit.
5. Start ElasticSearch
Go to the installation root directory and run the CD.. /
Go to the bin directory and start es./elasticsearch
The following problems may occur during the process:
1) Insufficient memory:
Solution: This is caused by insufficient memory, reduce the memory required to start the program, or increase the memory, such as closing some programs.
Method 1: Expand the VM memory and directly change the VM memory. This method is omitted.
Method two: the way to reduce the memory required.
To access the config command, run CD config
To modify the jvm.properties file, run vi jvm.options
You can see that the default memory for this version is 1 GB, so let’s make it a little bit smaller.
Save and exit.
2)
[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.Copy the code
Solutions:
Add user and enable ElasticSearch with new user permissions.
Format: useradd User name -g Group name -p password
groupadd ymq
useradd ymq -g ymq -p ymq
Copy the code
Command format: chown -r Owning user: owning user group Name File path for changing permission
Chown-r YMq: indicates the YMQ path chmod -r 777 pathCopy the code
Start up again,
Foreground startup command:./elasticsearch
Run./ elasticSearch -d in the background
(6) Verification
After successful startup, access 127.0.0.1:9200 to verify:
The singleton installation is successful.
(7) Stop elasticSearch
If it is foreground start, just press CTRL + C to stop it.
In the background, perform the following operations.
Install elasticSearch -head
For elasticSearch, you need to download a plugin to manage elasticSearch. This plugin needs to install nodeJS. Please refer to my other article, Installing NodeJs-v8.11.1 for CentOS7.
(1) Check whether the nodeJS and NPM version are installed successfully.
Nodejs is the required environment and NPM is the package manager.
Failed node environment friend please to install (http://www.runoob.com/nodejs/nodejs-install-setup.html), NPM installation node will bring their own, only the node after the installation is complete, look at the NPM version, Upgrade to the latest version whenever possible.
(2) to find we need lot of plug-in elasticsearch – head (https://github.com/mobz/elasticsearch-head) to download:
download
The download is complete
(3) Decompress
Command: unzip master.zip
This is because unzip is not installed.
To decompress again:
Decompression is complete.
(4) Install dependency packages
Go to the unzip project: CD ElasticSearch -head-master
Install dependency package: NPM install
Ash, I think, made an error
So let’s solve that
Ls command:
To delete the dependency packages, run the rm -rf node_modules command
Install a plugin: NPM install [email protected] –ignore-scripts
Then install the dependencies with the command: NPM install
OK
(5)
Port 9100 is enabled by default. You need to enable this plug-in.
To check whether firewall ports are enabled, run the firewall-cmd –list-port command
Enable port 9100: firewall-cmd –zone=public –add-port=9100/ TCP –permanent
Restart the firewall: firewall-cmd –reload
Start command: NPM run start
Successfully started. If necessary, press CTRL + C to stop.
So let’s open it up in the browser
OK.
Pseudo-cluster installation
In the case of successful standalone installation, cluster/pseudo cluster installation is relatively simple, mainly configuration files.
Configuring the Active Node
Go to the config directory of Elasticsearch
Edit elasticSearch. yml: vi elasticSearch. yml
configuration
# the cluster name
cluster.name: elasticsearch
# the node name
node.name: master
Network. The host: 0.0.0.0
http.port: 9200
Save and exit.
Configuring slave Nodes
Change the name of your own ElasticSearch to the directory above where you installed it
Duplicate elasticSearch and give it a new name
Command: cp -r New name of your ElasticSearch directory
Authorize both folders to your users separately
Command: sudo chown -r username folder
Go to the first newly copied folder, go to config folder, and edit ElasticSearch.yml
Command: vi elasticsearch.yml
Change the node name and port number
Note that there is a property that needs to be configured
# Automatic address discovery
Discovery. Zen. Ping. Unicast. Hosts: [” 127.0.0.1 “]
Save and exit.
Repeat the previous steps to change the port number (different port numbers) and node name of the configuration file in the other newly copied directory.
Firewall open port
The firewall opens ports 8200 and 8300.
Start the
Start each node and view it in a browser.
This article is a personal installation process, if there is any error, please criticize and correct.