首页
✨运维
🎉安装
👀踩坑
🤷‍♂️学习
😊关于
  • 分类
  • 标签
  • 归档
GitHub

Summer

运维界的小白
首页
✨运维
🎉安装
👀踩坑
🤷‍♂️学习
😊关于
  • 分类
  • 标签
  • 归档
GitHub
  • K8s

  • shell

    • 自动重启应用脚本
    • 自动重启docker脚本
    • 安装java脚本
    • 安装mysql脚本
    • 安装elasticsearch脚本
      • 1.安装脚本
    • 安装redis脚本
    • 清理docker日志脚本
    • 钉钉报警脚本
    • 彩色进度条脚本
    • 奇数行和偶数行合并
    • 备份mysql脚本
    • cpu硬盘报警脚本
    • 安装node-exporter脚本
  • Zabbix

  • Python

  • Redis

  • Elasticsearch

  • prometheus

  • Mysql

  • 学习
  • shell
summer
2020-11-03

安装elasticsearch脚本

# 1.安装脚本

#!/bin/bash

# read -p "please input your server IP like 192.168.0.9: " serverip
# echo $serverip
# read -p 'please input your server group IP like "192.168.0.9","192.168.0.8","192.168.0.7": ' servergpip
# echo $servergpip

echo -e " Please choose ES version:
		$WHITE 1)$WHITE $ES_version1;
		$WHITE 2)$WHITE $ES_version2;"
echo -e "$WHITE"

# 判断
while :; do
  echo
  read -p "Please input the number of your choose:" ES_version_select
  if [[ ! $ES_version_select =~ ^[1,2]$ ]]; then
    echo -e "\033[0mPlease input 1 or 2\033[33m"
  else
    break
  fi
done

case $ES_version_select in
  1)
    echo "you choose $ES_version1"
    if [ -d "$elasticsearch_conf_dir" ]; then
      echo "本机es已存在..."
    else
    
      pushd $src_dir >/dev/null 2>&1
      unzip $elasticsearch_zip -d $elasticsearch_install_dir &> /dev/null
      # mkdir $elasticsearch_data
      popd >/dev/null 2>&1

      #方案一:写死
      echo "node.name: es0" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "path.data: $pathdata" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "path.logs: $pathlogs" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "network.host: $serverip" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "http.port: $httpport" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "transport.tcp.port: $transporttcpport" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "discovery.zen.ping.unicast.hosts: [$unicasthosts]" >> $elasticsearch_conf_dir/elasticsearch.yml
      echo "xpack.ml.enabled: false" >> $elasticsearch_conf_dir/elasticsearch.yml

      #配置操作系统文件访问设置
      mv -f /etc/security/limits.conf /etc/security/limits.confbak
      cp $conf_dir/limits.conf /etc/security
      echo "正在配置操作系统文件访问设置.."
      mv -f /etc/sysctl.conf /etc/sysctl.confbak
      cp $conf_dir/sysctl.conf /etc
      #使系统配置生效
      sysctl -p &> /dev/null
      chown -R $user:$user $es_ch
      echo "es安装成功正在使用非root用户启动.."
      echo "启动执行./home/非root用户/elasticsearch-6.3.1/bin/elasticsearch -d"
      su - $user << EOF
cd /;
./home/smartmining/elasticsearch-6.3.1/bin/elasticsearch -d;
exit;
EOF
      systemctl stop firewalld.service &> /dev/null
      sleep 2
      echo "--------------------本机安装es6.....成功-------------------"
    fi
    ;;

 2)
    echo "you choose $ES_version2"
    if [ -d "$elasticsearch_conf_dir" ]; then
      echo "本机es已存在..."
    else
      systemctl stop firewalld.service &> /dev/null
      pushd $src_dir >/dev/null 2>&1
      tar -zxvf $elasticsearch_tar -C $elasticsearch_install_dir &> /dev/null
      mkdir $elasticsearch_data
      popd >/dev/null 2>&1

      echo "node.name: es0" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "path.data: $pathdata2" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "path.logs: $pathlogs2" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "network.host: $serverip" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "http.port: $httpport" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "transport.tcp.port: $transporttcpport" >> $elasticsearch_conf_dir2/elasticsearch.yml
      #echo "discovery.zen.ping.unicast.hosts: [$servergpip]" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "discovery.zen.ping.unicast.hosts: [$unicasthosts]" >> $elasticsearch_conf_dir2/elasticsearch.yml
      echo "xpack.ml.enabled: false" >> $elasticsearch_conf_dir2/elasticsearch.yml
      # 通过为 cluster.initial_master_nodes 参数设置符合主节点条件的节点的 IP 地址来引导启动集群
      echo "cluster.initial_master_nodes: ["es0"]" >> $elasticsearch_conf_dir2/elasticsearch.yml
      # 开启跨域访问支持,默认为false
      echo "http.cors.enabled: true" >> $elasticsearch_conf_dir2/elasticsearch.yml
      # 跨域访问允许的域名地址
      echo 'http.cors.allow-origin: "*"' >> $elasticsearch_conf_dir2/elasticsearch.yml

      mv $es_start_dir2 /home/$user/elasticsearch-7.6.0/bin/elasticsearchbak
      cp $conf_dir/elasticsearch /home/$user/elasticsearch-7.6.0/bin

      #配置操作系统文件访问设置
      mv -f /etc/security/limits.conf /etc/security/limits.confbak
      cp $conf_dir/limits.conf /etc/security

      echo "正在配置操作系统文件访问设置.."
      mv -f /etc/sysctl.conf /etc/sysctl.confbak
      cp $conf_dir/sysctl.conf /etc

      #使系统配置生效
      sysctl -p &> /dev/null
      chown -R $user:$user $es_ch2
      echo "es安装成功正在使用非root用户启动.."
      echo "启动执行./home/非root用户/elasticsearch-7.6.0/bin/elasticsearch -d"
      su - $user << EOF
 cd /;
 ./home/smartmining/elasticsearch-7.6.0/bin/elasticsearch -d;
 exit;
EOF

      sleep 2
      echo "--------------------本机安装es7.....成功-------------------"
    fi
    ;;

esac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
安装mysql脚本
安装redis脚本

← 安装mysql脚本 安装redis脚本→

最近更新
01
redis持久化
12-08
02
redis为什么这么快
12-08
03
redis的优缺点
12-08
更多文章>
Theme by Vdoing | Copyright © 2019-2020 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式