Skip to content

STEC-deployment

服务器初始化配置

每个目录的磁盘使用情况

查看当前服务器磁盘情况,home目录所在磁盘大小

bash
df -h

示例输出:

bash
[root@localhost ~]# df -h
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                   32G     0   32G   0% /dev
tmpfs                      32G     0   32G   0% /dev/shm
tmpfs                      32G   11M   32G   1% /run
tmpfs                      32G     0   32G   0% /sys/fs/cgroup
/dev/mapper/centos-root   192G  3.1G  189G   2% /
/dev/mapper/vg_data-data 1000G  595M  999G   1% /data
/dev/vda1                 297M  137M  161M  46% /boot
tmpfs                     6.3G     0  6.3G   0% /run/user/0

可以看到/data目录下分配了1000G硬盘空间。

查看并卸载OpenJDK

查看JDK版本(OpenJDK需要删除)

bash
java -version

示例输出:

bash
[root@localhost ~]# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

搜索已安装的Java包:

bash
rpm -qa | grep java

如果搜索到OpenJDK的包,则对其执行卸载命令:

bash
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64
java -version

修改文件描述符限制

/etc/security/limits.conf中添加:

bash
* soft nofile 65535
* hard nofile 65535

修改 /etc/sysctl.conf, 加入:

bash
fs.file-max = 6553560

重启生效:

bash
reboot
Details

设置的方式有两种,一种是临时生效,重启后恢复默认。另一种永久生效。

file-max 的修改:

bash
echo 6553560 > /proc/sys/fs/file-max
sysctl -w "fs.file-max=34166"
// 以上 2 种重启机器后会恢复为默认值

echo "fs.file-max = 6553560" >> /etc/sysctl.conf
// 立即生效,此方式永久生效
sysctl -p

重启系统后生效:

bash
* soft noproc 65535
* hard noproc 65535
* soft nofile 65535
* hard nofile 65535

临时启动:

bash
ulimit -a
ulimit -n 655350

关机:

bash
shutdown -h 0

重启后检查:

bash
ulimit -a

示例输出:

bash
[root@localhost ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256820
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256820
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

防火墙设置

查看防火墙状态:

bash
systemctl status firewalld

防火墙禁用/可用:

bash
systemctl stop firewalld
systemctl disable firewalld

在停止防火墙后,设置防火墙不可用。

开启防火墙:

bash
systemctl start firewalld

开放端口3306:

bash
firewall-cmd --zone=public --add-port=3306/tcp --permanent

常用命令

所有者(chown -R 用户名称 目录名称)

bash
chown -R root:root /data/cjxx/soft/nginx/conf
chown -R zhgs:zhgs /data/cjxx/soft/nginx/conf
tail -100f logs/stec-devops.log
netstat -lntp | grep 6379
ps -ef | grep
vi /opt/nginx/conf/nginx.conf

esc,输入:

bash
q: 退出
wq: 保存并退出

应用安装

创建统一安装目录

注意:目前需要安装在/data目录下(/home目录会有权限问题)

bash
mkdir /data
mkdir /data/scripts
mkdir /data/soft
mkdir /data/apps_view
mkdir /data/apps_jar
mkdir /data/server
mkdir /data/server/static-file

应用安装

上传sh安装脚本到/data/scripts并赋予执行权限。

安装JDK

bash
cd /data/scripts
chmod +x jdk-install.sh
sh -x jdk-install.sh
source /etc/profile

检查安装是否成功:

bash
java -version

安装Redis

(需要在sh脚本中指定密码,默认: Suog@redis.yourip)

bash
cd /data/scripts
chmod +x redis-install-6.2.13.sh
sh -x redis-install-6.2.13.sh

启动状态查看:

bash
systemctl status redis

配置文件:/data/soft/redis/redis.conf

bash
#如果需要修改密码:
requirepass yourpassword

常用命令:

bash
# 启动
systemctl start redis

# 关闭
systemctl stop redis

# 重启
systemctl restart redis

# 设置开机启动
systemctl enable redis

# 启动状态查看
systemctl status redis

当Redis数据量过大时启动会报错:

bash
# systemctl status redis
Process: 139622 ExecStop=/bin/kill -s QUIT (code=exited, status=1/FAILURE)

修改文件:/usr/lib/systemd/system/redis.service

在配置文件中[Service]下增加一行:

ini
ExecStartPost=/bin/sleep 0.1

如果不行,在ExecStop行最后加上 $MAINPID

ini
[Unit]
Description=Redis
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/home/cjxx/soft/redis/redis.pid
ExecStart=/home/cjxx/soft/redis/bin/redis-server /home/cjxx/soft/redis/redis.conf
ExecReload=/home/cjxx/soft/redis/bin/redis-server -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

安装Zookeeper

bash
cd /data/scripts
chmod +x zookeeper-install-3.7.0.sh
sh -x zookeeper-install-3.7.0.sh

配置文件:/home/cjxx/soft/zookeeper/conf/zoo.cfg

修改zoo.cfg,关闭管理端口:

bash
# 解决zookeeper启动占用8080端口方法
admin.serverPort=8011

# 可以更极端的配置,关闭管理配置
admin.enableServer=false

常用命令:

bash
# 设置开机启动
systemctl enable zookeeper

# 启动
systemctl start zookeeper

# 关闭
systemctl stop zookeeper

# 状态查看
systemctl status zookeeper

# 重启
systemctl restart zookeeper

安装Nginx

bash
cd /data/scripts
chmod +x nginx-install-1.24.0.sh
sh -x nginx-install-1.24.0.sh

配置文件:/data/soft/nginx/conf/nginx.conf

系统漏洞修复,在keepalive_timeout后加一行:

bash
keepalive_requests 1000

版本1.27.1,需要加上配置,默认有问题:

bash
proxy_buffering off
# 设置最大上传文件大小为 10 MB
client_max_body_size 300M
client_body_buffer_size 300M

常用命令:

bash
# 当前版本
/home/cjxx/soft/nginx/sbin/nginx -V

# 启动
systemctl start nginx

# 关闭
systemctl stop nginx

# 开机启动
systemctl enable nginx

# 判断是否开机启动
systemctl is-enabled nginx

# nginx启动关闭状态判断
systemctl status nginx

# 修改nginx配置文件后重新装载配置文件
systemctl reload nginx

# 重启
systemctl restart nginx
systemctl reload nginx; systemctl restart nginx

安装STEC-DevOps

bash
cd /data/scripts
chmod +x stec-devops-install.sh
sh -x stec-devops-install.sh

会安装到/data/server/stec-devops

发布的jar包目录默认在(可以自己配置发布地址):

bash
/data/apps_jar
/data/apps_view (前端页面)

常用命令:

bash
# 设置为开机启动
chkconfig stec-devops on

# 启动
service stec-devops start

# 运行状态查看
service stec-devops status

# 关闭
service stec-devops stop
service stec-devops stop; service stec-devops start

安装MySQL数据库

(需要修改mysql-install-5.7.44.sh中new_password中的密码配置,以满足复杂度要求)

bash
cd /data/scripts
chmod +x mysql-install-5.7.44.sh
sh -x mysql-install-5.7.44.sh

配置文件:/etc/my.cnf

bash
# 配置log文件大小和保存时间
max_binlog_size=500M
expire_logs_days=15
ssl=0
binlog_format = ROW

常用命令:

bash
# 启动
systemctl start mysqld

# 关闭
systemctl stop mysqld

# 重启
systemctl restart mysqld

# 启动状态
systemctl status mysqld

# 设置开机启动
systemctl enable mysqld
mysql -V

在CentOS中卸载MySQL应用---慎用:

bash
sudo yum remove mysql-server

安装Kafka

bash
cd /data/scripts
chmod +x kafka-install.sh
sh -x kafka-install.sh

安装后IP地址可能需要改,需要检查/data/soft/kafka/config/server.properties

properties
adversised.listeners=PLAINTEXT://newipaddress:9092

常用命令:

bash
# 设置开机启动
systemctl enable kafka

# 启动
systemctl start kafka

# 关闭
systemctl stop kafka

# 状态查看
systemctl status kafka
systemctl restart kafka

安装RabbitMQ

启动:

bash
systemctl start rabbitmq-server

查看RabbitMQ状态:

bash
rabbitmqctl status

示例输出:

bash
Connection count: 1
Queue count: 8
Virtual host count: 3

安装InfluxDB-1.6.0

bash
cd /data/scripts
chmod +x influxdb-1.6.0-install.sh
sh -x influxdb-1.6.0-install.sh

备份:

bash
sh -x influxdb-backup.sh

修改备份地址:

bash
influxdb_backup_dir=/home/data/backup/influxdb

还原:

bash
sh -x influxdb-restore.sh
tar -xzvf influxdb_backup_2023_03_07.tar.gz
# 解压备份文件---解压后的目录有问题,这里需要注意

# 全库还原,目录为解压出来的备份数据目录--目录有问题
influxd restore -portable /data/backup/influxdb/home/data/backup/influxdb/temp

常用命令:

bash
systemctl start influxdb
systemctl stop influxdb
# 设置开机启动
systemctl enable influxdb
systemctl status influxdb

安装FastDFS-5.12

bash
cd /data/scripts
chmod +x fastdfs-install-V6.07.sh
sh -x fastdfs-install-V6.07.sh

常用命令:

bash
# storage启动
service fdfs_storaged start

# storage关闭
service fdfs_storaged stop

# 设置storage开机启动
chkconfig fdfs_trackerd on

# storage重启
service fdfs_storaged restart

# tracker启动
service fdfs_trackerd start

# tracker关闭
service fdfs_trackerd stop

# tracker重启
service fdfs_trackerd restart

# 设置tracker开机启动
chkconfig fdfs_trackerd on

# 查看状态
service fdfs_trackerd status
service fdfs_storaged status

安装FineReport

bash
cd /data/scripts
chmod +x finereport-install.sh
sh -x finereport-install.sh

安装LibreOffice

bash
cd /data/scripts
chmod +x libreoffice-install.sh
sh -x libreoffice-install.sh

IP地址现在的是安装环境,正式环境时,需要改IP。

安装Nacos

**说明:**安装Nacos前,需要先安装JDK。

安装:

bash
cd /data/scripts
chmod +x nacos-install.sh
sh -x nacos-install.sh

常用命令:

bash
systemctl start nacos
systemctl status nacos
systemctl stop nacos
systemctl start nacos
# 设置开机启动
systemctl enable nacos

Credit @Wayne19980