CentOS7使用
基本环境
下载CentOS-7-x86_64-Minimal-2009.iso最小化安装,缺少常用命令ifconfig、netstat,vi无代码高亮,使用yum安装:
yum install net-tools yum install vim-minimal vim-common vim-enhanced vim-filesystem
SELINUX/iptables
CentOS默认启用了SELINUX:
- CentOS7中iptables、firewalld:https://blog.csdn.net/weixin_30878501/article/details/98232144
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 systemctl stop firewalld && systemctl disable firewalld
-
sestatus
SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 31
systemctl
# 配置服务 # https://www.freedesktop.org/software/systemd/man/systemd.exec.html # [Unit]部分主要是对服务的说明,包括Description(描述服务)、After(描述服务启动顺序) # [Service]服务启动、重启、停止命令配置,全部要使用绝对路径: # Type:forking,simple # PIDFile:PID文件 # ExecStart:启动命令,ExecStop:停止命令,ExecReload:重启命令 # PrivateTmp=True:给服务分配独立临时空间 # StandardOutput: # null:关闭程序业务日志输出 # StandardInput=null # StandardOutput=journal # StandardError=inherit # Manual page systemd.exec # 如果您的发行版较新systemd(systemd版本236或更高),则可以将StandardOutput或的值设置StandardError为file:YOUR_ABSPATH_FILENAME。 # 输出到file:/append:是相对较新的功能,因此不适用于较旧的发行版,如centos-7(或之前的任何centos)。 # [Install]描述服务安装相关设置 # /lib/systemd/system/prometheus.service # /etc/systemd/system/multi-user.target.wants/prometheus.service [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/bin/prometheus --config.file=/data/prometheus/conf/prometheus.yml --storage.tsdb.path=/data/prometheus/data --storage.tsdb.retention=90d --log.level=debug --log.format=logfmt #--web.external-url=http://prom.k8stech.net Restart=on-failure StandardOutput=/var/log/prometheus.log [Install] WantedBy=multi-user.target systemctl enable prometheus.service systemctl start prometheus.service systemctl log prometheus.service systemctl daemon-reload systemctl show prometheus.service
-
systemctl日志查看
# 显示所有的systemctl的日志,这里的日志是多个服务混合的 journalctl -f journalctl -u prometheus.service
-
openresty
- https://openresty.org/cn/installation.html
-
https://github.com/openresty/opm
wget https://openresty.org/package/centos/openresty.repo sudo mv openresty.repo /etc/yum.repos.d/ # update the yum index: sudo yum check-update yum install openresty openresty-opm opm search mysql openresty/lua-resty-mysql Lua MySQL client driver for ngx_lua based on the cosocket API openresty/lua-resty-websocket Lua WebSocket implementation for the ngx_lua module openresty/lua-resty-redis Lua redis client driver for the ngx_lua based on the cosocket API openresty/lua-resty-upload Streaming reader and parser for HTTP file uploading based on ngx_lua cosocket openresty/lua-resty-dns Lua DNS resolver for the ngx_lua based on the cosocket API openresty/lua-resty-memcached Lua memcached client driver for the ngx_lua based on the cosocket API