From 8003fc8215849075afade2261da28b2753aa4748 Mon Sep 17 00:00:00 2001 From: mustafa Date: Wed, 9 Apr 2025 09:56:53 +0330 Subject: [PATCH] 2 --- .../Installing and Configuring and Modules.md | 132 +++++++++ .../ElasticDump backup&restore.md | 66 +++++ .../Snapshot and Restore.md | 15 + .../backup and remote restore.ml | 148 ++++++++++ .../backup restore snapshot/backup&restore.md | 99 +++++++ .../enable security.md | 119 ++++++++ .../fa-backup and remote Restore.md | 187 +++++++++++++ .../install-uninstall-config.md | 257 ++++++++++++++++++ .../simple backup and restore.md | 86 ++++++ 9 files changed, 1109 insertions(+) create mode 100644 Kibana/Installing and Configuring and Modules.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/ElasticDump backup&restore.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/Snapshot and Restore.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/backup and remote restore.ml create mode 100644 The Elasticsearch Documentation/backup restore snapshot/backup&restore.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/enable security.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/fa-backup and remote Restore.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/install-uninstall-config.md create mode 100644 The Elasticsearch Documentation/backup restore snapshot/simple backup and restore.md diff --git a/Kibana/Installing and Configuring and Modules.md b/Kibana/Installing and Configuring and Modules.md new file mode 100644 index 0000000..33a2527 --- /dev/null +++ b/Kibana/Installing and Configuring and Modules.md @@ -0,0 +1,132 @@ +

بسم الله الرحمن الرحیم

+ +##

نصب و پیکربندی Kibana Dashboard

## + +

طبق مستندات رسمی، کیبانا را فقط پس از نصب Elasticsearch باید نصب کنید. نصب به این ترتیب تضمین می کند که اجزایی که هر محصول به آنها وابسته است به درستی در جای خود قرار دارند. +
+ از آنجایی که قبلاً منبع بسته Elastic را در مرحله قبل اضافه کرده اید، می توانید اجزای باقی مانده از Elastic Stack را با استفاده از apt نصب کنید: +

+ +```r +sudo apt install kibana +``` + +

سپس سرویس Kibana را فعال و راه اندازی کنید:

+ +```r +sudo systemctl enable kibana +sudo systemctl start kibana +``` + +

+از آنجایی که کیبانا طوری پیکربندی شده است که فقط در لوکال هاست گوش دهد، باید یک پروکسی معکوس راه اندازی کنیم تا اجازه دسترسی خارجی به آن را بدهیم. ما برای این منظور از Nginx استفاده خواهیم کرد که قبلاً باید روی سرور شما نصب شده باشد. +
+ ابتدا از دستور openssl برای ایجاد یک کاربر مدیریتی Kibana استفاده کنید که از آن برای دسترسی به رابط وب کیبانا استفاده خواهید کرد. به عنوان مثال، نام این حساب را kibanaadmin می‌گذاریم، اما برای اطمینان از امنیت بیشتر، توصیه می‌کنیم یک نام غیر استاندارد برای کاربر خود انتخاب کنید که حدس زدن آن دشوار باشد. +
+ دستور زیر کاربر و رمز عبور کیبانا را ایجاد کرده و در فایل htpasswd.users ذخیره می کند. شما Nginx را طوری پیکربندی می‌کنید که به این نام کاربری و رمز عبور نیاز داشته باشد و این فایل را لحظه‌ای بخوانید: +

+ +```r +echo "kibanaadmin:`openssl passwd -apr1`" | sudo tee -a /etc/nginx/htpasswd.users +``` + +

+رمز عبور را وارد کنید و آن را تأیید کنید. این ورود را به خاطر بسپارید یا توجه داشته باشید، زیرا برای دسترسی به رابط وب کیبانا به آن نیاز دارید. +
+ سپس یک فایل بلوک سرور Nginx ایجاد می کنیم. به عنوان مثال، ما به این فایل با عنوان your_domain اشاره می کنیم، اگرچه ممکن است برای شما مفید باشد که نام توصیفی تری برای فایل خود قرار دهید. به عنوان مثال، اگر یک رکورد FQDN و DNS برای این سرور تنظیم کرده اید، می توانید این فایل را به نام FQDN خود نام گذاری کنید. +
+ با استفاده از nano یا ویرایشگر متن دلخواه خود، فایل بلوک سرور Nginx را ایجاد کنید: +

+ +```r +sudo nano /etc/nginx/sites-available/your_domain +``` + +

+بلوک کد زیر را به فایل اضافه کنید، حتما your_domain را برای مطابقت با FQDN یا آدرس IP عمومی سرور خود به روز کنید. این کد Nginx را پیکربندی می کند تا ترافیک HTTP سرور شما را به برنامه Kibana هدایت کند که در localhost:5601 گوش می دهد. علاوه بر این، Nginx را برای خواندن فایل htpasswd.users و نیاز به احراز هویت اولیه پیکربندی می کند. +
+ توجه داشته باشید که اگر آموزش پیش نیاز Nginx را تا انتها دنبال کرده باشید، ممکن است قبلاً این فایل را ایجاد کرده باشید و آن را با محتوایی پر کرده باشید. در این صورت، قبل از افزودن موارد زیر، تمام محتوای موجود در فایل را حذف کنید: +

+ +```r +/etc/nginx/sites-available/your_domain +``` + +

+ +server { + listen 80; +
+ server_name localhost; +
+ auth_basic "Restricted Access"; + auth_basic_user_file /etc/nginx/htpasswd.users; +
+ location / { + proxy_pass http://localhost:5601; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } +} +
+

+ +

+فایل را با CTRL+Oذخیره و با CTRL+X ببندید. +
+ در مرحله بعد، پیکربندی جدید را با ایجاد یک پیوند نمادین به دایرکتوری فعال شده توسط سایت ها فعال کنید. اگر قبلاً یک فایل بلوک سرور با همین نام در پیش نیاز Nginx ایجاد کرده اید، نیازی به اجرای این دستور ندارید: +

+ +```r +sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/your_domain +``` + +

+سپس پیکربندی را برای خطاهای متنی، بررسی کنید: +

+ +```r +sudo nginx -t +``` + +

+اگر خطایی در خروجی شما گزارش شد، به عقب برگردید و دوباره بررسی کنید که محتوایی که در فایل پیکربندی خود قرار داده اید به درستی + اضافه شده است. هنگامی که سینتکس در خروجی OK است، ادامه دهید و سرویس Nginx را مجددا راه اندازی کنید: +

+ +```r +sudo systemctl reload nginx +``` + +

+اگر راهنمای اولیه راه اندازی سرور را دنبال کردید، باید فایروال UFW را فعال کنید. برای اجازه دادن به اتصالات به Nginx، می‌توانیم قوانین را با تایپ کردن زیر تنظیم کنیم: +

+ +```r +sudo ufw allow 'Nginx Full' +``` + +

+توجه: اگر آموزش پیش نیاز Nginx را دنبال کردید، ممکن است یک قانون UFW ایجاد کرده باشید که به نمایه Nginx HTTP از طریق فایروال اجازه می دهد. از آنجایی که نمایه کامل Nginx امکان ترافیک HTTP و HTTPS را از طریق فایروال فراهم می کند، می توانید با خیال راحت قانونی را که در آموزش پیش نیاز ایجاد کرده اید حذف کنید. این کار را با دستور زیر انجام دهید: +

+ +```r +sudo ufw delete allow 'Nginx HTTP' +``` + +

+Kibana اکنون از طریق FQDN یا آدرس IP عمومی سرور Elastic Stack شما قابل دسترسی است. می‌توانید صفحه وضعیت سرور کیبانا را با رفتن به آدرس زیر و وارد کردن اطلاعات کاربری خود در صورت درخواست بررسی کنید: +

+ +```r +http://your_domain/status +``` + +

+این صفحه وضعیت اطلاعات مربوط به استفاده از منابع سرور را نمایش می دهد و افزونه های نصب شده را فهرست می کند. +

+ +

صلوات

\ No newline at end of file diff --git a/The Elasticsearch Documentation/backup restore snapshot/ElasticDump backup&restore.md b/The Elasticsearch Documentation/backup restore snapshot/ElasticDump backup&restore.md new file mode 100644 index 0000000..3651f57 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/ElasticDump backup&restore.md @@ -0,0 +1,66 @@ +******************************** بسم الله الرحمن الرحیم ******************************** + +# 1-نصب # + +> Install Node.js + NPM + +```r +sudo apt install nodejs npm +``` +> Install helper package to get latest Node.js + NPM versions + +```r +sudo npm install n -g +``` +> Install Elasticdump globally on your local machine + +```r +sudo npm install elasticdump -g +``` + +> show version + +```r +sudo elasticdump --version +``` + +> for example: 6.71.0 + +# 2- پشتیبان گیری # + +> make backup dir + +```r +sudo mkdir /home/backup +``` +> with out auth + +```r +sudo elasticdump --input=http://127.0.0.1:6900/index --output=/home/backup/change_logindex.json --type=data +``` + +> with auth + +```r +sudo elasticdump --input=https://username:password@127.0.0.1:6900/index --output=/home/backup/change_logindex.json --type=data +``` + + ## می تواند بگیرد --type مقادیری که ## + +>default: data, options:(index, settings, analyzer, data, mapping, policy, alias, template, component_template, index_template) + + +# 3- بازیابی # +> with out auth + +```r +sudo elasticdump --input=/home/backup/change_logindex.json --output=http://127.0.0.1:6900/index --type=data +``` + +> with auth + +```r +elasticdump --input=/home/backup/change_logindex.json --output=https://username:password@127.0.0.1:6900/index --type=data +``` + +******************************** در پناه حق ******************************** diff --git a/The Elasticsearch Documentation/backup restore snapshot/Snapshot and Restore.md b/The Elasticsearch Documentation/backup restore snapshot/Snapshot and Restore.md new file mode 100644 index 0000000..acc36e0 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/Snapshot and Restore.md @@ -0,0 +1,15 @@ +بسم الله الرحمن الرحیم + +# Go to in kibana # +1: Go To "Snapshot and Restore" +2: Start by registering a repository "Register repository" +3: select "shared file system" +4: set "Repository name": "for example name1" +5: click "next" +6: set path.repo example: "/home/backup" +* نکته مهم: +> !اگر خطا بدهد +> باید در انتهای فایل وای-ام-ال الاستیک ایجاد شود path.repo +7:click "Register" +............. ادامه دارد + diff --git a/The Elasticsearch Documentation/backup restore snapshot/backup and remote restore.ml b/The Elasticsearch Documentation/backup restore snapshot/backup and remote restore.ml new file mode 100644 index 0000000..09c2d44 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/backup and remote restore.ml @@ -0,0 +1,148 @@ +Migrating data + +If you want to move your existing Elasticsearch data into your new infrastructure, check out the migration options. You’ll find instructions to guide you through: + + Migrating data from its original source + Reindexing data from a remote Elasticsearch cluster + Restoring data from a snapshot + Migrating internal Elasticsearch indices + Migrating through remote reindex + +Migrate your Elasticsearch data + +You might have switched to Elasticsearch Service for any number of reasons and you’re likely wondering how to get your existing Elasticsearch data into your new infrastructure. Along with easily creating as many new deployments with Elasticsearch clusters that you need, you have several options for moving your data over. Choose the option that works best for you: + + Index your data from the original source, which is the simplest method and provides the greatest flexibility for the Elasticsearch version and ingestion method. + Reindex from a remote cluster, which rebuilds the index from scratch. + Restore from a snapshot, which copies the existing indices. + +One of the many advantages of Elasticsearch Service is that you can spin up a deployment quickly, try out something, and then delete it if you don’t like it. This flexibility provides the freedom to experiment while your existing production cluster continues to work. +Before you begin + +Depending on which option that you choose, you might have limitations or need to do some preparation beforehand. + +Indexing from the source + The new cluster must be the same size as your old one, or larger, to accommodate the data. +Reindex from a remote cluster + The new cluster must be the same size as your old one, or larger, to accommodate the data. Depending on your security settings for your old cluster, you might need to temporarily allow TCP traffic on port 9243 for this procedure. + +If your cluster is self-managed with a self-signed certificate, you can follow this step-by-step migration guide. + +Restore from a snapshot + The new cluster must be the same size as your old one, or larger, to accommodate the data. The new cluster must also be an Elasticsearch version that is compatible with the old cluster (check Elasticsearch snapshot version compatibility for details). If you have not already done so, you will need to set up snapshots for your old cluster using a repository that can be accessed from the new cluster. +Migrating internal Elasticsearch indices + + If you are migrating internal Elasticsearch indices from another cluster, specifically the .kibana index or the .security index, there are two options: + + Use the steps on this page to reindex the internal indices from a remote cluster. The steps for reindexing internal indices and regular, data indices are the same. + Check Migrating internal indices to restore the internal Elasticsearch indices from a snapshot. + +Before you migrate your Elasticsearch data, define your index mappings on the new cluster. Index mappings are unable to migrate during reindex operations. +Index from the source + +If you still have access to the original data source, outside of your old Elasticsearch cluster, you can load the data from there. This might be the simplest option, allowing you to choose the Elasticsearch version and take advantage of the latest features. You have the option to use any ingestion method that you want—​Logstash, Beats, the Elasticsearch clients, or whatever works best for you. + +If the original source isn’t available or has other issues that make it non-viable, there are still two more migration options, getting the data from a remote cluster or restoring from a snapshot. +Reindex from a remote cluster + +Through the Elasticsearch reindex API, available in version 5.x and later, you can connect your new Elasticsearch Service deployment remotely to your old Elasticsearch cluster. This pulls the data from your old cluster and indexes it into your new one. Reindexing essentially rebuilds the index from scratch and it can be more resource intensive to run. + + Log in to the Elasticsearch Service Console. + Select a deployment or create one. + + If the old Elasticsearch cluster is on a remote host (any type of host accessible over the internet), add an Elasticsearch reindex.remote.whitelist user setting: + From your deployment menu, go to the Edit page. + In the Elasticsearch section, select Manage user settings and extensions. For deployments with existing user settings, you may have to expand the Edit elasticsearch.yml caret for each node type instead. + + Add the following user setting: + + reindex.remote.whitelist: [REMOTE_HOST:PORT] + + Where REMOTE_HOST and PORT are the endpoint of the Elasticsearch cluster that you are reindexing from, without the https:// prefix. The setting accepts domains of ["\*.io:*", "\*.com:*"] by default. For example: + + reindex.remote.whitelist: [81693ca13302469c8cbca193625c941c.us-east-1.aws.found.io:9243] + + If your remote endpoint is not covered by the default allowlist settings, adjust the allowlist settings then add the remote endpoint to the whitelist. + Select Save changes. + From the API Console or in the Kibana Console app, create the destination index on Elasticsearch Service. + + Copy the index from the remote cluster: + + POST _reindex + { + "source": { + "remote": { + "host": "https://REMOTE_ELASTICSEARCH_ENDPOINT:PORT", + "username": "USER", + "password": "PASSWORD" + }, + "index": "INDEX_NAME", + "query": { + "match_all": {} + } + }, + "dest": { + "index": "INDEX_NAME" + } + } + + Verify that the new index is present: + + GET INDEX-NAME/_search?pretty + + You can remove the reindex.remote.whitelist user setting that you added previously. + +Restore from a snapshot + +If you cannot connect to a remote index for whatever reason, such as if it’s in a non-working state, you can try restoring from the most recent working snapshot. + + On your old Elasticsearch cluster, choose an option to get the name of your snapshot repository bucket: + + GET /_snapshot + GET /_snapshot/_all + + Get the snapshot name: + + GET /_snapshot/NEW-REPOSITORY-NAME/_all + + The output for each entry provides a "snapshot": value which is the snapshot name. + + { + "snapshots": [ + { + "snapshot": "scheduled-1527616008-instance-0000000004", + ... + }, + ... + ] + } + + From the Elasticsearch Service Console of the new Elasticsearch cluster, add the snapshot repository. For details, check our guidelines for Amazon Web Services (AWS) Storage, Google Cloud Storage (GCS), or Azure Blob Storage. + + If you’re migrating searchable snapshots, the repository name must be identical in the source and destination clusters. + + Start the Restore process. + + For deployments with Elastic Stack version 7.2 and higher: + Open Kibana and go to Management > Snapshot and Restore. + Under the Snapshots tab, you can find the available snapshots from your newly added snapshot repository. Select any snapshot to view its details, and from there you can choose to restore it. + Select Restore. + Select the indices you wish to restore. + Configure any additional index settings. + Select Restore snapshot to begin the process. + + For deployments with Elastic Stack version 7.1 and lower: + + Open the API Console or the Kibana Console app of the new Elasticsearch cluster and restore the snapshot: + + POST /_snapshot/REPOSITORY_NAME/SNAPSHOT_NAME/_restore?pretty + { + "indices": "*", + "ignore_unavailable": true, + "include_global_state": true + } + + Verify that the new index is restored in your Elasticsearch Service deployment with this query: + + GET INDEX_NAME/_search?pretty + diff --git a/The Elasticsearch Documentation/backup restore snapshot/backup&restore.md b/The Elasticsearch Documentation/backup restore snapshot/backup&restore.md new file mode 100644 index 0000000..449e04d --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/backup&restore.md @@ -0,0 +1,99 @@ + Elasticsearch snapshot and restore + +If you opt for Elasticsearch snapshot and restore, each time you take a snapshot, the backups are done incrementally. Meaning, only the changes that have occurred between two backups (differentials) are stored. The files are saved in the folder labeled as repo in Elasticsearch configuration. Should you prefer to save files on some other location, there are numerous plugins for S3, Azure and similar, that can come in handy. + +In our example, we will backup to our local folder. Also, we have used Ubuntu machine, yet all the steps are still applicable should you prefer some other Linux distro or Windows. + +1. Prepare the filesystem + + >mkdir /home/backup + chown elasticsearch:elasticsearch /home/backup + +2. Add repo to elasticsearch.yml file + + >echo 'path.repo: ["/home/backup"]'>>/etc/elasticsearch/elasticsearch.yml + systemctl restart elasticsearch + +3. After the preparations on the filesystem side we have just made, now we can enable repo in Elasticsearch. All commands are executed directly on the Elasticseach host, however you can use Kibana or Postman if this is too bulky for you. + + >curl -XPUT -H "Content-Type: application/json" 'http://localhost:9200/_snapshot/backup' -d '{ + "type": "fs", + "settings": { + "location": "/home/backup", + "compress": true + } + }' + +4. Let's create our first snapshot + +> curl -XPUT-H "Content-Type: application/json" 'http://localhost:9200/_snapshot/backup/snapshot1' -d '{ "indices": "netflow*", "include_global_state": true }' + +include_global_state parameter is added because we want to backup and restore index mapping along with indices. + +The snapshotting process can be monitored in various APIs while it is in progress and upon completion: + +curl –XGET localhost:9200/_cat/snapshots/backup?v +curl –XGET localhost:9200_snapshot/_status +curl –XGET localhost:9200/_snapshot/backup/_current + +Once we have completed the backup phase, we can head onto recovery or restore. On the target machine, you need to create folders and execute all the commands until systemctl restart elasticsearch from the aforementioned steps 1 and 2 . Then copy or rsync the entire folder to the new machine. Use the following set of commands to restore: + +curl-XPOST -H "Content-Type: application/json" +'http://localhost:9200/_snapshot/backup/snapshot1/_restore' -d ' { "indices": "netflow*" , "include_global_state":true" }' + +Here we are restoring all the indices, starting with NetFlow and also including mappings. This process can take a lot of time sometimes, depending on your machine. You can monitor the status of every index with _recovery API. Moreover, there are some optimizations available that can speed up the restore process: + +I Switch to default refresh interval with: "ignore_index_settings": [ "index.refresh_interval" ] + +II Use the dynamic setting that limits inbound and outbound recovery traffic, and is set to 40mb by default: indices.recovery.max_bytes_per_sec + +There are also other, expert recovery settings available, but you have to be really careful not to overload your Elasticsearch cluster, which can lead to OOM and crashing. + + +Elasticdump + +Elasticdump is a nodeJS application than can easily be downloaded and used for backup and recovery. In this example we will show how to apply it. + +1. Download and install LTS version of nodeJS + +curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - +sudo apt-get install -y nodejs + +2. Download and install elasticdump globally +sudo npm install elasticdump -g + + Elasticdump is a command that is executed on Elaticsearch node. + +3. Backup the template of NetFlow indices +elasticdump --input=http://localhost:9200/netflow --output=templates.json --type=template + +4. Use multielasticdump to export all indices, as well as their mapping,settings and template +multielasticdump --direction=dump --input=http://localhost:9200 --output=/home/backup + +5. Copy the whole folder and template.json file to the new machine. + +The restore process is basically just reversing the order of –input and –output in backup commands written above in steps 3 and 4: + +elasticdump --input=templates.json --output=http://localhost:9200/netflow --type=template + +multielasticdump --direction=load --input=/home/backup --output=http://localhost:9200 + +Elasticdump and multielasticdump can be really slow processes too, therefore here are some tips and tricks on how to get faster export/import: + +I Use flag that defines the number of objects to be moved in batch per operation. Default is 100, although depending on your RAM you can set it to 1000 or even 10000: -limit + +II Apply flag that adds in-flight compression of the JSON files to avoid gzip or zstd commands afterward: -fsCompress + +III Also, there is a specific flag used to disable index refresh. It improves index speed and has lower hardware requirements. However, recently indexed data might not be collected. This flag is usually recommended when it comes to big data indexing, where speed is more important than the data novelty: -noRefresh + +IV Useful can be the flag that determines how many forks should be run simultaneously, and this number is by default set to correspond the number of CPUs: -parallel + +V Last but not least, you may use the flag that designates a type that will be ignored from the dump/load. Six options are supported: data,mapping,analyzer,alias,settings and template. Multi-type support is possible, however then each type must be separated with a comma: -ignoreType + +If these fixes are not providing satisfying results for you, there is one dirty fix, however, it is not recommended on low RAM systems. This setting configures max result windows and the number of objects limit that are going be retrieved from Elasticsearch. After applying the described setting to all indices, you should be able to export and import with higher speed although the cost would be higher RAM consumption. + +curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{ +"index.max_result_window" : "100000" +}' + +Using Elasticdump with all the mentioned flags can sometimes crash your Elasticsearch instance if you don't have enough RAM, so you need to be careful when exporting data this way. \ No newline at end of file diff --git a/The Elasticsearch Documentation/backup restore snapshot/enable security.md b/The Elasticsearch Documentation/backup restore snapshot/enable security.md new file mode 100644 index 0000000..c668921 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/enable security.md @@ -0,0 +1,119 @@ +بسم الله الرحمن الرحیم + +Enable Elasticsearch security features +edit + +Enabling the Elasticsearch security features provides basic authentication so that you can run a local cluster with username and password authentication. + +* On every node in your cluster, stop both Kibana and Elasticsearch if they are running. + +* On every node in your cluster, add the xpack.security.enabled setting to the $ES_PATH_CONF/elasticsearch.yml file and set the value to true: +```r +nano /etc/elasticsearch/elasticsearch.yml +``` + +```r + xpack.security.enabled: true +``` + + The $ES_PATH_CONF variable is the path for the Elasticsearch configuration files. If you installed Elasticsearch using archive distributions (zip or tar.gz), the variable defaults to $ES_HOME/config. If you used package distributions (Debian or RPM), the variable defaults to /etc/elasticsearch. + + If your cluster has a single node, add the discovery.type setting in the $ES_PATH_CONF/elasticsearch.yml file and set the value to single-node. This setting ensures that your node does not inadvertently connect to other clusters that might be running on your network. + +```r + discovery.type: single-node +``` + +Set passwords for built-in users +edit + +To communicate with your cluster, you must configure a password for the elastic and kibana_system built-in users. Unless you enable anonymous access (not recommended), all requests that don’t include credentials are rejected. + +You only need to set passwords for the elastic and kibana_system users when enabling minimal or basic security. + + On every node in your cluster, start Elasticsearch. For example, if you installed Elasticsearch with a .tar.gz package, run the following command from the ES_HOME directory: +```r + cd /usr/share/elasticsearch +``` + +```r + ./bin/elasticsearch +``` + + On any node in your cluster, open another terminal window and set the password for the elastic built-in user by running the elasticsearch-reset-password utility. This command resets the password to an auto-generated value. + +```r + ./bin/elasticsearch-reset-password -u elastic +``` + + If you want to set the password to a specific value, run the command with the interactive (-i) parameter. + +```r + ./bin/elasticsearch-reset-password -i -u elastic +``` + + Set the password for the kibana_system built-in user. + +```r + ./bin/elasticsearch-reset-password -u kibana_system +``` + + Save the new passwords. In the next step, you’ll add the the password for the kibana_system user to Kibana. + +Next: Configure Kibana to connect to Elasticsearch with a password +Configure Kibana to connect to Elasticsearch with a password +edit + +When the Elasticsearch security features are enabled, users must log in to Kibana with a valid username and password. + +You’ll configure Kibana to use the built-in kibana_system user and the password that you created earlier. Kibana performs some background tasks that require use of the kibana_system user. + +This account is not meant for individual users and does not have permission to log in to Kibana from a browser. Instead, you’ll log in to Kibana as the elastic superuser. + +Add the elasticsearch.username setting to the KIB_PATH_CONF/kibana.yml file and set the value to the kibana_system user: +```r +nano /etc/kibana/kibana.yml +``` + +```r + elasticsearch.username: "kibana_system" +``` + + The KIB_PATH_CONF variable is the path for the Kibana configuration files. If you installed Kibana using archive distributions (zip or tar.gz), the variable defaults to KIB_HOME/config. If you used package distributions (Debian or RPM), the variable defaults to /etc/kibana. + + From the directory where you installed Kibana, run the following commands to create the Kibana keystore and add the secure settings: + + Create the Kibana keystore: +```r + cd /usr/share/kibana +``` + + +```r + ./bin/kibana-keystore create +``` + +Add the password for the kibana_system user to the Kibana keystore: +```r + ./bin/kibana-keystore add elasticsearch.password +``` + +```r +nano /etc/kibana/kibana.yml +``` + +```r + elasticsearch.username: "kibana_system" + elasticsearch.password: "************" +``` + +When prompted, enter the password for the kibana_system user. + + Restart Kibana. For example, if you installed Kibana with a .tar.gz package, run the following command from the Kibana directory: + +```r + ./bin/kibana +``` + Log in to Kibana as the elastic user. Use this superuser account to manage spaces, create new users, and assign roles. If you’re running Kibana locally, go to http://localhost:5601 to view the login page. + +صلوات diff --git a/The Elasticsearch Documentation/backup restore snapshot/fa-backup and remote Restore.md b/The Elasticsearch Documentation/backup restore snapshot/fa-backup and remote Restore.md new file mode 100644 index 0000000..60f6a2d --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/fa-backup and remote Restore.md @@ -0,0 +1,187 @@ +

بسم الله الرحمن الرحیم

+ +
+ + انتقال داده ها + + اگر می خواهید داده های Elasticsearch موجود خود را به زیرساخت جدید خود منتقل کنید، گزینه های مهاجرت را بررسی کنید. دستورالعمل هایی برای راهنمایی شما در این زمینه پیدا خواهید کرد: + + انتقال داده ها از منبع اصلی + Reindexing داده ها از یک cluster Elasticsearch راه دور + بازیابی اطلاعات از یک snapshot + مهاجرت شاخص های داخلی Elasticsearch + مهاجرت از طریق فهرست مجدد از راه دور + + داده های Elasticsearch خود را انتقال دهید + + ممکن است به دلایلی به سرویس Elasticsearch تغییر داده باشید و احتمالاً از خود می‌پرسید که چگونه داده‌های Elasticsearch موجود خود را به زیرساخت جدید خود وارد کنید. در کنار ایجاد آسان تعداد زیادی استقرار جدید با cluster های Elasticsearch که نیاز دارید، چندین گزینه برای انتقال داده های خود دارید. بهترین گزینه برای خود را انتخاب کنید: + + داده های خود را از منبع اصلی فهرست کنید، که ساده ترین روش است و بیشترین انعطاف را برای نسخه Elasticsearch و روش مصرف فراهم می کند. + index مجدد از یک cluster راه دور، که index را از ابتدا بازسازی می کند. + بازیابی از یک snapshot، که شاخص های موجود را کپی می کند. + + یکی از مزایای بسیاری از سرویس Elasticsearch این است که می توانید یک استقرار را به سرعت چرخش کنید، چیزی را امتحان کنید و سپس اگر دوست ندارید آن را حذف کنید. این انعطاف‌پذیری آزادی آزمایش را در زمانی که cluster تولید موجود شما به کار خود ادامه می‌دهد، فراهم می‌کند. + قبل از اینکه شروع کنی + + بسته به اینکه کدام گزینه را انتخاب می‌کنید، ممکن است محدودیت‌هایی داشته باشید یا نیاز به انجام مقدماتی از قبل داشته باشید. + + Indexing from the source + + cluster جدید باید به اندازه cluster قبلی شما یا بزرگتر باشد تا داده ها را در خود جای دهد. + + Reindex from a remote cluster + + cluster جدید باید به اندازه cluster قبلی شما یا بزرگتر باشد تا داده ها را در خود جای دهد. بسته به تنظیمات امنیتی خود برای + +خوشه جدید باید به اندازه خوشه قبلی شما یا بزرگتر باشد تا داده ها را در خود جای دهد. بسته به تنظیمات امنیتی خود برای خوشه قدیمی، ممکن است لازم باشد به طور موقت به ترافیک TCP در پورت 9243 برای این روش اجازه دهید. + +اگر cluster شما با گواهینامه خودامضا مدیریت می شود، می توانید این راهنمای مهاجرت گام به گام را دنبال کنید. + + بازیابی از یک snapshot + cluster جدید باید به اندازه cluster قبلی شما یا بزرگتر باشد تا داده ها را در خود جای دهد. cluster جدید همچنین باید یک نسخه Elasticsearch باشد که با cluster قدیمی سازگار باشد (برای جزئیات، سازگاری نسخه فوری Elasticsearch را بررسی کنید). اگر قبلاً این کار را انجام نداده اید، باید با استفاده از یک مخزن که از cluster جدید قابل دسترسی است، عکس های فوری برای cluster قدیمی خود تنظیم کنید. + مهاجرت شاخص های داخلی Elasticsearch + + اگر شاخص‌های داخلی Elasticsearch را از یک cluster دیگر، به‌ویژه از فهرست kibana. یا شاخص .security مهاجرت می‌کنید، دو گزینه وجود دارد: + + از مراحل این صفحه برای فهرست مجدد شاخص های داخلی از یک cluster راه دور استفاده کنید. مراحل نمایه سازی مجدد شاخص های داخلی و شاخص های داده ای معمولی یکسان است. + برای بازیابی شاخص‌های داخلی Elasticsearch از یک snapshot، مهاجرت شاخص‌های داخلی را علامت بزنید. + + قبل از اینکه داده های Elasticsearch خود را انتقال دهید، نگاشت فهرست خود را در cluster جدید تعریف کنید. نگاشتهای فهرست نمی توانند در طول عملیات فهرست مجدد منتقل شوند. + نمایه از منبع + + اگر هنوز به منبع داده اصلی دسترسی دارید، خارج از cluster قدیمی Elasticsearch، می توانید داده ها را از آنجا بارگیری کنید. این ممکن است ساده‌ترین گزینه باشد که به شما امکان می‌دهد نسخه Elasticsearch را انتخاب کنید و از آخرین ویژگی‌ها بهره ببرید. شما می توانید از هر روشی که می خواهید استفاده کنید - Logstash، Beats، کلاینت های Elasticsearch یا هر چیزی که برای شما بهتر است. + + اگر منبع اصلی در دسترس نیست یا مشکلات دیگری دارد که آن را غیرقابل اجرا می‌کند، هنوز دو گزینه انتقال دیگر وجود دارد، دریافت داده‌ها از یک cluster راه دور یا بازیابی از یک snapshot. + +فهرست مجدد از یک cluster راه دور + + از طریق Elasticsearch reindex API، موجود در نسخه 5.x و جدیدتر، می توانید استقرار سرویس Elasticsearch جدید خود را از راه دور به cluster Elasticsearch قدیمی خود متصل کنید. این داده ها را از cluster قدیمی شما می کشد و آن را در cluster جدید شما فهرست می کند. ایندکس مجدد اساساً ایندکس را از ابتدا بازسازی می کند و اجرای آن می تواند منابع بیشتری داشته باشد. + + به کنسول سرویس Elasticsearch وارد شوید. + یک استقرار را انتخاب کنید یا ایجاد کنید. + + اگر cluster قدیمی Elasticsearch روی یک میزبان راه دور (هر نوع میزبانی قابل دسترسی از طریق اینترنت) است، یک تنظیم کاربر Elasticsearch reindex.remote.whitelist اضافه کنید: + از منوی استقرار خود، به صفحه ویرایش بروید. + در قسمت Elasticsearch گزینه Manage user settings and extensions را انتخاب کنید. برای استقرار با تنظیمات کاربر موجود، ممکن است مجبور شوید به جای آن، Edit elasticsearch.yml caret را برای هر نوع گره گسترش دهید. + + تنظیمات کاربری زیر را اضافه کنید: + +```r + reindex.remote.whitelist: [REMOTE_HOST:PORT] + +``` + + جایی که REMOTE_HOST و PORT نقطه پایانی cluster Elasticsearch هستند که شما از آن دوباره فهرست می‌کنید، بدون پیشوند https://. این تنظیم دامنه های ["\*.io:*"، "\*.com:*"] را به طور پیش فرض می پذیرد. مثلا: + +```r + reindex.remote.whitelist: [81693ca13302469c8cbca193625c941c.us-east-1.aws.found.io:9243] +``` + + اگر نقطه پایان راه دور شما توسط تنظیمات فهرست مجاز پیش‌فرض پوشش داده نمی‌شود، تنظیمات لیست مجاز را تنظیم کنید سپس نقطه پایان راه دور را به لیست سفید اضافه کنید. + Save changes را انتخاب کنید. + از API Console یا در برنامه کنسول Kibana، فهرست مقصد را در سرویس Elasticsearch ایجاد کنید. + + فهرست را از remote cluster کپی کنید: + + +```r +POST _reindex +{ + "source": { + "remote": { + "host": "https://REMOTE_ELASTICSEARCH_ENDPOINT:PORT", + "username": "USER", + "password": "PASSWORD" + }, + "index": "INDEX_NAME", + "query": { + "match_all": {} + } + }, + "dest": { + "index": "INDEX_NAME" + } +} + +``` + +6-بررسی کنید که index جدید وجود دارد: + +```r +GET INDEX-NAME/_search?pretty +``` + +می‌توانید تنظیمات کاربر reindex.remote.whitelist را که قبلاً اضافه کرده‌اید حذف کنید. + + # بازیابی از یک snapshot + + اگر به هر دلیلی نمی‌توانید به فهرست راه دور متصل شوید، مثلاً اگر در حالت غیرفعال است، می‌توانید بازیابی را از آخرین snapshot کاری امتحان کنید. + +## 1.در کلاستر Elasticsearch قدیمی خود، گزینه ای را برای دریافت نام سطل مخزن snapshot خود انتخاب کنید: + +```r +GET /_snapshot +GET /_snapshot/_all +``` + +## 2. دریافت نام snapshot: + +```r +GET /_snapshot/NEW-REPOSITORY-NAME/_all +``` + +خروجی برای هر ورودی یک "snapshot" را ارائه می دهد: مقداری که نام snapshot است. + + +

+ +{ + "snapshots": [ + { + "snapshot": "scheduled-1527616008-instance-0000000004", + ... + }, + ... + ] +} + +

+ +## 3. از کنسول سرویس Elasticsearch cluster جدید Elasticsearch، مخزن snapshot را اضافه کنید. برای جزئیات، دستورالعمل‌های ما را برای ذخیره‌سازی خدمات وب آمازون (AWS)، فضای ذخیره‌سازی ابری Google (GCS)، یا ذخیره‌سازی حباب Azure بررسی کنید. + + اگر در حال انتقال عکس های فوری قابل جستجو هستید، نام مخزن باید در cluster های مبدا و مقصد یکسان باشد. + +4.فرآیند Restore: + +برای استقرار با Elastic Stack نسخه 7.2 و بالاتر: + + a:Open Kibana and go to Management > Snapshot and Restore. + b:Under the Snapshots tab, you can find the available snapshots from your newly added snapshot repository. Select any snapshot to view its details, and from there you can choose to restore it. + c:Select Restore. + d:Select the indices you wish to restore. + e:Configure any additional index settings. + f:Select Restore snapshot to begin the process. + +برای استقرار با Elastic Stack نسخه 7.1 و پایین تر: + +```r +POST /_snapshot/REPOSITORY_NAME/SNAPSHOT_NAME/_restore?pretty +{ +"indices": "*", +"ignore_unavailable": true, +"include_global_state": true +} +``` + +## 5.بررسی کنید که index جدید در استقرار سرویس Elasticsearch شما با این عبارت بازیابی شده است: + +```r +GET INDEX_NAME/_search?pretty +``` + +[منبع](https://www.elastic.co/guide/en/cloud/current/ec-migrating-data.html) + +
+ + +

صلوات

\ No newline at end of file diff --git a/The Elasticsearch Documentation/backup restore snapshot/install-uninstall-config.md b/The Elasticsearch Documentation/backup restore snapshot/install-uninstall-config.md new file mode 100644 index 0000000..4bc5da4 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/install-uninstall-config.md @@ -0,0 +1,257 @@ + +

بسم الله الرحمن الرحیم

+ +##

نحوه حذف/نصب و پیکربندی Elasticsearch 8 در Ubuntu 20.04

## + +

در این مطلب قصد داریم نحوه نصب Elasticsearch 8 را در Ubuntu 20.04 ، پیکربندی Elasticsearch در وبونتو 20.04 و حذف Elasticsearch از Ubuntu را بیان کنیم.

+ +###

معرفی

### +

+ Elasticsearch جستجو و تجزیه و تحلیل در زمان واقعی را برای انواع داده ها فراهم می کند. چه متنی ساختاریافته یا بدون ساختار، داده های عددی یا داده های مکانی داشته باشید، Elasticsearch می تواند آن را به نحوی کارآمد ذخیره و فهرست بندی کند که از جستجوهای سریع پشتیبانی می کند. +

+ +###

پیش نیازها:

### +

+ * سرور Ubuntu با 20.04/18.04/16.04 LTS
+ * جاوا 8 یا نسخه بالاتر
+ * 2 CPU و 4 گیگابایت RAM
+ * باز بودن پورت9200
+

+ +

بسته های سیستم را به روز کنید

+ +```r +sudo apt update +``` + +

بسته apt-transport-https را برای دسترسی به مخزن از طریق HTTPS نصب کنید

+ +```r +sudo apt install apt-transport-https +``` + +##

1.OpenJDK را در Ubuntu نصب کنید

## +

+ OpenJDK 11 را با دستور زیر در Ubuntu نصب کنید: +

+ +```r +sudo apt install openjdk-11-jdk +``` + +

بررسی نسخه ی نصبی جاوا با دستور زیر:

+ +```r +java --version +``` + +

خروجی:

+

+openjdk 11.0.14.1 2022-02-08
+OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04)
+OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
+

+ +##

2.تنظیم متغیر محیطی JAVA_HOME

## + +

برای تعریف متغیر محیطی فایل زیر را باز کنید:

+ +```r +sudo nano /etc/environment +``` + +

متغیر زیر را در فایل قرار دهید:

+ +```r +JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" +``` + +

متغیر محیطی یا environment را با استفاده از دستور زیر بارگذاری کنید

+ + +```r +source /etc/environment +``` + +

بررسی JAVA_HOME متغیر

+ +```r +echo $JAVA_HOME +``` + +

خروجی:

+

+/usr/lib/jvm/java-11-openjdk-amd64 +

+ +##

3.نصب ElasticSearch 8 در Ubuntu 20.04 LTS

## + +

کلید امضای عمومی را دانلود و نصب کنید، اگر می‌خواهید آخرین Elasticsearch را دانلود کنید، به صفحه دانلود رسمی Elastic Stack مراجعه کنید.

+ +```r +wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg +``` + +

تعریف مخزن را در این فایل ذخیره کنید: /etc/apt/sources.list.d/elastic-8.x.list:

+ +```r +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 +``` + +

می توانید Elasticsearch را با استفاده از دستور زیر نصب کنید:

+ +```r +sudo apt-get update +sudo apt-get install elasticsearch +``` + + +

راه اندازی سرویس Elasticsearch

+ +```r +sudo systemctl start elasticsearch +``` +

هنگام راه‌اندازی سیستم، Elasticsearch را فعال کنید

+ +```r +sudo systemctl enable elasticsearch +``` + +

دستور زیر برای بررسی وضعیت Elasticsearch است:

+ +```r +sudo systemctl status elasticsearch +``` + +

خروجی:

+

+ + +● elasticsearch.service - Elasticsearch + Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled) + Active: active (running) since Thu 2022-04-21 06:57:31 UTC; 9s ago + Docs: https://www.elastic.co + Main PID: 17266 (java) + Tasks: 68 (limit: 4693) + Memory: 2.3G + CGroup: /system.slice/elasticsearch.service + ├─17266 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.neg> + └─17539 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller +
+Apr 21 06:57:12 ip-172-31-4-2 systemd[1]: Starting Elasticsearch... +Apr 21 06:57:31 ip-172-31-4-2 systemd[1]: Started Elasticsearch. + +
+ +

+ +##

4.پیکربندی Elasticsearch در Ubuntu 20.04 LTS

## + +

بیایید در فایل پیکربندی زیر تغییراتی ایجاد کنیم

+ +```r +sudo nano /etc/elasticsearch/elasticsearch.yml +``` + +

به بخش Network بروید و network.host را از نظر خارج کنید و IP سیستم خود را جایگزین کنید

+ + +```r +network.host: 0.0.0.0 +``` + +

و باید این خط را اضافه کنید discovery.seed_hosts: [ ] در بخش discovery همانطور که در زیر نشان داده شده است:

+ + +

در مرحله بعد به BEGIN SECURITY AUTO CONFIGURATION بروید و در اینجا باید true را با false جایگزین کنید، همانطور که در زیر نشان داده شده است:

+ +

+Error: elasticsearch “curl: (52) Empty reply from server” on port 9200 +

+ +

راه حل:
+فایل پیکربندی Elasticsearch را باز کنید +

+ +```r +sudo nano /etc/elasticsearch/elasticsearch.yml +``` + +

+ xpack.security.enabled: true +

+ +

+غیرفعالسازی امینت با دستور +

+ +```r + xpack.security.enabled: false +``` + +

+پس از تغییر در فایل پیکربندی باید باید سرویس را دوباره راه‌اندازی کنید پس دستور زیر را اجرا کنید: +

+ +```r +sudo systemctl restart elasticsearch +``` + +##

5.دسترسی ElasticSearch به Ubuntu

## + +

+اجازه می دهد Elasticsearch را با استفاده از دستور curl با ارسال درخواست HTTP آزمایش کنیم +

+ +```r +curl -X GET "localhost:9200" +``` + +

خروجی:

+

+ +{ + "name" : "ip-172-31-4-2", + "cluster_name" : "elasticsearch", + "cluster_uuid" : "5WWxXV59TUiwsLWmb1lTDg", + "version" : { + "number" : "8.1.3", + "build_flavor" : "default", + "build_type" : "deb", + "build_hash" : "39afaa3c0fe7db4869a161985e240bd7182d7a07", + "build_date" : "2022-04-19T08:13:25.444693396Z", + "build_snapshot" : false, + "lucene_version" : "9.0.0", + "minimum_wire_compatibility_version" : "7.17.0", + "minimum_index_compatibility_version" : "7.0.0" + }, + "tagline" : "You Know, for Search" +} + +

+ +

+با استفاده از مرورگر می توانید دسترسی داشته باشید +

+ +```r +http://127.0.0.1:9200 +``` + + +##

6.حذف Elasticsearch از Ubuntu

+ +

+اگر می خواهید elasticsearch را حذف کنید، دستورات زیر را اجرا کنید: +

+ +```r +sudo apt-get --purge autoremove elasticsearch +sudo apt-get remove --purge elasticsearch +sudo rm -rf /etc/elasticsearch +``` + +

[منبع](https://www.fosstechnix.com/how-to-install-elasticsearch-8-on-ubuntu/)

+ + +

صلوات

\ No newline at end of file diff --git a/The Elasticsearch Documentation/backup restore snapshot/simple backup and restore.md b/The Elasticsearch Documentation/backup restore snapshot/simple backup and restore.md new file mode 100644 index 0000000..0d07021 --- /dev/null +++ b/The Elasticsearch Documentation/backup restore snapshot/simple backup and restore.md @@ -0,0 +1,86 @@ + +Old server: + +elasticsearch.yml add path.repo, for example + +```r +nano /etc/elasticsearch/elasticsearch.yml +``` + +```r +path.repo:["/data/backup"] +``` + +Restart Elasticsearch services + +```r +sytemctl restart elasticsearch +``` + + +```r +curl -H "Content-Type: application/json" + -XPUT http://192.168.50.247:9200/_snapshot/my_backup + -d '{ "type": "fs", "settings": + { "location": "/data/backup","compress": true }}' + +``` + +Create backup + +``` +curl -XPUT http://192.168.50.247:9200/_snapshot/my_backup/news0618 + +``` + +#New server: + +Restore database(new server ip:192.168.10.49 ): + +```r +curl -XPOST http://192.168.10.49:9200/_snapshot/my_backup/news0618/_restore +``` + +Answer: + +If you are using fs as a snapshot repository location then it will not work as your new instance is hosted on different host it will not have access to your old hosts file system. You need to use any shared location like volume mounts, S3 or Azure blob etc. + +You should use reindexing rather than snapshot and restore. Its pretty simpler. Refer this link for remote reindexing: + +Steps: + + Whitelist remote host in elasticsearch.yaml using the reindex.remote.whitelist property in your new Elasticsearch instance: + +```r + reindex.remote.whitelist: "192.168.50.247:9200" +``` + Restart new Elasticsearch instance. + + Reindexing: + +```r + curl -X POST "http://192.168.10.49:9200/_reindex?pretty" -H 'Content-Type: application/json' -d' + { + "source": { + "remote": { + "host": "http://192.168.50.247:9200" + }, + "index": "source-index-name", + "query": { + "match_all": {} + } + }, + "dest": { + "index": "dest-index-name" + } + } + ' +``` + +Refer this link for reindexing many indices + +Warning: The destination should be configured as wanted before calling _reindex. Reindex does not copy the settings from the source or its associated template. Mappings, shard counts, replicas, and so on must be configured ahead of time. + +Hope this helps! + +[منبع](https://stackoverflow.com/questions/68031767/how-to-migrate-elasticsearch-to-a-new-server) \ No newline at end of file