重装服务器,并改用稳定的centos 8.2版本,centos8.0版本有两个OpenSSL漏洞,我无法修复,干脆升级版本(高版本的linux安装一些库也比较方便,例如centos7.9上面安装mysqlclient就折腾了好长时间,按照官网的方法都没装上,又比如virtualwrapper等)。花费了14个小时,记录如下:
准备工作:
- Navicat复制数据库结构和数据到本地。
- crontab文件(注意删除病毒脚本文件)
- elasticsearch的配置yml文件,jvm.options文件,plugins文件,源码压缩包
- logstash的配置conf文件,jvm.options文件,源码压缩包
- nginx的配置文件
- Django项目文件
- python相关库
pip3 freeze > requirements.txt
workon Django
pip3 freeze > requirements-django.txt
- elasticsearch的备份数据,注意版本须一致!
# 建立es用户有权限的esbackup备份目录
curl -XPUT 'http://127.0.0.1:9200/_snapshot/esbackup?pretty' -H 'Content-Type: application/json' -d '
{
"type": "fs",
"settings": {
"location": "/home/esbackup",
"max_snapshot_bytes_per_sec" : "50mb",
"max_restore_bytes_per_sec" : "50mb"
}
}
'
# 安装hdfs插件
./elasticsearch-plugin install https://artifacts.elastic.co/downloads/elasticsearch-plugins/repository-hdfs/repository-hdfs-7.10.0.zip
# 备份数据,建立快照
curl -H "Content-Type:application/json" -XPUT '127.0.0.1:9200/_snapshot/esbackup/snapshot_1' -d '
{
"indices": "NBA20210505"
}'
# 恢复数据
curl -H "Content-Type:application/json" -XPOST '127.0.0.1:9200/_snapshot/esbackup/snapshot_1/_restore?wait_for_completion=true'
# 查看快照状态
curl -XGET 'http://127.0.0.1:9200/_snapshot/esbackup/snapshot_1/_status?pretty'
# 如需删除
curl -X DELETE "localhost:9200/_snapshot/esbackup/snapshot_1"
curl -X DELETE "localhost:9200/_snapshot/esbackup"
- 一些同步的时间戳记录脚本,如:logstash_jdbc_last_run等
- 一些脚本文件
重装如下:
- python3.6.8的安装
- nginx,nginx-1.18.0版本,覆盖原始nginx.conf文件,以及增加屏蔽的IP文件blockIP.conf,增加nginx.service单元
wget http://nginx.org/download/nginx-1.18.0.tar.gz -P /usr/src
tar -zxvf nginx-1.18.0.tar.gz
yum -y install gcc pcre-devel zlib zlib-devel
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
数据库mariadb,安装10.3.27-MariaDB(以下示例为centos7上面的实验)。
# vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos73-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# yum install mariadb-server
yum install MariaDB-server MariaDB-client
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
- 创建网站数据库专用用户的权限账号,注意,在mariadb10.3的版本中,下方的NBA_DB数据库这里不要加引号
grant all privileges on NBA_DB.NBA_TABLE to 'zxf'@'%' identified by '1234';
flush privileges;
- 更改ssh端口
vim /etc/ssh/sshd_config
=> Port 123456
# 防火墙放开端口
firewall-cmd --add-port=12345/tcp --permanent
firewall-cmd --reload
systemctl restart sshd #centos系统,重启ssh服务命令
- elasticsearch的安装,插件、备份恢复,启动
# 创建用户
useradd es
# 下载es文件
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-x86_64.tar.gz
tar -zxvf elasticsearch-*
chown -R es:es elasticsearch-*
# 后台奇幻es用户启动
./elasticsearch -d
- logstash的安装,配置文件,启动
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.12.0-linux-x86_64.tar.gz
tar -zxvf logstash-*
nohup /usr/src/logstash-7.12.0/bin/logstash -f /usr/src/logstash-7.12.0/logstash20210505.conf &
- python的一些库,例如Djano、守护进程supervisord的安装等
pip3 freeze > requirements.txt
pip3 install -r requirements.txt
- Django项目
- goaccess的安装,mysql-connector-java文件的放置
- firewall的相关端口开放