一、安装部署
1、skywalking9版本连接8版本es
从8版本开始,es默认开启认证,使用es账户的时候需要注意权限问题,我有一次使用skywalking时就遇到了,配置普通账户skywalking会报错,只能使用管理员账户配置
es7开启认证
在es config目录下穿建certs目录
在config目录下执行
../bin/elasticsearch-certutil ca
../bin/elasticsearch-certutil cert --ca certs/elastic-stack-ca.p12
一直回车
配置文件elasticsearch.yaml加入
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
启动es后,执行命令初始化密码
./bin/elasticsearch-setup-passwords interactive 交互式输入密码
./bin/elasticsearch-setup-passwords auto 设定默认密码
2、系统参数配置
cat <<EOF>> /etc/security/limits.conf
* soft core 102400
* hard core 102400
* hard nofile 655360
* soft nofile 655360
* hard nproc 32768
* soft nproc 32768
* soft memlock unlimited
* hard memlock unlimited
EOF
(Linux7为20-nproc.conf)
cat <<EOF>>/etc/security/limits.d/20-nproc.conf
* soft nproc 4096
root soft nproc unlimited
EOF
调整虚拟内存&最大并发连接
cat <<EOF>> /etc/sysctl.conf
vm.max_map_count = 655360
vm.swappiness = 0
EOF
修改完成后sysctl -p使配置生效
启动es不能用root账户
3、too many shards,shard不够
curl -XPUT -H 'Content-Type:application/json' -u elastic http://host:9200/cluster/settings -d '{ "persistent":{"cluster":{"max_shards_per_node":"10000"}}}'//默认shard时1000,索引多时不够用
4、报错 read only 不能删除时
curl -XPUT -H 'Content-Type:application/json' -u elastic http://host:9200/all/settings -d '{ "index":{"blocks":{"read_only_allow_delete": true}}}'
5、修改所有索引的shard和副本数
curl -XPUT -H 'Content-Type:application/json' -u elastic http://host:9200/_template/all -d '{ "index_patterns":["*"],"order":0,"settings":{"index":{"number_of_replicas":"0","number_of_shards":"2"}}}'
(shard默认为节点数的1.5-3倍,replica不超过节点数)
6、常用命令
删除索引
curl -XDELETE es地址/索引名称 //可以用模糊匹配
创建索引
curl -XPUT es地址/索引名称
关闭、打卡索引
curl -XPUT es地址/索引名称/_close
curl -XPUT es地址/索引名称/_open