需要准备如下
# es启动时需要使用非root用户, 所以创建一个bigdata用户
useradd bigdata
# 为bigdata用户添加密码
echo 123456 | passwd --stdin bigdata
# 将bigdata添加到sudoers
echo "bigdata ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/bigdata
chmod 0440 /etc/sudoers.d/bigdata
# 解决sudo: sorry, you must have a tty to run sudo问题,在/etc/sudoers注释掉 Default requiretty 一行
# sudo sed -i 's/Defaults requiretty/Defaults:bigdata !requiretty/' /etc/sudoers
# 创建一个bigdata目录
mkdir /{bigdata,data}
# 给相应的目录添加权限
chown -R bigdata:bigdata {bigdata,data}
chmod -R 777 {bigdata,data}
tar -zxvf elasticsearch-6.1.3.tar.gz -C /bigdata/
vi /bigdata/elasticsearch-6.1.3/config/elasticsearch.yml
# 集群名称,通过组播的方式通信,通过名称判断属于哪个集群
cluster.name: bigdata
# 节点名称,要唯一
node.name: es-1
# 数据存放位置
path.data: /data/es/data
# 日志存放位置
path.logs: /data/es/logs
# es绑定的ip地址
network.host: node1
# 初始化时可进行选举的节点
discovery.zen.ping.unicast.hosts: ["node1", "node2", "node3"]
[选举的节点可以只设置一个, 这样就相当于单机版]
6. 使用scp拷贝到其他节点
7. 在其他节点上修改es配置,需要修改的有node.name和network.host
8. 启动es(/bigdata/elasticsearch-6.1.3/bin/elasticsearch -h查看帮助文档)
/bigdata/elasticsearch-6.1.3/bin/elasticsearch -d
9. 用浏览器访问es所在机器的9200端口, 内容如下
{
"name" : "es-1",
"cluster_name" : "bigdata",
"version" : {
"number" : "2.3.1",
"build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
"build_timestamp" : "816-04-04T12:25:05Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
kill ps -ef | grep Elasticsearch | grep -v grep | awk '{print $2}'
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
elasticsearch.yml
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
解决方法: 在文件/etc/security/limits.conf
添加
* hard nofile 65536
* soft nofile 65536
如果第三条不生效的话,加入下面两行
* hard nproc 4096
* soft nproc 4096
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
/etc/security/limits.d/90-nproc.conf
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因: 虚拟内存太小下
解决方案: 修改文件/etc/sysctl.conf
:vm.max_map_count=262144
sysctl -p 生效
plugins文件夹下建立ik目录, 将中文分词器下的文件放入即可
Chrome插件
https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/
安装步骤: (注意: 在root用户下安装)
nodejs
, 会自带npm
包npm install -g grunt-cli
npm install -g grunt
npm install -g cnpm --registry=https://registry.npm.taobao.org
server: {
options: {
hostname: '*',
port: 9100,
base: '.',
keepalive: true
}
}
tar -zxf curl-7.20.0.tar.gz
cd curl-7.20.0
./configure –prefix=/usr/local/curl
make
make install