用 docker compose 搭建 bitshares elastic search

in #cn-dev5 years ago (edited)

怕是这是第一篇中文说如何部署 bitshares elastic search 的文章吧。

前置知识

  • docker
  • elastic search

准备工作

安装 docker 和 docker-compose

# 这里只给出centos7的安装步骤
# 其他系统请参考docker的官方文档  [https://docs.docker.com/install/]

# 安装 docker
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine \
&& yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2 \
&& yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo \
&& yum install -y docker-ce \
&& systemctl enable docker \
&& systemctl start docker

# 安装 docker-compose
yum install epel-release \
    && yum install -y python-pip \
    && pip install docker-compose \
    && yum upgrade python*

拉取dockerfile

git clone https://github.com/ety001/dockerfile.git

# 切换到相关目录
cd dockerfile/bts-es

这是我自己用来存储常用的 dockerfile 的库

编译 Bitshares 内核

# 编译 3.1.0,如果编译其他版本,自行更换版本号即可
docker-compose build --build-arg TAG=3.1.0

编译速度取决于你的网速和机器配置。

  • 如果在国内,可以打开该目录下的 Dockerfile,把其中的替换 sources.list 的步骤取消注释,这样更新系统软件的时候,可以使用国内163的源。
  • 另外 Dockerfile 文件中也可以调整编译参数利用多核性能提高编译速度。

修改系统配置

/etc/sysctl.conf 中增加 vm.max_map_count = 262144elasticsearch要求 max_map_count 最低 262144。添加后,重新载入 sysctl --system

启动

启动前,需要修改docker-compose.yml中的 XmsXmx环境变量,代表 es 的最小内存和最大内存占用。我的文件默认配置的是 6G

docker-compose up -d

需要在 docker-compose.yml 文件所在目录执行该命令。

停止

docker-compose down

需要在 docker-compose.yml 文件所在目录执行该命令。

验证es是否启动成功

curl http://127.0.0.1:9200/_cat/health

验证是否有数据

curl -X GET 'http://localhost:9200/bitshares-*/data/_count?pretty=true' -H 'Content-Type: application/json' -d '
{
        "query" : {
                "bool" : { "must" : [{"match_all": {}}] }
        }
}'

已知问题

  • 默认用户密码未修改

相关链接


UPDATE

  • 修改密码的话,只需要在 docker-compose.ymlelasticsearch 中增加 ELASTIC_PASSWORD=123456 环境变量,这样启动后,密码就是 123456

ET碎碎念,每周一,晚六点一刻更新,欢迎订阅

---

感谢你的阅读,我是中文区见证人之一,欢迎通过 SteemConnect 来给我投票,或者打开 https://steemit.com/~witnesses/ 页面,输入 ety001 进行投票。

2.gif

中文区的见证人目前有:
支持一下他们(按字母顺序),一人可以有30票


Thank you for reading. I'm a witness. I would really appreciate your witness vote! You can vote by SteemConnect. Or open https://steemit.com/~witnesses page, input ety001 to vote.

2.gif

Sort:  

恭喜你!您的这篇文章入选 @justyy 今日 (2019-07-11) 榜单 【优秀的文章】, 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
@justyy 是CN区的见证人,请支持他,给他投票,或者设置justyy为见证人代理。感谢!@justyy的主要贡献:https://steemyy.com

Congratulations! This post has been selected by @justyy as today's (2019-07-11) 【Good Posts】, Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^

SteemIt 工具、API接口、机器人和教程
SteemIt Tools, Bots, APIs and Tutorial



If you believe what I am doing, please consider a spare vote voting me here, thank you very much indeed.

@justyy - the author of https://SteemYY.com and I have been a Steem Witness for more than a year now.

区块链中文第一大银行简介:你的比特币拿不了利息,但是你把比特币换成steem后就能拿利息了!

你那里天气如何?来 @steemgg 玩游戏吧,决战到天亮倘若你想让我隐形,请回复“取消”。

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 65668.23
ETH 2619.57
USDT 1.00
SBD 2.65