运维部署宝典-长更版

本文详细介绍了在Linux环境下安装和配置防火墙、VMware、CentOS、Redis主从复制、哨兵模式、Java、Nginx、ELKStack(Elasticsearch、Logstash、Kibana)以及Filebeat的过程,适合技术社区的读者参考。
摘要由CSDN通过智能技术生成

防火墙操作:

参考
查看防火墙状态 systemctl status firewalld
查看是否开启目标端口:iptables -L -n | grep 6379 开放则显示一条记录
永久开放端口 firewall-cmd --zone=public --add-port=6379/tcp --permanent
永久关闭端口 firewall-cmd –zone=public –remove-port=80/tcp --permanent sudo iptables -A INPUT -p tcp –dport 80 -j DROP
重载防火墙 firewall-cmd --reload
查看防火墙开放的所有端口:firewall-cmd --list-port

安装vm16:

安装centos(重点:重启ip会替换):

安装redis:

参考1 参考2
远程连接redis客户端仅需输入host:port
redis启动命令:bin目录下

./redis-onekeyhandle.sh /home/xlh/middleware/redis/redis-6.2.12/src/redis-server /home/xlh/middleware/redis/redis-6.2.12/redis.conf

主从复制:

scp redis-6.2.12.tar.gz root@另一台机子ip:/home/xlh/middleware/redis

从机配置文件:replicaof ip 6379 (master ip : port) ----永久性 ,临时设置用客户端设置
先启动主,再启动从
验证:

主:
./redis-cli
info replication
设置key
从:
./redis-cli
info replication
获取key

思考:两个从未开防火墙,对于这种主从架构来说可能没影响,哨兵模式可能会

哨兵模式:

如出现:

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 2
>>> 'sentinel monitor mymaster 127.0.0.1 6379 2'

./redis-server.sh sentinel.conf --sentinel

java安装:

多jdk安装参考
centos默认有openjdk需要卸载

java -version
rpm -qa | grep javarpm -qa | grep java |xargs rpm -e --nodeps  卸载
unzip jdk1.8.0_351_linux.zip(tar -zxvf jdk-11.0.20_linux-x64_bin.tar.gz)
root权限:vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_144
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/    
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile
chmod +x /home/xlh/java/jdk1.8.0_351/bin -R
/home/xlh/java/jdk1.8.0_351

安装nginx:

参考1
参考2
参考3

tar -xvfz nginx-1.19.3.tar.gz
在安装目录下:
./configure --with-http_stub_status_module --with-http_ssl_module

如有报错:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

说明不成功

yum -y install pcre-devel,如若出现

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

yum -y install openssl openssl-devel

./configure --with-http_stub_status_module --with-http_ssl_module

make

make install

cd /usr/local/nginx/sbin (nginx启动命令在这)
启动./nginx -c /home/xlh/middleware/nginx/nginx-1.19.3/conf/nginx.conf
访问不了就跟redis一样开放端口

./nginx -s stop

elkf搭建:

elasticsearch安装:

下载
参考1 参考2

tar -zxvf elasticsearch.7.12.1.tar.gz -C /usr/local/elk

jvm.options:
# 最小占用内存
-Xms1g
# 最大占用内存
-Xmx1g

elasticsearch.yml:

# IP配置为:0.0.0.0 外网才能访问
network.host: 0.0.0.0
# 集群配置
cluster.initial_master_nodes: ["node-1"]
# 配置当前es节点的名称
node.name: node-1
# 配置端口号
http.port: 9200
# 进入es bin目录
$ cd /usr/local/elk/elasticsearch/bin
# 后台启动
$ nuhup ./elasticsearch &amp;
# 或者
$ ./elasticsearch -d

若出现:

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

参考

vi /etc/sysctl.conf
vm.max_map_count=262144
sysctl -p

开放9200端口

kibana安装:

参考1
参考2

tar -zxvf kibana-7.12.1-linux-x86_64.tar.gz
kibana.yml:

# kibana 端口
server.port: 5601
# 允许外网访问
server.host: "0.0.0.0"
# 监听ES
elasticsearch.hosts: ["http://localhost:9200"]
nohup ./kibana &

开放5601端口

logstash安装:

tar -zxvf logstash-7.12.1-linux-x86_64.tar.gz
mkdir conf.d
touch logstash.yml

logstash.yml:

input{
	# 从filebeats中获取数据
    beats {
        # 端口必须为5044
        port => 5044
        # 日志类型
        type => 'systemlog'
        # 编码
        codec => plain {
          charset => "UTF-8"
        }
    }
}


# 输出
output {
    # 输出到ES
    elasticsearch {
        # ES的IP端口地址
        hosts => ["192.168.213.136:9200"]
        # 输出到ES的日志索引(在kibana中搜索此索引查看日志数据)
        index => "elk-%{+systemlog}-%{+YYYY.MM.dd}"
    }
}

原本的logstash.yml:

# 配置自定义的传输管道目录
path.config: /usr/local/elk/logstash/conf.d
# logstashIP地址
http.host: "127.0.0.1"
# logstash端口
http.port: 9623
nohup ./logstash -f /home/xlh/middleware/elk/logstash-7.12.1/conf.d/logstash.conf
./logstash -f "input { stdin {} } output { stdout {} }"   管道配置输入输出后权限不足,换root
[2023-08-27T20:59:10,692][INFO ][logstash.config.source.local.configpathloader] No config files found in path {:path=>"/home/xlh/middleware/elk/logstash-7.12.1/bin/input { stdin {} } output { stdout {} }"}
[2023-08-27T20:59:10,701][ERROR][logstash.config.sourceloader] No configuration found in the configured sources.

filebeat安装:

filebeat.yml:

filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /home/xlh/middleware/elk/temp/test*.txt

	
	# ------------------------------ Logstash Output -------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["本机具体ip(非127.0.0.1或者localhost):5044"]

nohup ./filebeat -e -c filebeat.yml >> logs/filebeat.log
注意:(由于本虚拟机ip经常变动,每次启动注意ip配置)

elkf一键启动:

./elkf-onekeystartup.sh xlh /home/xlh/middleware/elk/elasticsearch-7.12.1/bin/ /home/xlh/middleware/elk/kibana-7.12.1-linux-x86_64/bin/ /home/xlh/middleware/elk/logstash-7.12.1/bin/ /home/xlh/middleware/elk/logstash-7.12.1/conf.d/logstash.conf /home/xlh/middleware/elk/filebeat-7.12.1-linux-x86_64/

持续关注本篇文章,长更中…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fire king

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值