关于xsheel开启两个终端导致文件保存出现问题

情况:写了一个.sh脚本用来自动启动elasticsearch相关的docker,错误提示:is not tty

百度:docker exec -i就可以不要用-it参数,因为-t是使用伪tty

过程:我删除了-t参数,但是一直还是报这个错误,怀疑网上的解决方法是不是不太好使,然后在一次cat后偶然发现我使用vim的时候显示-i,但是cat显示-it

结果:两个连接,导致出现这个问题,把额外的连接关闭。

 

[root@VM-20-7-centos elasticsearch]# cat /data/docker/elasticsearch/docker_es.sh 
es="elasticsearch:7.7.0"
es_head="mobz/elasticsearch-head:5"
es_ik_path="/data/docker/elasticsearch/elasticsearch-analysis-ik-7.7.0.zip"
es_head_vendor_path="/data/docker/elasticsearch/vendor.js"
# 修改max_map_count的值,不然es启动不起来
max_map_count_file="/proc/sys/vm/max_map_count"
max_map_count=`cat ${max_map_count_file}`
if [ ${max_map_count} -gt 262144 ];
then
    echo "max_map_count值为: ${max_map_count}, 修改为2G"
       sysctl -w vm.max_map_count=262144
    #262144 > ${max_map_count_file}
else
    echo "max_map_count值为: ${max_map_count}, 不需要修改"
fi

# 判断docker是否存在es镜像
es_exist=`docker images ${es} | wc -l`
if [ $es_exist -eq 2 ];
then
    echo "已存在${es} image, 不需要docker pull"
else
    docker pull ${es}
    echo “docker pull ${es}”
fi

# 判断docker是否存在es-head
es_head_exist=`docker images ${es_head} | wc -l`
if [ ${es_head_exist} -eq 2 ];
then
    echo "已存在${es_head} image, 不需要docker pull"
else
docker pull ${es_head}
echo "docker pull ${es_head}"
fi

# 将ik分词器放入es中
echo "docker rm -f es"
docker rm -f es
echo "docker run --name es -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0"
docker run --name es -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0
docker exec -i es /bin/bash <<EOF
echo "http.cors.enabled: true" >> config/elasticsearch.yml
echo 'http.cors.allow-origin: "*"' >> config/elasticsearch.yml
exit
EOF
docker cp ${es_ik_path} es:/usr/share/elasticsearch/plugins/
docker exec -i es /bin/bash <<EOF
mkdir /usr/share/elasticsearch/plugins/ik
mv /usr/share/elasticsearch/plugins/elasticsearch-analysis-ik-7.7.0.zip /usr/share/elasticsearch/plugins/ik/
cd /usr/share/elasticsearch/plugins/ik
unzip elasticsearch-analysis-ik-7.7.0.zip
rm -rf elasticsearch-analysis-ik-7.7.0.zip
exit
EOF
docker restart es
echo "es的elasticsearch.yml文件修改成功,且ik分词器配置完成,重新启动es"
docker rm -f es_head
docker create --name es_head -p 9100:9100 mobz/elasticsearch-head:5
echo "创建es_head的容器"
docker start es_head
echo "启动es_head"
docker cp ${es_head_vendor_path}  es_head:/usr/src/app/_site
echo "es_head配置更新完成,重启"
docker restart es_head

 

posted on 2022-07-19 21:23  我欲皆真  阅读(26)  评论(0编辑  收藏  举报

导航