Install elasticsearch 8.0 for Ubuntu X and Kibana

Now it's really a batch of rolls (please don't learn, I can't keep up 必必必), Just after installing rabbitmq, my friend asked me to install an es service So I started writing this article again
Up to now, the latest version of the official website is 8.2
Because I want to learn and simulate the real production environment, I also need to use cluster
Here I have prepared three servers Its configuration is as follows

{
    vCPU: 3,
     RAM: 16G,
     ROM: 100G,
      IP: ["192.168.2.29", "192.168.2.30"]
}
Install ElasticSearch
  • After configuring two servers in ESXI, wait for a few seconds and enter the system after successful installation
  • First, configure SSH Remote Access and update the system to the latest according to the normal operation, and no methods and commands are written here
  • After waiting for a few seconds, the system update is completed, and then we open it Installation of Ubuntu operating system on ElasticSearch official website
  • After logging in to the server with XShell, send the same instruction to the server at the same time To install the elastic search program on multiple servers at the same time
  • First, import the PGP Key of ElasticSearch
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
  • Then we need to install a tool. If it has been installed, you can skip this step Generally, there is no problem executing it again
sudo apt-get install apt-transport-https
  • Wait a few seconds for each server to be installed successfully and save the source file of elasticsearch
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
  • Then it is the last step of installation. You can directly execute the update and installation commands
sudo apt-get update && sudo apt-get install elasticsearch
  • Wait a few seconds for the installation to succeed
Configure ElasticSearch
  • After the installation is successful, we should not start in a hurry. Because it is a cluster, we must configure some things
  • Here, we first open the configuration file of elasticsearch
sudo nano /etc/elasticsearch/elasticsearch.yml
  • After opening, we modify some parameters
# Cluster name (it's hard to choose a name according to your own needs)
cluster.name: joes-elasticsearch-cluster
# Node name (each node is different. Adjust the name of each server according to the actual situation)
node.name: node-1
# path.data/path.log is the log and data folder directory of es. I generally prefer the default without modification. Of course, it can also be adjusted according to my own situation
# I also use the default memory part and do not adjust it. If it needs to be adjusted, it is recommended to allocate at least half of the available memory of the machine to ES
# For the network binding part, the local IP is generally used, but we generally use 0.0.0.0 for this kind of thing
network.host: 0.0.0.0
# Bind the port and use the default
http.port: 9200
# In the service discovery part, we can write as many IP addresses as we have machines, and we can also use the form of domain names As for the communication port, we can use the default one without manual configuration
discovery.seed_hosts: ["192.168.2.29", "192.168.2.30"]
# Initialize the node of the master node Here we add all our three machines, which can be adjusted according to our actual situation
# The node that initializes the master node by default
cluster.initial_master_nodes: ["node-1", "node-2"]
#
transport.host: 192.168.2.29
# For other information, the default is temporarily used
  • After saving and exiting editing, the ES service of the first server can be started
  • After starting the service, you will be prompted and given a token. If the token expires or you forget the token, you can use the following command to regenerate it
sudo bin/elasticsearch-create-enrollment-token -s node
  • Then before the second server starts Execute the following command Be sure to execute before starting, but not after
sudo /usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token>
  • After joining the cluster, the ES service can be started normally through the following command
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
Install Kibana
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
  • Then we need to install a tool. If it has been installed, you can skip this step Generally, there is no problem executing it again
sudo apt-get install apt-transport-https
  • Wait a few seconds for each server to be installed successfully and save the source file of elasticsearch
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
  • These steps are the same as before. Since we are installing on 29 this server, we skip them. If they are deployed separately, they need to be executed
  • Then we execute the installation command
sudo apt update && sudo apt install kibana -y
  • After the installation is successful, don't start in a hurry and adjust the configuration file first
sudo nano /etc/kibana/kibana.yml
  • Replace the bound ip with 0.0.0.0
server.port: 5601
server.host: 0.0.0.0
i18n.locale: "zh-CN"
  • After saving and exiting, start the service
sudo systemctl enable kibana.service
sudo systemctl start kibana.service
sudo journalctl -u kibana.service
  • The information output according to the last command will have a url, as shown in the figure
  • Open this link in the browser and enter the token given after starting ES
  • Then according to sudo systemctl status kibana The command "service" will prompt a verification code Enter kibana

Posted by phpstuck on Fri, 15 Apr 2022 08:54:18 +0930