elastic 8.x on google colab

here step is how to use elastic 8.3.1 on google colab.

download elastic, cgroup-tools

In [1]:
%%bash

rm -rf elasticsearch*
wget -q https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.1-linux-x86_64.tar.gz
tar -xzf elasticsearch-8.3.1-linux-x86_64.tar.gz
sudo chown -R daemon:daemon elasticsearch-8.3.1/
umount /sys/fs/cgroup
apt install cgroup-tools
Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
  libnvidia-common-460
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  libcgroup1
The following NEW packages will be installed:
  cgroup-tools libcgroup1
0 upgraded, 2 newly installed, 0 to remove and 62 not upgraded.
Need to get 108 kB of archives.
After this operation, 393 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libcgroup1 amd64 0.41-8ubuntu2 [42.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 cgroup-tools amd64 0.41-8ubuntu2 [66.2 kB]
Fetched 108 kB in 0s (1,138 kB/s)
Selecting previously unselected package libcgroup1:amd64.
(Reading database ... 155639 files and directories currently installed.)
Preparing to unpack .../libcgroup1_0.41-8ubuntu2_amd64.deb ...
Unpacking libcgroup1:amd64 (0.41-8ubuntu2) ...
Selecting previously unselected package cgroup-tools.
Preparing to unpack .../cgroup-tools_0.41-8ubuntu2_amd64.deb ...
Unpacking cgroup-tools (0.41-8ubuntu2) ...
Setting up libcgroup1:amd64 (0.41-8ubuntu2) ...
Setting up cgroup-tools (0.41-8ubuntu2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.3) ...
/sbin/ldconfig.real: /usr/local/lib/python3.7/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

start elastic on backgroud

In [2]:
%%bash --bg

sudo -H -u daemon elasticsearch-8.3.1/bin/elasticsearch
Starting job # 0 in a separate thread.

create access password

In [3]:
!/content/elasticsearch-8.3.1/bin/elasticsearch-setup-passwords auto -url "https://localhost:9200"
******************************************************************************
Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This       command will be removed in a future release.
******************************************************************************

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y


Changed password for user apm_system
PASSWORD apm_system = 5wJfMLTnkHwSY7lbpr6y

Changed password for user kibana_system
PASSWORD kibana_system = rE40UfIbndtwONL6q33D

Changed password for user kibana
PASSWORD kibana = rE40UfIbndtwONL6q33D

Changed password for user logstash_system
PASSWORD logstash_system = DOJfaIC9toV7tgJB33ON

Changed password for user beats_system
PASSWORD beats_system = iVpsYjuzPaL6wIOZQEKx

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = wsxURS5iLLi3hrSf8qw9

Changed password for user elastic
PASSWORD elastic = Uzv4aE6oFfpMrDVy1nql

check a elastic process, live page. “Enter host password for user ‘elastic’:” use above elastic user password.

In [5]:
!ps -ef | grep elastic
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XGET https://localhost:9200/?pretty=true
root         399     397  0 08:19 ?        00:00:00 sudo -H -u daemon elasticsearch-8.3.1/bin/elasticsearch
daemon       400     399  8 08:19 ?        00:00:14 /content/elasticsearch-8.3.1/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=elasticsearch-8.3.1/bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=/content/elasticsearch-8.3.1 -Des.path.conf=/content/elasticsearch-8.3.1/config -Des.distribution.type=tar -cp /content/elasticsearch-8.3.1/lib/*:/content/elasticsearch-8.3.1/lib/cli-launcher/* org.elasticsearch.launcher.CliToolLauncher
daemon       467     400 33 08:19 ?        00:00:52 /content/elasticsearch-8.3.1/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -Djava.security.manager=allow -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=SPI,COMPAT --add-opens=java.base/java.io=ALL-UNNAMED -XX:+UseG1GC -Djava.io.tmpdir=/tmp/elasticsearch-8870137204813447444 -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -Xms6493m -Xmx6493m -XX:MaxDirectMemorySize=3405774848 -XX:G1HeapRegionSize=4m -XX:InitiatingHeapOccupancyPercent=30 -XX:G1ReservePercent=15 -Des.distribution.type=tar --module-path /content/elasticsearch-8.3.1/lib -m org.elasticsearch.server/org.elasticsearch.bootstrap.Elasticsearch
daemon       490     467  0 08:19 ?        00:00:00 /content/elasticsearch-8.3.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root         621      72  0 08:22 ?        00:00:00 /bin/bash -c ps -ef | grep elastic
root         623     621  0 08:22 ?        00:00:00 grep elastic
Enter host password for user 'elastic':
{
  "name" : "57c066b7e6a1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "qnlGU_l8RsORus-vwAdpoQ",
  "version" : {
    "number" : "8.3.1",
    "build_type" : "tar",
    "build_hash" : "b9a6b2867996ba92ceac66cb5bafc6db25e7910e",
    "build_date" : "2022-06-29T18:39:55.731992798Z",
    "build_snapshot" : false,
    "lucene_version" : "9.2.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

create sample index.

In [10]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XPUT https://localhost:9200/playground -d '{"mappings": { "properties": { "name" : { "type": "keyword" } } } }'
Enter host password for user 'elastic':
{"acknowledged":true,"shards_acknowledged":true,"index":"playground"}

check a index.

In [11]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XGET https://localhost:9200/playground/_mapping?pretty=true
Enter host password for user 'elastic':
{
  "playground" : {
    "mappings" : {
      "properties" : {
        "name" : {
          "type" : "keyword"
        }
      }
    }
  }
}

create new data to es.

In [12]:
!curl --cacert /content/elasticsearch-8.3.1/config/certs/http_ca.crt -u elastic -H 'Content-Type: application/json' -XPOST https://localhost:9200/playground/_doc -d '{"name": "HOGE"}'
Enter host password for user 'elastic':
{"_index":"playground","_id":"oLPQ-4EBI_biyaanZoqU","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

コメントを残す

メールアドレスが公開されることはありません。

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください