diff --git a/.gitattributes b/.gitattributes index 8065569..ee80d20 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ wordpress/theme-name/dux.tar.gz filter=lfs diff=lfs merge=lfs -text +openvpn/softs/openvpn.zip filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/github-actions-main.yml b/.github/workflows/github-actions-main.yml new file mode 100644 index 0000000..fb759b7 --- /dev/null +++ b/.github/workflows/github-actions-main.yml @@ -0,0 +1,53 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions +# on: [push] # 每次提交就编译 +on: + push: + tags: + - '*' # 只有tag擦编译 +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + + - name: Check out repository code + uses: actions/checkout@v3 + - name: Get the tag name + run: echo "TRAVIS_BRANCH=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - shell: bash + run: | + echo "Latest tag name: $TRAVIS_BRANCH" + make build_tar_gz + + - name: List files in the repository + run: | + ls ${{ github.workspace }} + + # 创建Release + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Tar Gz Assets + id: uploadRelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + for file in $(find . -name "*.tar.gz"); do + echo "Uploading $file" + asset_name=$(basename $file) + curl \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/gzip" \ + --data-binary @$file \ + "https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=$(basename $file)" + done + - run: echo "job's status is ${{ job.status }}." + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile index 073e500..d3170a0 100644 --- a/Makefile +++ b/Makefile @@ -23,13 +23,25 @@ zabbix_build: tar zcvf zabbix_script_${TRAVIS_BRANCH}.tar.gz zabbix_${TRAVIS_BRANCH} firewall_build: - mv firewallfirewall_${TRAVIS_BRANCH} + mv firewall firewall_${TRAVIS_BRANCH} tar zcvf firewall_script_${TRAVIS_BRANCH}.tar.gz firewall_${TRAVIS_BRANCH} es_build: mv elasticsearch elasticsearch_${TRAVIS_BRANCH} tar zcvf elasticsearch_script_${TRAVIS_BRANCH}.tar.gz elasticsearch_${TRAVIS_BRANCH} +logstash_build: + mv logstash logstash_${TRAVIS_BRANCH} + tar zcvf logstash_script_${TRAVIS_BRANCH}.tar.gz logstash_${TRAVIS_BRANCH} + +kibana_build: + mv kibana kibana_${TRAVIS_BRANCH} + tar zcvf kibana_script_${TRAVIS_BRANCH}.tar.gz kibana_${TRAVIS_BRANCH} + +filebeat_build: + mv filebeat filebeat_${TRAVIS_BRANCH} + tar zcvf filebeat_script_${TRAVIS_BRANCH}.tar.gz filebeat_${TRAVIS_BRANCH} + ci_build: cp -r ./lib ./jenkins cp -r jenkins ./ci @@ -45,13 +57,35 @@ wordpress_build: cp -r ./lib ./wordpress mv wordpress wordpress_${TRAVIS_BRANCH} tar zcvf wordpress_script_${TRAVIS_BRANCH}.tar.gz wordpress_${TRAVIS_BRANCH} -build_tar_gz: ci_build mongo_build redis_build gitlab_build jenkins_build nginx_build mysql_build wordpress_build docker_build \ +openvpn_build: + mv openvpn openvpn_${TRAVIS_BRANCH} + tar zcvf openvpn_script_${TRAVIS_BRANCH}.tar.gz openvpn_${TRAVIS_BRANCH} +activemq_build: + mv activemq activemq_${TRAVIS_BRANCH} + tar zcvf activemq_script_${TRAVIS_BRANCH}.tar.gz activemq_${TRAVIS_BRANCH} + +build_tar_gz: ci_build \ + mongo_build \ + redis_build \ + gitlab_build \ + jenkins_build \ + nginx_build \ + mysql_build \ + wordpress_build \ + docker_build \ zabbix_build \ firewall_build \ - es_build + es_build \ + logstash_build \ + kibana_build \ + filebeat_build \ + openvpn_build \ + activemq_build ci: curl -v -X POST "http://jenkins:c253a297a64fbf61269ea19b37bdc58c@114.116.83.37:9090/job/docker_script/buildWithParameters/" -d TRAVIS_BRANCH=latest push: rsync -auvz --progress . chenqian@106.14.227.239:/tmp/docker_script +tag: + git tag -d 0.17; git push origin :refs/tags/0.17;git tag -a 0.17 -m "0.17";git push origin 0.17 diff --git a/activemq/jetty-realm.properties b/activemq/jetty-realm.properties new file mode 100644 index 0000000..a3c1553 --- /dev/null +++ b/activemq/jetty-realm.properties @@ -0,0 +1,21 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- + +# Defines users that can access the web (console, demo, etc.) +# username: password [,rolename ...] +admin: pa44w0rd, admin +user: user, user \ No newline at end of file diff --git a/activemq/jetty.xml b/activemq/jetty.xml new file mode 100644 index 0000000..eff8628 --- /dev/null +++ b/activemq/jetty.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + index.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/activemq/start.sh b/activemq/start.sh new file mode 100644 index 0000000..55f8c6c --- /dev/null +++ b/activemq/start.sh @@ -0,0 +1,6 @@ +docker run -d --name activemq -p 61616:61616 -p 8161:8161 \ + -v ${PWD}/jetty.xml:/opt/apache-activemq-5.16.2/conf/jetty.xml \ + -v ${PWD}/jetty-realm.properties:/opt/apache-activemq-5.16.2/conf/jetty-realm.properties \ + symptoma/activemq:5.16.2 + + diff --git a/activemq/stop.sh b/activemq/stop.sh new file mode 100644 index 0000000..a4b9e22 --- /dev/null +++ b/activemq/stop.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker rm -f activemq diff --git a/aliyun/ecs_create_linux b/aliyun/ecs_create_linux new file mode 100755 index 0000000..1e434fe --- /dev/null +++ b/aliyun/ecs_create_linux @@ -0,0 +1,173 @@ +#!/usr/bin/env python +# coding=utf-8 +import os +import sys +import json +import time +import traceback +import datetime +import util +# import config + +from aliyunsdkcore.client import AcsClient +from aliyunsdkcore.acs_exception.exceptions import ClientException, ServerException +from aliyunsdkecs.request.v20140526.RunInstancesRequest import RunInstancesRequest +from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest + +home_path = os.path.expanduser('~') +cache_path = os.path.join(home_path, '.aliyuncq') +file_name = cache_path + '/config.json' +config = {} + + +RUNNING_STATUS = 'Running' +CHECK_INTERVAL = 3 +CHECK_TIMEOUT = 180 + + +class AliyunRunInstancesExample(object): + + def __init__(self): + self.access_id = config['AccessKey_ID'] + self.access_secret = config['AccessKey_Secret'] + + # 是否只预检此次请求。true:发送检查请求,不会创建实例,也不会产生费用;false:发送正常请求,通过检查后直接创建实例,并直接产生费用 + self.dry_run = False + # 实例所属的地域ID + self.region_id = config['region_id'] + # 实例的资源规格 + self.instance_type = 'ecs.n1.tiny' + # 实例的计费方式 + self.instance_charge_type = 'PostPaid' + # 镜像ID + self.image_id = 'centos_7_04_64_20G_alibase_201701015.vhd' + # 指定新创建实例所属于的安全组ID + self.security_group_id = 'sg-bp1b5tdc69ihvoy355mk' + # 购买资源的时长 + self.period = 1 + # 购买资源的时长单位 + self.period_unit = 'Hourly' + # 实例所属的可用区编号 + self.zone_id = config['zone_id'] + # 网络计费类型 + self.internet_charge_type = 'PayByBandwidth' + # 虚拟交换机ID + self.vswitch_id = 'vsw-bp1yejv7kvyl6nesvb4oc' + # 实例名称 + self.instance_name = config['Host_name'] + # 实例的密码 + self.password = config['Password'] + # 指定创建ECS实例的数量 + self.amount = 1 + # 公网出带宽最大值 + self.internet_max_bandwidth_out = 1 + # 是否为I/O优化实例 + self.io_optimized = 'optimized' + # 是否开启安全加固 + self.security_enhancement_strategy = 'Active' + # 自动释放时间 + self.auto_release_time = util.formatutc(config['Release_time']) + # 系统盘大小 + self.system_disk_size = '20' + # 系统盘的磁盘种类 + self.system_disk_category = 'cloud_efficiency' + + self.client = AcsClient(self.access_id, self.access_secret, self.region_id) + + def run(self): + try: + ids = self.run_instances() + self._check_instances_status(ids) + except ClientException as e: + print('Fail. Something with your connection with Aliyun go incorrect.' + ' Code: {code}, Message: {msg}' + .format(code=e.error_code, msg=e.message)) + except ServerException as e: + print('Fail. Business error.' + ' Code: {code}, Message: {msg}' + .format(code=e.error_code, msg=e.message)) + except Exception: + print('Unhandled error') + print(traceback.format_exc()) + + def run_instances(self): + """ + 调用创建实例的API,得到实例ID后继续查询实例状态 + :return:instance_ids 需要检查的实例ID + """ + request = RunInstancesRequest() + + request.set_DryRun(self.dry_run) + + request.set_InstanceType(self.instance_type) + request.set_InstanceChargeType(self.instance_charge_type) + request.set_ImageId(self.image_id) + request.set_SecurityGroupId(self.security_group_id) + request.set_Period(self.period) + request.set_PeriodUnit(self.period_unit) + request.set_ZoneId(self.zone_id) + request.set_InternetChargeType(self.internet_charge_type) + request.set_VSwitchId(self.vswitch_id) + request.set_InstanceName(self.instance_name) + request.set_Password(self.password) + request.set_Amount(self.amount) + request.set_InternetMaxBandwidthOut(self.internet_max_bandwidth_out) + request.set_IoOptimized(self.io_optimized) + request.set_SecurityEnhancementStrategy(self.security_enhancement_strategy) + request.set_AutoReleaseTime(self.auto_release_time) + request.set_SystemDiskSize(self.system_disk_size) + request.set_SystemDiskCategory(self.system_disk_category) + request.set_HostName(self.instance_name) + + body = self.client.do_action_with_exception(request) + data = json.loads(body) + instance_ids = data['InstanceIdSets']['InstanceIdSet'] + print('Success. Instance creation succeed. InstanceIds: {}'.format(', '.join(instance_ids))) + print(data) + return instance_ids + + def _check_instances_status(self, instance_ids): + """ + 每3秒中检查一次实例的状态,超时时间设为3分钟。 + :param instance_ids 需要检查的实例ID + :return: + """ + start = time.time() + while True: + request = DescribeInstancesRequest() + request.set_InstanceIds(json.dumps(instance_ids)) + body = self.client.do_action_with_exception(request) + data = json.loads(body) + # print(data) + for instance in data['Instances']['Instance']: + if RUNNING_STATUS in instance['Status']: + instance_ids.remove(instance['InstanceId']) + print('Instance boot successfully: {}, ip:{}'.format(instance['InstanceId'],instance['PublicIpAddress']['IpAddress'][0])) + + if not instance_ids: + print('Instances all boot successfully') + break + + if time.time() - start > CHECK_TIMEOUT: + print('Instances boot failed within {timeout}s: {ids}' + .format(timeout=CHECK_TIMEOUT, ids=', '.join(instance_ids))) + break + + time.sleep(CHECK_INTERVAL) + + +if __name__ == '__main__': + if len(sys.argv) <2: + print("python create_linux.py '5' 'hostname'") + sys.exit(1) + release_time=(datetime.datetime.now()+datetime.timedelta(hours=int(sys.argv[1]))).strftime("%Y-%m-%d %H:%M:%S") + + config = util.read_config(file_name) + + config['Release_time'] = release_time + config['Host_name'] = sys.argv[2] + print (config) + # print(config.Host_name) + # print(config.Release_time) + + AliyunRunInstancesExample().run() diff --git a/asposeword/Dockerfile b/asposeword/Dockerfile new file mode 100644 index 0000000..33c1e9a --- /dev/null +++ b/asposeword/Dockerfile @@ -0,0 +1,30 @@ +# Use an official OpenJDK runtime as a parent image +FROM openjdk:11-slim + +# Install Python and Flask +RUN apt-get update && apt-get install -y python3 python3-pip +RUN pip3 install flask + +RUN apt-get install -y fonts-wqy-zenhei && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Download and install Aspose.Words for Java +# Note: You need to have the Aspose.Words for Java JAR file in your project directory +# If you have a license file, you should also copy it to the container +COPY aspose-words-20.12-jdk17-cracked.jar /app/lib/aspose-words.jar + +# Compile the Java program +RUN javac -cp .:lib/aspose-words.jar Office2TextTest.java + +# Expose the port the app runs on +EXPOSE 5000 + +# Run the Flask app +CMD ["python3", "app.py"] diff --git a/asposeword/Makefile b/asposeword/Makefile new file mode 100644 index 0000000..12ff94f --- /dev/null +++ b/asposeword/Makefile @@ -0,0 +1,11 @@ +build: + docker build -t office2pdf . +run: + @docker rm -f aspoffice + docker run --name aspoffice -d -p 5000:5000 -v $(pwd):/app office2pdf + +test: + curl -X POST http://116.236.69.90:5000/convert \ + -F "file=@供应链台账系统项目技术开发委托合同(1).doc" \ + -F "target_format=pdf" \ + -o outputfile.pdf diff --git a/asposeword/Office2PdfTest.java b/asposeword/Office2PdfTest.java new file mode 100644 index 0000000..d54ba08 --- /dev/null +++ b/asposeword/Office2PdfTest.java @@ -0,0 +1,28 @@ +import com.aspose.words.Document; +import com.aspose.words.SaveFormat; + +import java.io.File; +import java.io.FileOutputStream; + +public class Office2PdfTest { + public static void main(String[] args) { + if (args.length < 2) { + System.out.println("Usage: java Office2PdfTest "); + return; + } + + try { + String src = args[0]; + String dst = args[1]; + long start = System.currentTimeMillis(); + File file = new File(dst); + FileOutputStream os = new FileOutputStream(file); + Document doc = new Document(src); + doc.save(os, SaveFormat.PDF); + os.close(); + System.out.println("convert cost " + (System.currentTimeMillis() - start) + "ms"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/asposeword/Office2TextTest.java b/asposeword/Office2TextTest.java new file mode 100644 index 0000000..1cbab49 --- /dev/null +++ b/asposeword/Office2TextTest.java @@ -0,0 +1,28 @@ +import com.aspose.words.Document; +import com.aspose.words.SaveFormat; + +import java.io.File; +import java.io.FileOutputStream; + +public class Office2TextTest { + public static void main(String[] args) { + if (args.length < 2) { + System.out.println("Usage: java Office2PdfTest "); + return; + } + + try { + String src = args[0]; + String dst = args[1]; + long start = System.currentTimeMillis(); + File file = new File(dst); + FileOutputStream os = new FileOutputStream(file); + Document doc = new Document(src); + doc.save(os, SaveFormat.TEXT); + os.close(); + System.out.println("convert cost " + (System.currentTimeMillis() - start) + "ms"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/asposeword/app.py b/asposeword/app.py new file mode 100644 index 0000000..d9a8ece --- /dev/null +++ b/asposeword/app.py @@ -0,0 +1,41 @@ +import os +import subprocess +from flask import Flask, request, send_file + +app = Flask(__name__) + +@app.route('/convert', methods=['POST']) +def convert(): + if 'file' not in request.files: + return 'No file part', 400 + file = request.files['file'] + if file.filename == '': + return 'No selected file', 400 + if 'target_format' not in request.form: + return 'No target format specified', 400 + + target_format = request.form['target_format'] + allowed_formats = ['pdf','txt'] + + if target_format not in allowed_formats: + return f'Invalid target format. Allowed formats are: {", ".join(allowed_formats)}', 400 + + if file: + input_path = os.path.join('/tmp', file.filename) + output_filename = file.filename.rsplit('.', 1)[0] + '.' + target_format + output_path = os.path.join('/tmp', output_filename) + file.save(input_path) + + # Call the Java program to convert the file + try: + subprocess.run(['java', '-cp', '.:lib/aspose-words.jar', 'Office2TextTest', input_path, output_path], check=True) + except subprocess.CalledProcessError as e: + return f'Conversion failed: {e}', 500 + + if not os.path.exists(output_path): + return 'Conversion failed', 500 + + return send_file(output_path, as_attachment=True) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/asposeword/aspose-words-20.12-jdk17-cracked.jar b/asposeword/aspose-words-20.12-jdk17-cracked.jar new file mode 100644 index 0000000..a5c4c8f Binary files /dev/null and b/asposeword/aspose-words-20.12-jdk17-cracked.jar differ diff --git a/docker/config.sh b/docker/config.sh index c8c56b9..7b888e7 100644 --- a/docker/config.sh +++ b/docker/config.sh @@ -1,9 +1,13 @@ #!/bin/bash -DOCKER_PACKAGE_URL=https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz +#DOCKER_PACKAGE_URL=https://download.docker.com/linux/static/stable/x86_64/docker-19.03.14.tgz +DOCKER_PACKAGE_URL=https://download.docker.com/linux/static/stable/x86_64/docker-24.0.4.tgz + # https://github.com/docker/compose/releases/download/1.21.2/docker-compose-Linux-x86_64 -DOCKER_COMPOSE_URL="https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m)" +# DOCKER_COMPOSE_URL="https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" +DOCKER_COMPOSE_URL="https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" + export DOCKER_PACKAGE=${DOCKER_PACKAGE_URL##*/} export DOCKER_COMPOSE=${DOCKER_COMPOSE_URL##*/} diff --git a/docker/install-docker_new.sh b/docker/install-docker_new.sh index cd6c7fa..ae65abd 100644 --- a/docker/install-docker_new.sh +++ b/docker/install-docker_new.sh @@ -4,8 +4,8 @@ source ./config.sh # Download docker echo "download: ${DOCKER_PACKAGE_URL}" echo "download: ${DOCKER_COMPOSE_URL}" -wget -N -c $DOCKER_PACKAGE_URL -O ${DOCKER_PACKAGE} -wget -N -c $DOCKER_COMPOSE_URL -O ${DOCKER_COMPOSE} +wget -N -c $DOCKER_PACKAGE_URL --no-check-certificate -O ${DOCKER_PACKAGE} +wget -N -c $DOCKER_COMPOSE_URL --no-check-certificate -O ${DOCKER_COMPOSE} if [ $? -eq 0 ]; then echo "download docker files succeed!" else @@ -19,7 +19,8 @@ SCRIPT_PATH=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) : ${DOCKER_PACKAGE:=docker-18.06.0-ce.tar.gz} : ${DOCKER_COMPOSE_PACKAGE:=docker-compose-1.21.2-Linux-x86_64.tar.gz} -: ${DOCKER_ACCESS_PORT:="-H unix:///var/run/docker.sock -H 0.0.0.0:2375"} +# : ${DOCKER_ACCESS_PORT:="-H unix:///var/run/docker.sock -H 0.0.0.0:2375"} +: ${DOCKER_ACCESS_PORT:="-H unix:///var/run/docker.sock "} : ${DOCKER_DATA_ROOT:=/opt/docker/data} : ${PRIVATE_REGISTRY:=127.0.0.1} : ${REGISTRY_PORT:=5000} @@ -86,7 +87,7 @@ sudo systemctl restart dockerd.service mkdir -p /etc/docker && \ tee /etc/docker/daemon.json <<-EOF { - "graph": "${DOCKER_DATA_ROOT}", + "data-root": "${DOCKER_DATA_ROOT}", "insecure-registries": [ "${PRIVATE_REGISTRY}:${REGISTRY_PORT}" ], diff --git a/elasticsearch/config.sh b/elasticsearch/config.sh index 932f696..ba9bfdb 100644 --- a/elasticsearch/config.sh +++ b/elasticsearch/config.sh @@ -1,6 +1,6 @@ #!/bin/bash CONTAINER_NAME=myes -ESIMAGE=elasticsearch:5.4.3 +ESIMAGE=elasticsearch:7.3.2 ES_IP=localhost diff --git a/elasticsearch/config/jvm.options b/elasticsearch/config/jvm.options new file mode 100644 index 0000000..0e2f13b --- /dev/null +++ b/elasticsearch/config/jvm.options @@ -0,0 +1,119 @@ +## JVM configuration + +################################################################ +## IMPORTANT: JVM heap size +################################################################ +## +## You should always set the min and max JVM heap +## size to the same value. For example, to set +## the heap to 4 GB, set: +## +## -Xms4g +## -Xmx4g +## +## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html +## for more information +## +################################################################ + +# Xms represents the initial size of total heap space +# Xmx represents the maximum size of total heap space + +-Xms1g +-Xmx1g + +################################################################ +## Expert settings +################################################################ +## +## All settings below this section are considered +## expert settings. Don't tamper with them unless +## you understand what you are doing +## +################################################################ + +## GC configuration +-XX:+UseConcMarkSweepGC +-XX:CMSInitiatingOccupancyFraction=75 +-XX:+UseCMSInitiatingOccupancyOnly + +## G1GC Configuration +# NOTE: G1GC is only supported on JDK version 10 or later. +# To use G1GC uncomment the lines below. +# 10-:-XX:-UseConcMarkSweepGC +# 10-:-XX:-UseCMSInitiatingOccupancyOnly +# 10-:-XX:+UseG1GC +# 10-:-XX:InitiatingHeapOccupancyPercent=75 + +## DNS cache policy +# cache ttl in seconds for positive DNS lookups noting that this overrides the +# JDK security property networkaddress.cache.ttl; set to -1 to cache forever +-Des.networkaddress.cache.ttl=60 +# cache ttl in seconds for negative DNS lookups noting that this overrides the +# JDK security property networkaddress.cache.negative ttl; set to -1 to cache +# forever +-Des.networkaddress.cache.negative.ttl=10 + +## optimizations + +# pre-touch memory pages used by the JVM during initialization +-XX:+AlwaysPreTouch + +## basic + +# explicitly set the stack size +-Xss1m + +# set to headless, just in case +-Djava.awt.headless=true + +# ensure UTF-8 encoding by default (e.g. filenames) +-Dfile.encoding=UTF-8 + +# use our provided JNA always versus the system one +-Djna.nosys=true + +# turn off a JDK optimization that throws away stack traces for common +# exceptions because stack traces are important for debugging +-XX:-OmitStackTraceInFastThrow + +# flags to configure Netty +-Dio.netty.noUnsafe=true +-Dio.netty.noKeySetOptimization=true +-Dio.netty.recycler.maxCapacityPerThread=0 + +# log4j 2 +-Dlog4j.shutdownHookEnabled=false +-Dlog4j2.disable.jmx=true + +-Djava.io.tmpdir=${ES_TMPDIR} + +## heap dumps + +# generate a heap dump when an allocation from the Java heap fails +# heap dumps are created in the working directory of the JVM +-XX:+HeapDumpOnOutOfMemoryError + +# specify an alternative path for heap dumps; ensure the directory exists and +# has sufficient space +-XX:HeapDumpPath=data + +# specify an alternative path for JVM fatal error logs +-XX:ErrorFile=logs/hs_err_pid%p.log + +## JDK 8 GC logging + +8:-XX:+PrintGCDetails +8:-XX:+PrintGCDateStamps +8:-XX:+PrintTenuringDistribution +8:-XX:+PrintGCApplicationStoppedTime +8:-Xloggc:logs/gc.log +8:-XX:+UseGCLogFileRotation +8:-XX:NumberOfGCLogFiles=32 +8:-XX:GCLogFileSize=64m + +# JDK 9+ GC logging +9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m +# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise +# time/date parsing will break in an incompatible way for some date patterns and locals +9-:-Djava.locale.providers=COMPAT diff --git a/elasticsearch/docker-compose.yml b/elasticsearch/docker-compose.yml index 58bf434..648cd9b 100644 --- a/elasticsearch/docker-compose.yml +++ b/elasticsearch/docker-compose.yml @@ -1,7 +1,7 @@ version: '2.2' services: elasticsearch: - image: elasticsearch:5.4.3 + image: elasticsearch:7.3.2 container_name: elasticsearch ports: - 9200:9200 diff --git a/elasticsearch/install.sh b/elasticsearch/install.sh index a72e66b..967c300 100644 --- a/elasticsearch/install.sh +++ b/elasticsearch/install.sh @@ -1,2 +1,3 @@ #!/bin/bash -docker pull elasticsearch:5.4.3 +source ./config.sh +docker pull ${ESIMAGE} diff --git a/elasticsearch/readme.md b/elasticsearch/readme.md index 25c913c..43b5a67 100644 --- a/elasticsearch/readme.md +++ b/elasticsearch/readme.md @@ -1,3 +1,6 @@ +## 设置内存 +echo "vm.max_map_count=262144" >> /etc/sysctl.conf +sysctl -p # 测试分词 # 安装分词 diff --git a/elasticsearch/start_service.sh b/elasticsearch/start_service.sh index f6dd979..1e05606 100644 --- a/elasticsearch/start_service.sh +++ b/elasticsearch/start_service.sh @@ -1,11 +1,7 @@ #!/bin/bash -. config.sh +. ./config.sh docker run \ -p 9200:9200 \ - -v ${ES_DATA}:/usr/share/elasticsearch/data \ - -v ${ES_CONFIG}:/usr/share/elasticsearch/config \ - -v ${ES_PLUGINS}:/usr/share/elasticsearch/plugins \ - -v ${ES_BACKUP}:/tmp/es_backup \ -e TAKE_FILE_OWNERSHIP=111 \ --name ${CONTAINER_NAME} -d ${ESIMAGE} diff --git a/elk/Makefile b/elk/Makefile new file mode 100644 index 0000000..c794cb7 --- /dev/null +++ b/elk/Makefile @@ -0,0 +1,4 @@ +scp: + rsync -auvz --progress --exclude-from rsync.exclude . root@node2:/root/elk + rsync -auvz --progress --exclude-from rsync.exclude . watch@sdzabbix:/opt/apps/elk + diff --git a/elk/kibana/config/kibana.yml b/elk/kibana/config/kibana.yml new file mode 100644 index 0000000..c6962e6 --- /dev/null +++ b/elk/kibana/config/kibana.yml @@ -0,0 +1,102 @@ +# Default Kibana 5 file from https://github.com/elastic/kibana/blob/master/config/kibana.yml +# +# Kibana is served by a back end server. This setting specifies the port to use. +#server.port: 5601 + +# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. +# The default is 'localhost', which usually means remote machines will not be able to connect. +# To allow connections from remote users, set this parameter to a non-loopback address. +server.host: "0.0.0.0" + +# Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects +# the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests +# to Kibana. This setting cannot end in a slash. +#server.basePath: "" + +# The maximum payload size in bytes for incoming server requests. +#server.maxPayloadBytes: 1048576 + +# The Kibana server's name. This is used for display purposes. +#server.name: "your-hostname" + +# The URL of the Elasticsearch instance to use for all your queries. +#elasticsearch.url: "http://localhost:9200" + +# When this setting’s value is true Kibana uses the hostname specified in the server.host +# setting. When the value of this setting is false, Kibana uses the hostname of the host +# that connects to this Kibana instance. +#elasticsearch.preserveHost: true + +# Kibana uses an index in Elasticsearch to store saved searches, visualizations and +# dashboards. Kibana creates a new index if the index doesn’t already exist. +#kibana.index: ".kibana" + +# The default application to load. +#kibana.defaultAppId: "discover" + +# If your Elasticsearch is protected with basic authentication, these settings provide +# the username and password that the Kibana server uses to perform maintenance on the Kibana +# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which +# is proxied through the Kibana server. +#elasticsearch.username: "user" +#elasticsearch.password: "pass" + +# Paths to the PEM-format SSL certificate and SSL key files, respectively. These +# files enable SSL for outgoing requests from the Kibana server to the browser. +#server.ssl.cert: /path/to/your/server.crt +#server.ssl.key: /path/to/your/server.key + +# Optional settings that provide the paths to the PEM-format SSL certificate and key files. +# These files validate that your Elasticsearch backend uses the same key files. +#elasticsearch.ssl.cert: /path/to/your/client.crt +#elasticsearch.ssl.key: /path/to/your/client.key + +# Optional setting that enables you to specify a path to the PEM file for the certificate +# authority for your Elasticsearch instance. +#elasticsearch.ssl.ca: /path/to/your/CA.pem + +# To disregard the validity of SSL certificates, change this setting’s value to false. +#elasticsearch.ssl.verify: true + +# Time in milliseconds to wait for Elasticsearch to respond to pings. Defaults to the value of +# the elasticsearch.requestTimeout setting. +#elasticsearch.pingTimeout: 1500 + +# Time in milliseconds to wait for responses from the back end or Elasticsearch. This value +# must be a positive integer. +#elasticsearch.requestTimeout: 30000 + +# List of Kibana client-side headers to send to Elasticsearch. To send *no* client-side +# headers, set this value to [] (an empty list). +#elasticsearch.requestHeadersWhitelist: [ authorization ] + +# Header names and values that are sent to Elasticsearch. Any custom headers cannot be overwritten +# by client-side headers, regardless of the elasticsearch.requestHeadersWhitelist configuration. +#elasticsearch.customHeaders: {} + +# Time in milliseconds for Elasticsearch to wait for responses from shards. Set to 0 to disable. +#elasticsearch.shardTimeout: 0 + +# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying. +#elasticsearch.startupTimeout: 5000 + +# Specifies the path where Kibana creates the process ID file. +#pid.file: /var/run/kibana.pid + +# Enables you specify a file where Kibana stores log output. +#logging.dest: stdout + +# Set the value of this setting to true to suppress all logging output. +#logging.silent: false + +# Set the value of this setting to true to suppress all logging output other than error messages. +#logging.quiet: false + +# Set the value of this setting to true to log all events, including system usage information +# and all requests. +#logging.verbose: false + +# Set the interval in milliseconds to sample system and process performance +# metrics. Minimum is 100ms. Defaults to 5000. +#ops.interval: 5000 +i18n.locale: "zh-CN" diff --git a/elk/logstash/conf.d/sample.conf b/elk/logstash/conf.d/sample.conf new file mode 100644 index 0000000..c6ea178 --- /dev/null +++ b/elk/logstash/conf.d/sample.conf @@ -0,0 +1 @@ +input { tcp {type => "waf" port => "5044" codec => "json"} } output { elasticsearch { hosts => ["localhost"] } } diff --git a/elk/logstash/log/logstash-plain.log b/elk/logstash/log/logstash-plain.log new file mode 100644 index 0000000..87de9f0 --- /dev/null +++ b/elk/logstash/log/logstash-plain.log @@ -0,0 +1,54 @@ +[2020-08-28T02:08:26,407][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/opt/logstash/data/queue"} +[2020-08-28T02:08:26,459][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/opt/logstash/data/dead_letter_queue"} +[2020-08-28T02:08:27,188][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.4.0"} +[2020-08-28T02:08:27,224][INFO ][logstash.agent ] No persistent UUID file found. Generating new UUID {:uuid=>"b85e37f1-e168-481e-ae31-355ef14f78e6", :path=>"/opt/logstash/data/uuid"} +[2020-08-28T02:08:29,388][INFO ][org.reflections.Reflections] Reflections took 58 ms to scan 1 urls, producing 20 keys and 40 values +[2020-08-28T02:08:30,421][INFO ][logstash.outputs.elasticsearch][main] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}} +[2020-08-28T02:08:30,635][WARN ][logstash.outputs.elasticsearch][main] Restored connection to ES instance {:url=>"http://localhost:9200/"} +[2020-08-28T02:08:30,715][INFO ][logstash.outputs.elasticsearch][main] ES Output version determined {:es_version=>7} +[2020-08-28T02:08:30,717][WARN ][logstash.outputs.elasticsearch][main] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>7} +[2020-08-28T02:08:30,774][INFO ][logstash.outputs.elasticsearch][main] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost"]} +[2020-08-28T02:08:30,935][INFO ][logstash.outputs.elasticsearch][main] Using default mapping template +[2020-08-28T02:08:30,947][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.specialized.RubyArrayOneObject) has been create for key: cluster_uuids. This may result in invalid serialization. It is recommended to log an issue to the responsible developer/development team. +[2020-08-28T02:08:31,039][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, :thread=>"#"} +[2020-08-28T02:08:31,234][INFO ][logstash.outputs.elasticsearch][main] Attempting to install template {:manage_template=>{"index_patterns"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s", "number_of_shards"=>1, "index.lifecycle.name"=>"logstash-policy", "index.lifecycle.rollover_alias"=>"logstash"}, "mappings"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}} +[2020-08-28T02:08:31,281][INFO ][logstash.outputs.elasticsearch][main] Installing elasticsearch template to _template/logstash +[2020-08-28T02:08:31,600][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"} +[2020-08-28T02:08:31,713][INFO ][logstash.inputs.tcp ][main] Starting tcp input listener {:address=>"0.0.0.0:5044", :ssl_enable=>"false"} +[2020-08-28T02:08:31,873][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]} +[2020-08-28T02:08:32,091][INFO ][logstash.outputs.elasticsearch][main] Creating rollover alias +[2020-08-28T02:08:32,644][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600} +[2020-08-28T02:08:32,913][INFO ][logstash.outputs.elasticsearch][main] Installing ILM policy {"policy"=>{"phases"=>{"hot"=>{"actions"=>{"rollover"=>{"max_size"=>"50gb", "max_age"=>"30d"}}}}}} to _ilm/policy/logstash-policy +[2020-08-28T02:09:03,554][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"PUT /test HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 127.0.0.1:5044\r\nAccept: */*\r\ncontent-type: application/json\r\nContent-Length: 53\r\n\r\n{ \"name\" : \"troy\", \"pwd\" : \"今天发苹果吃了 \" }"} +[2020-08-28T02:09:21,638][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"PUT /test HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 127.0.0.1:5044\r\nAccept: */*\r\ncontent-type: application/json\r\nContent-Length: 53\r\n\r\n{ \"name\" : \"troy\", \"pwd\" : \"今天发苹果西瓜 \" }"} +[2020-08-28T02:18:27,285][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"{\"host\":\"www.gosdwan.com\",\"upstream_connect_time\":\"0.011\",\"status\":\"200\",\"bytes_sent\":\"59213\",\"request_start_time\":\"2020-08-28 11:07:11\",\"upstream_addr\":\"127.0.0.1:4443\",\"headers\":{\"host\":\"www.gosdwan.com\",\"connection\":\"keep-alive\",\"sec-fetch-site\":\"cross-site\",\"upgrade-insecure-requests\":\"1\",\"cache-control\":\"max-age=0\",\"sec-fetch-mode\":\"navigate\",\"accept-encoding\":\"gzip, deflate, br\",\"user-agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"sec-fetch-dest\":\"document\",\"accept\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,image\\/apng,*\\/*;q=0.8,application\\/signed-exchange;v=b3;q=0.9\"},\"log_type\":\"access_log\",\"query_string\":\"\",\"upstream_bytes_received\":\"59114\",\"request_time\":\"0.145\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"703\",\"upstre"} +[2020-08-28T02:18:27,288][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"am_response_time\":\"0.142\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"eb0bbffc-27a1-44fd-9cd7-46c2dfb00dc2\",\"uri\":\"\\/\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:30,290][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"{\"host\":\"www.gosdwan.com\",\"upstream_connect_time\":\"0.010\",\"status\":\"200\",\"bytes_sent\":\"5189\",\"request_start_time\":\"2020-08-28 11:07:13\",\"upstream_addr\":\"127.0.0.1:4443\",\"headers\":{\"host\":\"www.gosdwan.com\",\"connection\":\"keep-alive\",\"sec-fetch-site\":\"same-origin\",\"sec-fetch-dest\":\"style\",\"sec-fetch-mode\":\"no-cors\",\"accept-encoding\":\"gzip, deflate, br\",\"user-agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"referer\":\"https:\\/\\/www.gosdwan.com\\/\",\"accept\":\"text\\/css,*\\/*;q=0.1\"},\"log_type\":\"access_log\",\"query_string\":\"v=52\",\"upstream_bytes_received\":\"5171\",\"request_time\":\"0.011\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"621\",\"upstream_response_time\":\"0.010\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"ed5d59bd-1c4b-4067-a88"} +[2020-08-28T02:18:30,291][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"2-1614e8e4b1ad\",\"uri\":\"\\/themes\\/xinhang\\/public\\/assets\\/css\\/common.css\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:31,814][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"ike Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"referer\":\"https:\\/\\/www.gosdwan.com\\/\",\"accept\":\"image\\/webp,image\\/apng,image\\/*,*\\/*;q=0.8\"},\"log_type\":\"access_log\",\"query_string\":\"\",\"upstream_bytes_received\":\"95428\",\"request_time\":\"0.013\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"654\",\"upstream_response_time\":\"0.008\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"704ca682-e39c-4012-be75-04be6b1bc3f1\",\"uri\":\"\\/upload\\/default\\/20200512\\/56de5fa35eecd950ab56b81e3f8a71a8.jpg\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:37,635][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"od\":\"GET\",\"upstream_bytes_sent\":\"654\",\"upstream_response_time\":\"0.009\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"65899359-f7de-4b11-b97b-16d60c42b5a0\",\"uri\":\"\\/upload\\/default\\/20200405\\/7b19ee057d82776788dcbbeb3931faee.png\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} diff --git a/elk/logstash/log/logstash.err b/elk/logstash/log/logstash.err new file mode 100644 index 0000000..2efca49 --- /dev/null +++ b/elk/logstash/log/logstash.err @@ -0,0 +1 @@ +Thread.exclusive is deprecated, use Thread::Mutex diff --git a/elk/logstash/log/logstash.stdout b/elk/logstash/log/logstash.stdout new file mode 100644 index 0000000..ad1b2ec --- /dev/null +++ b/elk/logstash/log/logstash.stdout @@ -0,0 +1,364 @@ +Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties +2020-08-28 02:08:26,264 main ERROR Unable to create file /var/log/logstash/logstash-slowlog-plain.log java.io.IOException: Permission denied + at java.io.UnixFileSystem.createFileExclusively(Native Method) + at java.io.File.createNewFile(File.java:1012) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:628) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608) + at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113) + at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,272 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@51a6af38] unable to create manager for [/var/log/logstash/logstash-slowlog-plain.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@1f234e35[pattern=/var/log/logstash/logstash-slowlog-plain-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=104857600)]), strategy=DefaultRolloverStrategy(min=1, max=30, useMax=true), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c] %.10000m%n, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@51a6af38] unable to create manager for [/var/log/logstash/logstash-slowlog-plain.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@1f234e35[pattern=/var/log/logstash/logstash-slowlog-plain-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=104857600)]), strategy=DefaultRolloverStrategy(min=1, max=30, useMax=true), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c] %.10000m%n, filePermissions=null, fileOwner=null]] + at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115) + at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,275 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,281 main ERROR Unable to create file /var/log/logstash/logstash-slowlog-plain.log java.io.IOException: Permission denied + at java.io.UnixFileSystem.createFileExclusively(Native Method) + at java.io.File.createNewFile(File.java:1012) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:628) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608) + at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113) + at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,286 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@51a6af38] unable to create manager for [/var/log/logstash/logstash-slowlog-plain.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@2461b519[pattern=/var/log/logstash/logstash-slowlog-plain-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=104857600)]), strategy=DefaultRolloverStrategy(min=1, max=30, useMax=true), advertiseURI=null, layout=org.apache.logging.log4j.core.layout.JsonLayout@361d56a3, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@51a6af38] unable to create manager for [/var/log/logstash/logstash-slowlog-plain.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@2461b519[pattern=/var/log/logstash/logstash-slowlog-plain-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=104857600)]), strategy=DefaultRolloverStrategy(min=1, max=30, useMax=true), advertiseURI=null, layout=org.apache.logging.log4j.core.layout.JsonLayout@361d56a3, filePermissions=null, fileOwner=null]] + at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115) + at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114) + at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145) + at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,289 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235) + at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899) + at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891) + at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514) + at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238) + at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250) + at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547) + at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619) + at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:605) + at org.logstash.log.LoggerExt.reconfigure(LoggerExt.java:160) + at org.logstash.log.LoggerExt$INVOKER$s$1$0$reconfigure.call(LoggerExt$INVOKER$s$1$0$reconfigure.gen) + at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:833) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:262) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0$__VARARGS__(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:1156) + at org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:1143) + at org.jruby.ir.targets.InstanceSuperInvokeSite.invoke(InstanceSuperInvokeSite.java:39) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0(/opt/logstash/logstash-core/lib/logstash/runner.rb:242) + at opt.logstash.logstash_minus_core.lib.logstash.runner.RUBY$method$run$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/runner.rb) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_0_dot_6_dot_5.lib.clamp.command.RUBY$method$run$0(/opt/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132) + at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) + at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) + at org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:183) + at opt.logstash.lib.bootstrap.environment.RUBY$script(/opt/logstash/lib/bootstrap/environment.rb:73) + at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) + at org.jruby.ir.Compiler$1.load(Compiler.java:89) + at org.jruby.Ruby.runScript(Ruby.java:854) + at org.jruby.Ruby.runNormally(Ruby.java:777) + at org.jruby.Ruby.runNormally(Ruby.java:795) + at org.jruby.Ruby.runFromMain(Ruby.java:607) + at org.logstash.Logstash.run(Logstash.java:102) + at org.logstash.Logstash.main(Logstash.java:45) + +2020-08-28 02:08:26,294 main ERROR Null object returned for RollingFile in Appenders. +2020-08-28 02:08:26,294 main ERROR Null object returned for RollingFile in Appenders. +2020-08-28 02:08:26,294 main ERROR Unable to locate appender "plain_rolling_slowlog" for logger config "slowlog" +[2020-08-28T02:08:26,407][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/opt/logstash/data/queue"} +[2020-08-28T02:08:26,459][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/opt/logstash/data/dead_letter_queue"} +[2020-08-28T02:08:27,188][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.4.0"} +[2020-08-28T02:08:27,224][INFO ][logstash.agent ] No persistent UUID file found. Generating new UUID {:uuid=>"b85e37f1-e168-481e-ae31-355ef14f78e6", :path=>"/opt/logstash/data/uuid"} +[2020-08-28T02:08:29,388][INFO ][org.reflections.Reflections] Reflections took 58 ms to scan 1 urls, producing 20 keys and 40 values +[2020-08-28T02:08:30,421][INFO ][logstash.outputs.elasticsearch][main] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}} +[2020-08-28T02:08:30,635][WARN ][logstash.outputs.elasticsearch][main] Restored connection to ES instance {:url=>"http://localhost:9200/"} +[2020-08-28T02:08:30,715][INFO ][logstash.outputs.elasticsearch][main] ES Output version determined {:es_version=>7} +[2020-08-28T02:08:30,717][WARN ][logstash.outputs.elasticsearch][main] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>7} +[2020-08-28T02:08:30,774][INFO ][logstash.outputs.elasticsearch][main] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost"]} +[2020-08-28T02:08:30,935][INFO ][logstash.outputs.elasticsearch][main] Using default mapping template +[2020-08-28T02:08:30,947][WARN ][org.logstash.instrument.metrics.gauge.LazyDelegatingGauge][main] A gauge metric of an unknown type (org.jruby.specialized.RubyArrayOneObject) has been create for key: cluster_uuids. This may result in invalid serialization. It is recommended to log an issue to the responsible developer/development team. +[2020-08-28T02:08:31,039][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, :thread=>"#"} +[2020-08-28T02:08:31,234][INFO ][logstash.outputs.elasticsearch][main] Attempting to install template {:manage_template=>{"index_patterns"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s", "number_of_shards"=>1, "index.lifecycle.name"=>"logstash-policy", "index.lifecycle.rollover_alias"=>"logstash"}, "mappings"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}} +[2020-08-28T02:08:31,281][INFO ][logstash.outputs.elasticsearch][main] Installing elasticsearch template to _template/logstash +[2020-08-28T02:08:31,600][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"} +[2020-08-28T02:08:31,713][INFO ][logstash.inputs.tcp ][main] Starting tcp input listener {:address=>"0.0.0.0:5044", :ssl_enable=>"false"} +[2020-08-28T02:08:31,873][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]} +[2020-08-28T02:08:32,091][INFO ][logstash.outputs.elasticsearch][main] Creating rollover alias +[2020-08-28T02:08:32,644][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600} +[2020-08-28T02:08:32,913][INFO ][logstash.outputs.elasticsearch][main] Installing ILM policy {"policy"=>{"phases"=>{"hot"=>{"actions"=>{"rollover"=>{"max_size"=>"50gb", "max_age"=>"30d"}}}}}} to _ilm/policy/logstash-policy +[2020-08-28T02:09:03,554][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"PUT /test HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 127.0.0.1:5044\r\nAccept: */*\r\ncontent-type: application/json\r\nContent-Length: 53\r\n\r\n{ \"name\" : \"troy\", \"pwd\" : \"今天发苹果吃了 \" }"} +[2020-08-28T02:09:21,638][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"PUT /test HTTP/1.1\r\nUser-Agent: curl/7.29.0\r\nHost: 127.0.0.1:5044\r\nAccept: */*\r\ncontent-type: application/json\r\nContent-Length: 53\r\n\r\n{ \"name\" : \"troy\", \"pwd\" : \"今天发苹果西瓜 \" }"} +[2020-08-28T02:18:27,285][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"{\"host\":\"www.gosdwan.com\",\"upstream_connect_time\":\"0.011\",\"status\":\"200\",\"bytes_sent\":\"59213\",\"request_start_time\":\"2020-08-28 11:07:11\",\"upstream_addr\":\"127.0.0.1:4443\",\"headers\":{\"host\":\"www.gosdwan.com\",\"connection\":\"keep-alive\",\"sec-fetch-site\":\"cross-site\",\"upgrade-insecure-requests\":\"1\",\"cache-control\":\"max-age=0\",\"sec-fetch-mode\":\"navigate\",\"accept-encoding\":\"gzip, deflate, br\",\"user-agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"sec-fetch-dest\":\"document\",\"accept\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,image\\/apng,*\\/*;q=0.8,application\\/signed-exchange;v=b3;q=0.9\"},\"log_type\":\"access_log\",\"query_string\":\"\",\"upstream_bytes_received\":\"59114\",\"request_time\":\"0.145\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"703\",\"upstre"} +[2020-08-28T02:18:27,288][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"am_response_time\":\"0.142\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"eb0bbffc-27a1-44fd-9cd7-46c2dfb00dc2\",\"uri\":\"\\/\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:30,290][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"{\"host\":\"www.gosdwan.com\",\"upstream_connect_time\":\"0.010\",\"status\":\"200\",\"bytes_sent\":\"5189\",\"request_start_time\":\"2020-08-28 11:07:13\",\"upstream_addr\":\"127.0.0.1:4443\",\"headers\":{\"host\":\"www.gosdwan.com\",\"connection\":\"keep-alive\",\"sec-fetch-site\":\"same-origin\",\"sec-fetch-dest\":\"style\",\"sec-fetch-mode\":\"no-cors\",\"accept-encoding\":\"gzip, deflate, br\",\"user-agent\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"referer\":\"https:\\/\\/www.gosdwan.com\\/\",\"accept\":\"text\\/css,*\\/*;q=0.1\"},\"log_type\":\"access_log\",\"query_string\":\"v=52\",\"upstream_bytes_received\":\"5171\",\"request_time\":\"0.011\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"621\",\"upstream_response_time\":\"0.010\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"ed5d59bd-1c4b-4067-a88"} +[2020-08-28T02:18:30,291][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"2-1614e8e4b1ad\",\"uri\":\"\\/themes\\/xinhang\\/public\\/assets\\/css\\/common.css\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:31,814][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"ike Gecko) Chrome\\/84.0.4147.135 Safari\\/537.36\",\"cookie\":\"Hm_lvt_26256c2cf87138576b62e00b88ab282e=1597852483; Hm_lpvt_26256c2cf87138576b62e00b88ab282e=1598146799\",\"accept-language\":\"zh-CN,zh;q=0.9\",\"referer\":\"https:\\/\\/www.gosdwan.com\\/\",\"accept\":\"image\\/webp,image\\/apng,image\\/*,*\\/*;q=0.8\"},\"log_type\":\"access_log\",\"query_string\":\"\",\"upstream_bytes_received\":\"95428\",\"request_time\":\"0.013\",\"upstream_status\":\"200\",\"method\":\"GET\",\"upstream_bytes_sent\":\"654\",\"upstream_response_time\":\"0.008\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"704ca682-e39c-4012-be75-04be6b1bc3f1\",\"uri\":\"\\/upload\\/default\\/20200512\\/56de5fa35eecd950ab56b81e3f8a71a8.jpg\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} +[2020-08-28T02:18:37,635][ERROR][logstash.codecs.json ][main] JSON parse error, original data now in message field {:error=>#, :data=>"od\":\"GET\",\"upstream_bytes_sent\":\"654\",\"upstream_response_time\":\"0.009\",\"access_info\":\"bypass_request\",\"remote_addr\":\"34.92.163.44\",\"version\":\"1.1\",\"uuid\":\"65899359-f7de-4b11-b97b-16d60c42b5a0\",\"uri\":\"\\/upload\\/default\\/20200405\\/7b19ee057d82776788dcbbeb3931faee.png\",\"access_type\":\"jxcheck_protection\",\"scheme\":\"https\",\"body\":\"\",\"xxf_addr\":\"34.92.163.44\"}\r\n"} diff --git a/elk/rsync.exclude b/elk/rsync.exclude new file mode 100644 index 0000000..764e420 --- /dev/null +++ b/elk/rsync.exclude @@ -0,0 +1 @@ +elk-data diff --git a/elk/start_elk.sh b/elk/start_elk.sh new file mode 100644 index 0000000..dc31eed --- /dev/null +++ b/elk/start_elk.sh @@ -0,0 +1,12 @@ +#!/bin/bash +docker run -dit --name elk \ + -p 5601:5601 \ + -p 9200:9200 \ + -p 5044:5044 \ + -v ${PWD}/logstash/conf.d:/etc/logstash/conf.d/ \ + -v ${PWD}/logstash/log:/var/log/logstash \ + -v ${PWD}/kibana/config/:/opt/kibana/config \ + -v ${PWD}/elk-data:/var/lib/elasticsearch \ + -v /etc/localtime:/etc/localtime \ + sebp/elk:740 + diff --git a/elk/stop_elk.sh b/elk/stop_elk.sh new file mode 100644 index 0000000..f8cc0a4 --- /dev/null +++ b/elk/stop_elk.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker rm -f elk diff --git a/filebeat/Makefile b/filebeat/Makefile new file mode 100644 index 0000000..cb1a613 --- /dev/null +++ b/filebeat/Makefile @@ -0,0 +1,8 @@ +run: + sh stop_service.sh && \ + rm -fr ./ret/zls_filebeat.txt && \ + touch ./ret/zls_filebeat.txt && \ + sh start_service.sh + +tail: + tail -f ./ret/zls_filebeat.txt diff --git a/filebeat/config/config.sh b/filebeat/config/config.sh new file mode 100644 index 0000000..9a8a401 --- /dev/null +++ b/filebeat/config/config.sh @@ -0,0 +1,15 @@ +#!/bin/bash +CONTAINER_NAME=filebeat +IMAGE=store/elastic/filebeat:7.3.2 +LOGSTASH_CONTAINER_NAME=logstash + + +# ES_IP=localhost +# ES_BACKUP=${PWD}/es_backup + +# ES_DATA=${PWD}/data +# ES_CONFIG=${PWD}/config +# ES_PLUGINS=${PWD}/plugins + +FILEBEAT_DATA=/tmp/openvpn_filter +export IMAGE diff --git a/filebeat/config/filebeat.docker.yml b/filebeat/config/filebeat.docker.yml new file mode 100644 index 0000000..4d25cab --- /dev/null +++ b/filebeat/config/filebeat.docker.yml @@ -0,0 +1,15 @@ +filebeat.inputs: +- type: log + enabled: true + paths: + - /logs/ovpn_filter.log + multiline.pattern: '^A' + multiline.negate: true + multiline.match: after + +output.logstash: + hosts: ["logstash:5044"] + +processors: +- drop_fields: + fields: ["log","host","input","agent","ecs"] diff --git a/filebeat/config/filebeat.docker.yml_bak b/filebeat/config/filebeat.docker.yml_bak new file mode 100644 index 0000000..5a68387 --- /dev/null +++ b/filebeat/config/filebeat.docker.yml_bak @@ -0,0 +1,22 @@ +filebeat.inputs: +- type: log + enabled: true + paths: + - /logs/elog_file.log + multiline.pattern: '^A' + multiline.negate: true + multiline.match: after + # 需要收集的日志所在的位置,可使用通配符进行配置 + #- /data/elk/*.log + # - /logs/*/*.log + +#日志输出配置(采用 logstash 收集日志,5044为logstash端口) +# output.logstash: +# hosts: ['172.17.0.1:5044'] +# +# output.file: +# path: "/tmp/ret" +# filename: "zls_filebeat.txt" + +output.logstash: + hosts: ["101.230.12.68": 5044] diff --git a/filebeat/config/filebeat.docker.yml_bak_new b/filebeat/config/filebeat.docker.yml_bak_new new file mode 100644 index 0000000..78c563c --- /dev/null +++ b/filebeat/config/filebeat.docker.yml_bak_new @@ -0,0 +1,11 @@ +filebeat.inputs: +- type: log + enabled: true + paths: + - /logs/ovpn_filter.log + multiline.pattern: '^A' + multiline.negate: true + multiline.match: after + +output.logstash: + hosts: ["logstash:5044"] diff --git a/filebeat/ret/.keep b/filebeat/ret/.keep new file mode 100644 index 0000000..e69de29 diff --git a/filebeat/start_service.sh b/filebeat/start_service.sh new file mode 100755 index 0000000..264b4ba --- /dev/null +++ b/filebeat/start_service.sh @@ -0,0 +1,25 @@ +#!/bin/bash +source ./config/config.sh +# docker run -p 5044:5044 -p 5045:5045 \ +# --name lst -d \ +# -v ${PWD}/config/logstash.conf:/usr/share/logstash/config/logstash.conf \ +# -v ${PWD}/config/logstash.yml:/usr/share/logstash/config/logstash.yml \ +# ${IMAGE} -f /usr/share/logstash/config/logstash.conf + +docker run \ + --link logstash:logstash \ + --restart=always \ + --log-driver json-file \ + --log-opt max-size=100m \ + --log-opt max-file=20 \ + --name filebeat \ + --user=root -d \ + -v ${FILEBEAT_DATA}:/logs/ \ + -v ${PWD}/ret:/tmp/ret/ \ + -v ${PWD}/config/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml \ + ${IMAGE} + + + + # -v /etc/localtime:/etc/localtime \ + # -v ${PWD}/ret:/tmp/ret/ \ diff --git a/filebeat/stop_service.sh b/filebeat/stop_service.sh new file mode 100755 index 0000000..f77abc8 --- /dev/null +++ b/filebeat/stop_service.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source ./config/config.sh +docker rm -f filebeat diff --git a/jenkins/config.sh b/jenkins/config.sh index 0c3cb2c..10c1263 100644 --- a/jenkins/config.sh +++ b/jenkins/config.sh @@ -18,7 +18,7 @@ JENKINS_URL=localhost:9090 # option #JENKINS_FILE=jenkinsci/jenkins:lts #JENKINS_FILE=jenkins/jenkins:2.153 -JENKINS_FILE=jenkinsci/jenkins:2.153 +JENKINS_FILE=jenkins/jenkins:latest DOCKER_CONTAINER_NAME=jenkins diff --git a/jenkins/install_docker_jenkins.sh b/jenkins/install_docker_jenkins.sh index 2cd4c79..7a1afa4 100644 --- a/jenkins/install_docker_jenkins.sh +++ b/jenkins/install_docker_jenkins.sh @@ -29,7 +29,7 @@ else fi -CMD_LIST=( harborcmd \ +CMD_LIST=( \ jq \ git \ ) @@ -59,11 +59,11 @@ function pull_imaegs(){ # ${HARBORCMD} pull sameersbn/gitlab:11.3.5 sameersbn/gitlab:11.3.5 # ${HARBORCMD} pull sameersbn/redis:latest sameersbn/redis:latest # ${HARBORCMD} pull sameersbn/postgresql:9.4-23 sameersbn/postgresql:9.4-23 - harborcmd pull ${JENKINS_FILE} ${JENKINS_FILE} + docker pull ${JENKINS_FILE} if [ $? -eq 0 ]; then - success "harborcmd pull ${JENKINS_FILE} " + success "docker pull ${JENKINS_FILE} " else - error "harborcmd pull ${JENKINS_FILE} " + error "docker pull ${JENKINS_FILE} " fi } diff --git a/kibana/Makefile b/kibana/Makefile new file mode 100644 index 0000000..5a75a57 --- /dev/null +++ b/kibana/Makefile @@ -0,0 +1,3 @@ +scp: + rsync -auvz --progress --exclude-from rsync.exclude . root@node2:/tmp + diff --git a/kibana/config.sh b/kibana/config.sh new file mode 100644 index 0000000..ce8cb12 --- /dev/null +++ b/kibana/config.sh @@ -0,0 +1,4 @@ +#!/bin/bash +ELASTICSEARCH_URL=http://35.189.156.87:9200 + +KIBANA_PORT=5601 diff --git a/kibana/kibana.yml b/kibana/kibana.yml new file mode 100644 index 0000000..81b69a6 --- /dev/null +++ b/kibana/kibana.yml @@ -0,0 +1,4 @@ +server.name: kibana +server.host: "0.0.0.0" +elasticsearch.hosts: [ "http://35.189.156.87:9200/" ] ## es地址 +i18n.locale: "zh-CN" diff --git a/kibana/rsync.exclude b/kibana/rsync.exclude new file mode 100644 index 0000000..764e420 --- /dev/null +++ b/kibana/rsync.exclude @@ -0,0 +1 @@ +elk-data diff --git a/kibana/start_service.sh b/kibana/start_service.sh new file mode 100644 index 0000000..4095095 --- /dev/null +++ b/kibana/start_service.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# docker pull docker.elastic.co/kibana/kibana:7.3.2 + +# docker run -it -d -e \ +# ELASTICSEARCH_URL=${ELASTICSEARCH_URL} \ +# --name kibana \ +# -p ${KIBANA_PORT}:5601 \ +# docker.elastic.co/kibana/kibana:7.3.2 + + +docker run -d --name kibana -p 5601:5601 -v ${PWD}/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.3.2 diff --git a/kibana/stop_service.sh b/kibana/stop_service.sh new file mode 100644 index 0000000..24c10ef --- /dev/null +++ b/kibana/stop_service.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker rm -f kibana diff --git a/letsencrypt/backup.sh b/letsencrypt/backup.sh new file mode 100755 index 0000000..c950070 --- /dev/null +++ b/letsencrypt/backup.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source ./config.sh +mkdir -p backup +cp -r ${https_folder} ./backup/ diff --git a/logstash/config/logstash.conf b/logstash/config/logstash.conf new file mode 100644 index 0000000..3fef080 --- /dev/null +++ b/logstash/config/logstash.conf @@ -0,0 +1,7 @@ +input { tcp {type => "waf" port => "5044" codec => "json"} } +filter { + grok { + match => { "message" => "%{WORD:method} / HTTP/%{NUMBER:http_version} Host" } + } +} +output { elasticsearch { hosts => ["192.168.31.100"] } } diff --git a/logstash/config/logstash.conf_bak b/logstash/config/logstash.conf_bak new file mode 100644 index 0000000..83d011e --- /dev/null +++ b/logstash/config/logstash.conf_bak @@ -0,0 +1,20 @@ +input +{ + tcp { + type => "waf" + port => "5044" + codec => "json" + } +} + +output +{ + stdout + { + codec => rubydebug + } + elasticsearch + { + hosts => ["http://34.96.174.126:9200"] + } +} diff --git a/logstash/config/logstash.yml b/logstash/config/logstash.yml new file mode 100644 index 0000000..e69de29 diff --git a/logstash/start_service.sh b/logstash/start_service.sh new file mode 100755 index 0000000..639a728 --- /dev/null +++ b/logstash/start_service.sh @@ -0,0 +1,10 @@ +#!/bin/bash +docker run -p 5044:5044 -p 5045:5045 \ + --name lst -d \ + -v ${PWD}/config/logstash.conf:/usr/share/logstash/config/logstash.conf \ + -v ${PWD}/config/logstash.yml:/usr/share/logstash/config/logstash.yml \ + logstash:7.3.2 -f /usr/share/logstash/config/logstash.conf + + + + # -v /etc/localtime:/etc/localtime \ diff --git a/logstash/stop_service.sh b/logstash/stop_service.sh new file mode 100755 index 0000000..5e2e7e6 --- /dev/null +++ b/logstash/stop_service.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker rm -f lst diff --git a/matomo/db.env b/matomo/db.env new file mode 100644 index 0000000..e6befd8 --- /dev/null +++ b/matomo/db.env @@ -0,0 +1,6 @@ +MATOMO_DATABASE_HOST=127.0.0.1 +MATOMO_DATABASE_ADAPTER=mysql +MATOMO_DATABASE_TABLES_PREFIX=matomo_ +MATOMO_DATABASE_USERNAME=matomo +MATOMO_DATABASE_PASSWORD=iPsmLXmdTGN7hdPr +MATOMO_DATABASE_DBNAME=matomo diff --git a/matomo/docker-compose.yml b/matomo/docker-compose.yml new file mode 100644 index 0000000..a30bbeb --- /dev/null +++ b/matomo/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3" + +services: + app: + image: matomo + restart: always + volumes: +# - ./config:/var/www/html/config +# - ./logs:/var/www/html/logs + - ${PWD}/matomo/html:/var/www/html + environment: + - MATOMO_DATABASE_HOST=117.78.19.194 + - TZ=Asia/Shanghai + env_file: + - ./db.env + ports: + - 127.0.0.1:18089:80 # 8080可以更改为别的未使用的端口 lsof -i:8080 可以查看8080端口是否被使用 + - 127.0.0.1:8443:443 # 8443可以更改为别的未使用的端口 这边后续填到NPM的“Custom location”里 +volumes: + db: + matomo: + diff --git a/matomo/start.sh b/matomo/start.sh new file mode 100644 index 0000000..2a67cfd --- /dev/null +++ b/matomo/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker-compose up -d diff --git a/matomo/stop.sh b/matomo/stop.sh new file mode 100644 index 0000000..489373b --- /dev/null +++ b/matomo/stop.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker-compose down diff --git a/mongo/docker-compose.yml b/mongo/docker-compose.yml index e12858e..3c4af5d 100644 --- a/mongo/docker-compose.yml +++ b/mongo/docker-compose.yml @@ -1,34 +1,16 @@ -version: '3.2' +version: '3.8' services: - mongo: - image: mongo:3.0.15 - container_name: mongo + mongodb: + image: mongo:6.0 ports: - - 11081:27017 + - '27017:27017' volumes: - - ${MONGO_DATA_DIR}:/data/db - - ${PWD}/auth.js:/tmp/auth.js + - ./mongo_data:/data/db + command: mongod --auth environment: - MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME} - MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD} + - MONGO_INITDB_ROOT_USERNAME=root #初始化管理员用户名和密码 + - MONGO_INITDB_ROOT_PASSWORD=123456 + tty: true +volumes: + dbdata6: - deploy: - placement: - constraints: [node.role == manager] - command: "--smallfiles" - - mongo-express: - image: mongo-express:0.49 - container_name: mongo-express - ports: - - 8081:8082 - environment: - ME_CONFIG_OPTIONS_EDITORTHEME: ambiance - - # express login user and password - ME_CONFIG_BASICAUTH_USERNAME: ${ME_CONFIG_BASICAUTH_USERNAME} - ME_CONFIG_BASICAUTH_PASSWORD: ${ME_CONFIG_BASICAUTH_PASSWORD} - - # mongodb admin user and password - ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_INITDB_ROOT_USERNAME} - ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_INITDB_ROOT_PASSWORD} diff --git a/mysql/backupdb.sh b/mysql/backupdb.sh index cf1f1d2..8bdbd82 100755 --- a/mysql/backupdb.sh +++ b/mysql/backupdb.sh @@ -1,7 +1,7 @@ #!/bin/bash source ./config.sh _os="`uname`" -_now=$(date +"%m_%d_%Y") +_now=$(date +"%m_%d_%Y_%H_%M_%S") LOGFILE=${LOG_PATH}/backupdb.log : ${BACK_FOLDER:=${MYSQL_BACKUP_FOLDER}} @@ -20,9 +20,10 @@ do # Export dump TMP_CONTAINER=epxport_tmpmysq; - EXPORT_COMMAND="mysqldump --databases ${DBNAME} -uroot -p$ROOT_PASSWORD" + #EXPORT_COMMAND="mysqldump -h${MYSQL_IP} --databases ${DBNAME} -uroot -p$ROOT_PASSWORD -x" + EXPORT_COMMAND="mysqldump -hmysql --databases ${DBNAME} -uroot -p$ROOT_PASSWORD -x" # docker-compose exec db sh -c "$EXPORT_COMMAND" > $BAK_FILE - #docker exec -it mysql /bin/bash -c "$EXPORT_COMMAND" > $BAK_FILE + #docker exec -i mysql /bin/bash -c "$EXPORT_COMMAND" > $BAK_FILE echo $EXPORT_COMMAND | tee -a ${LOGFILE} if [ "$USE_DOCKER" == "1" ]; then docker ps -a |grep ${TMP_CONTAINER} @@ -32,8 +33,9 @@ do else echo "容器不存在在,开始创建容器${TMP_CONTANER},导出数据" | tee -a ${LOGFILE} fi + echo "docker run -it --rm --name ${TMP_CONTAINER} --link ${CONTAINER_NAME}:mysql ${MYSQLIMAGE} /bin/bash -c " - docker run -it --rm --name ${TMP_CONTAINER} \ + docker run -i --rm --name ${TMP_CONTAINER} --link ${CONTAINER_NAME}:mysql \ ${MYSQLIMAGE} /bin/sh -c "$EXPORT_COMMAND" > $BAK_FILE else @@ -43,6 +45,7 @@ do if [ $? == 0 ] then echo "dump success: ${BAK_FILE}" | tee -a ${LOGFILE} + dding "备份成功: ${BAK_FILE}" else echo "dump fail" | tee -a ${LOGFILE} dding "mysql 备份失败,请注意 ${BAK_FILE}" @@ -50,10 +53,10 @@ do exit 1 fi - COMMAND="mysql -uroot -p${ROOT_PASSWORD} -e 'SHOW MASTER STATUS' " + COMMAND="mysql -hmysql -uroot -p${ROOT_PASSWORD} -e 'SHOW MASTER STATUS' " echo $COMMAND | tee -a ${LOGFILE}; if [ "$USE_DOCKER" == "1" ]; then - docker run -it --rm --name tmpmysql \ + docker run -i --rm --name tmpmysql --link ${CONTAINER_NAME}:mysql \ ${MYSQLIMAGE} /bin/sh -c "$COMMAND" else eval $COMMAND | tee -a ${LOGFILE} diff --git a/mysql/config.sh b/mysql/config.sh index c438df0..bb3ac51 100644 --- a/mysql/config.sh +++ b/mysql/config.sh @@ -41,7 +41,7 @@ BACK_DATABASE_NAME=( \ # 是否使用docker 方式, # 0 不使用,使用本地mysql命令 # 1 使用 -USE_DOKER=0 +USE_DOCKER=0 LOG_PATH=${PWD}/logs diff --git a/mysql/start_mysql_service.sh b/mysql/start_mysql_service.sh index 8aafdd0..d913847 100755 --- a/mysql/start_mysql_service.sh +++ b/mysql/start_mysql_service.sh @@ -3,6 +3,7 @@ #mysql.server start source ./config.sh docker run -p ${PORT}:3306 \ + -e TZ=Asia/Shanghai \ --name ${CONTAINER_NAME} \ -v ${DOCKER_MYSQL_CONFIG}:/etc/mysql/conf.d \ -v ${PWD}/mysql/data:/var/lib/mysql \ diff --git a/nginx/install_docker_nginx.sh b/nginx/install_docker_nginx.sh index ed4d472..96900a8 100644 --- a/nginx/install_docker_nginx.sh +++ b/nginx/install_docker_nginx.sh @@ -29,7 +29,7 @@ else fi -CMD_LIST=( harborcmd \ +CMD_LIST=( \ ) @@ -57,11 +57,11 @@ function pull_imaegs(){ # ${HARBORCMD} pull sameersbn/gitlab:11.3.5 sameersbn/gitlab:11.3.5 # ${HARBORCMD} pull sameersbn/redis:latest sameersbn/redis:latest # ${HARBORCMD} pull sameersbn/postgresql:9.4-23 sameersbn/postgresql:9.4-23 - harborcmd pull ${DOCKER_NGINX_FILE} ${DOCKER_NGINX_FILE} + docker pull ${DOCKER_NGINX_FILE} if [ $? -eq 0 ]; then - success "harborcmd pull ${DOCKER_NGINX_FILE} " + success "docker pull ${DOCKER_NGINX_FILE} " else - error "harborcmd pull ${DOCKER_NGINX_FILE} " + error "docker pull ${DOCKER_NGINX_FILE} " fi } diff --git a/nginx/start_nginx_service.sh b/nginx/start_nginx_service.sh index 3b7c5ad..efe1ede 100644 --- a/nginx/start_nginx_service.sh +++ b/nginx/start_nginx_service.sh @@ -42,6 +42,7 @@ docker run --restart=always --name http_static_server \ -v ${DOCKER_NGINX_VOLUME}:/usr/share/nginx/html:ro -d \ -v ${PWD}/htpasswd:/usr/local/nginx/conf/vhost/htpasswd \ -p ${PORT}:80 \ + -e TZ=Asia/Shanghai \ ${DOCKER_NGINX_FILE} success "start nginx success" diff --git a/openvpn/Makefile b/openvpn/Makefile new file mode 100644 index 0000000..f3ca9ef --- /dev/null +++ b/openvpn/Makefile @@ -0,0 +1,23 @@ +scp: + rsync -auvz --progress . root@${TESTHOST}:/root/openvpn + +getclient: + mkdir -p client + rsync root@vpnserver:/root/client/ca.crt ./client + rsync root@vpnserver:/root/client/client.ovpn ./client + rsync root@vpnserver:/root/client/hfclient.crt ./client + rsync root@vpnserver:/root/client/hfclient.key ./client +remote_install_rsync: + ssh root@${TESTHOST} ' \ + yum install rsync -y \ + ' +sshkey: + ssh-copy-id -i ~/.ssh/id_rsa.pub root@${TESTHOST} + +init: sshkey remote_install_rsync scp +remote_install: + ssh root@${TESTHOST} ' \ + cd openvpn \ + sh install.sh \ + sh ovpn_config_server.sh \ + ' diff --git a/openvpn/all_install.sh b/openvpn/all_install.sh new file mode 100644 index 0000000..8340ef4 --- /dev/null +++ b/openvpn/all_install.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +source ./config.sh + +echo ${OPENVPN_SERVER} + +# 网卡 +echo ${INTERFACE} + + +VPNSEVER= +yum install gcc -y +sh install.sh + +yum install gcc net-tools traceroute -y +sh ovpn_config_server.sh +sed -i "s/47.96.250.238/${OPENVPN_SERVER}/g" ./client.conf + +# 开始内核转发 +echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf +sysctl -p + +# 关闭selinux +systemctl stop firewalld.service +systemctl disable firewalld.service +sed -i 's/enforcing/disabled/g' /etc/selinux/config +# 即时生效 +setenforce 0 + + +echo "iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ${INTERFACE} -j SNAT --to-source ${IPADDRESS}" + + +sh ovpn_create_user.sh user1 +sh ovpn_create_user.sh user2 + +cp /etc/openvpn/client/keys/single/user1.ovpn /tmp/ +cp /etc/openvpn/client/keys/single/user2.ovpn /tmp/ diff --git a/openvpn/checkpsw.sh b/openvpn/checkpsw.sh new file mode 100755 index 0000000..d2610a5 --- /dev/null +++ b/openvpn/checkpsw.sh @@ -0,0 +1,27 @@ +#!/bin/sh +########################################################### +# checkpsw.sh (C) 2004 Mathias Sundman +# +# This script will authenticate OpenVPN users against +# a plain text file. The passfile should simply contain +# one row per user with the username first followed by +# one or more space(s) or tab(s) and then the password. +PASSFILE="/etc/openvpn/via-file" +LOG_FILE="/tmp/openvpn-password.log" +TIME_STAMP=`date "+%Y-%m-%d %T"` +########################################################### +if [ ! -r "${PASSFILE}" ]; then +echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE} +exit 1 +fi +CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}` +if [ "${CORRECT_PASSWORD}" = "" ]; then +echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE} +exit 1 +fi +if [ "${password}" = "${CORRECT_PASSWORD}" ]; then +echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE} +exit 0 +fi +echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE} +exit 1 diff --git a/openvpn/client.conf b/openvpn/client.conf new file mode 100644 index 0000000..ece0e5e --- /dev/null +++ b/openvpn/client.conf @@ -0,0 +1,15 @@ +client +dev tun +proto tcp +remote 47.96.250.238 1194 +resolv-retry infinite +remote-cert-tls server +nobind +persist-key +persist-tun +ca ca.crt +cert admin.crt +key admin.key +tls-auth ta.key 1 +comp-lzo +verb 3 diff --git a/openvpn/client_pwd.conf b/openvpn/client_pwd.conf new file mode 100644 index 0000000..5e4dc62 --- /dev/null +++ b/openvpn/client_pwd.conf @@ -0,0 +1,17 @@ +client +dev tun +proto tcp +remote 47.99.133.176 1194 +resolv-retry infinite +nobind +persist-key +persist-tun +ca ca.crt +#cert tmp2.crt +#key tmp2.key +auth-user-pass +#tls-auth ta.key 1 +remote-cert-tls server +cipher AES-256-CBC +comp-lzo +verb 3 diff --git a/openvpn/config.sh b/openvpn/config.sh new file mode 100755 index 0000000..0b2e969 --- /dev/null +++ b/openvpn/config.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# openvpn 服务器 +OPENVPN_SERVER=123.123.123.123 + +# 网卡 +INTERFACE=eth0 + +# ip 地址 +IPADDRESS=192.168.0.221 + +# dns地址 +DNS_SERVER=8.8.8.8 + + diff --git a/openvpn/dns2ip.sh b/openvpn/dns2ip.sh new file mode 100755 index 0000000..15754ed --- /dev/null +++ b/openvpn/dns2ip.sh @@ -0,0 +1,21 @@ +DNS_IP="" + +#nslookup -port=8080 $domain 106.52.100.60 +PORT=38888 +IP=123.1.1.2 +domain=$1 +# echo $domain +res=/tmp/smartdnsres/${domain}.txt +COUNTER=0 +while [ -z $DNS_IP ] && [ $COUNTER -lt 4 ]; do + DNS_IP=$(nslookup -port=${PORT} ${domain} ${IP} | awk '/^Address: / { print $2 }') + [ -z "$DNS_IP" ] && sleep 1 + ((COUNTER++)) +done +scp root@${IP}:${res} ${res} +echo `cat ${res}` + +# [ -z "$DNS_IP" ] && echo `cat /tmp/aa/${domain}.txt` +# content=`cat /tmp/aa/${domain}.txt` +# echo $content + diff --git a/openvpn/install.sh b/openvpn/install.sh new file mode 100755 index 0000000..4017017 --- /dev/null +++ b/openvpn/install.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +mkdir -p $PWD/softs + +if [ ! -f "softs/lzo-2.10.tar.gz" ]; then + + wget -c http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz -O softs/lzo-2.10.tar.gz + wget -c https://swupdate.openvpn.org/community/releases/openvpn-2.3.14.tar.gz -O softs/openvpn-2.3.14.tar.gz + # wget -c https://github.com/OpenVPN/easy-rsa/archive/master.zip + wget -c https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.8/EasyRSA-3.0.8.tgz -O softs/EasyRSA-3.0.8.tgz +fi + + +function install_lzo() +{ + cd softs + tar zxvf lzo-2.10.tar.gz && \ + cd lzo-2.10 && \ + ./configure && make && make install + cd .. +} + +function install_openvpn() +{ + cd softs + tar zxvf openvpn-2.5.8.tar.gz && \ + cd openvpn-2.5.8 \ + && autoheader \ + && aclocal \ + && libtoolize --ltdl --copy --force \ + && automake --add-missing --copy \ + && autoconf \ + && ./configure --with-lzo-headers=/usr/local/include --with-lzo-lib=/usr/local/lib && \ + make && make install + + cd ../.. + +} +# function install_openvpn() +# { +# cd softs +# tar zxvf openvpn-2.3.14.tar.gz && \ +# cd openvpn-2.3.14 && \ +# ./configure --with-lzo-headers=/usr/local/include --with-lzo-lib=/usr/local/lib && \ +# make && make install +# unzip openvpn.zip && \ +# cd openvpn && \ +# cd src/easylogger && \ +# autoheader;aclocal;automake --add-missing;autoconf;./configure;make +# cd openvpn && \ +# autoheader;aclocal;automake --add-missing;autoconf; +# CPPFLAGS="-DENABLE_PF -DENABLE_DEBUG" ./configure --with-lzo-headers=/usr/local/include +# make + +# cd ../.. + +# mkdir /tmp/openvpn_filter +# mkdir -p ccd +# } + +CMD_LIST=( gcc \ + ) + +function install_ntpdate() +{ + timedatectl set-timezone Asia/Shanghai + yum -y install ntp ntpdate + ntpdate cn.pool.ntp.org +} + +function install_depend() +{ + # for CMD in ${CMD_LIST[@]} + # do + # which ${CMD} > /dev/null 2>&1 + # if [ $? -eq 0 ] + # then + # # success "check ${CMD}" + # echo "check $CMD ok" + # else + # echo "${CMD} no such file" + # exit 1 + # fi + # done + yum install libtool-ltdl-devel -y + yum install gcc net-tools zip unzip openssl openssl-devel pam-devel wget python3 -y + yum install libtool perl-Thread-Queue libuuid-devel -y + yum install http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-1.noarch.rpm -y + yum install automake --nogpgcheck -y + if [ $? -eq 0 ]; then + echo "succeed" + else + echo "yum download fail" + exit 1 + fi +} + +function install_easy_rsa() +{ + + cd softs + mkdir -p ${PWD}/easy-rsa && \ + tar xvf EasyRSA-3.0.8.tgz && \ + mv EasyRSA-3.0.8 easy-rsa/easyrsa3 + # ln -sf ${PWD}/EasyRSA-3.0.8 ${PWD}/easy-rsa +} + +install_ntpdate +install_depend +install_lzo +install_openvpn +install_easy_rsa diff --git a/openvpn/mergesingle.sh b/openvpn/mergesingle.sh new file mode 100644 index 0000000..6d3996b --- /dev/null +++ b/openvpn/mergesingle.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +if [ $# != 1 ] ; then +echo "USAGE: $0 user" +echo " e.g.: $0 user1" +exit 1; +fi + +user=$1 +FOLDER=/etc/openvpn/client/keys/${user} +SINGLE_OVPNFILE_FOLDER=/etc/openvpn/client/keys/single/ +SINGLE_OVPN_FILE=${SINGLE_OVPNFILE_FOLDER}/${user}.ovpn +SINGLE_OVPN_BAK_FILE=${SINGLE_OVPNFILE_FOLDER}/${user}_bak.ovpn + +CA=${FOLDER}/ca.crt +CLINET_KEY=${FOLDER}/${user}.key +CLIENT_CERT=${FOLDER}/${user}.crt +OVPN_FILE=${FOLDER}/${user}.ovpn +TA_KEY=${FOLDER}/ta.key +mkdir -p $SINGLE_OVPNFILE_FOLDER + +if [ ! -f ${CLINET_KEY} ]; then +echo "${CLINET_KEY} 文件不存在,请检查" +exit 1 +fi + + +rm -fr ${SINGLE_OVPN_FILE} + +# cat ${OVPN_FILE} | sed -e "s/ca /#ca /g" \o >> ${SINGLE_OVPN_FILE} +cat ${OVPN_FILE} | sed -e "s/^key /#key /g" \ + -e "s/^ca /#ca /g" \ + -e "s/^cert /#cert /g" \ + -e "s/tls-auth /#tls-auth /g" \ + >> ${SINGLE_OVPN_FILE} + +echo "" >> ${SINGLE_OVPN_FILE} +cat ${CA} >> ${SINGLE_OVPN_FILE} +echo "" >> ${SINGLE_OVPN_FILE} + +echo "" >> ${SINGLE_OVPN_FILE} +cat ${CLIENT_CERT} >> ${SINGLE_OVPN_FILE} +echo "" >> ${SINGLE_OVPN_FILE} + + +echo "" >> ${SINGLE_OVPN_FILE} +cat ${CLINET_KEY} >> ${SINGLE_OVPN_FILE} +echo "" >> ${SINGLE_OVPN_FILE} + +echo "key-direction 1" >> ${SINGLE_OVPN_FILE} + +echo "" >> ${SINGLE_OVPN_FILE} +cat ${TA_KEY} >> ${SINGLE_OVPN_FILE} +echo "" >> ${SINGLE_OVPN_FILE} + +cp ${SINGLE_OVPN_FILE} ${SINGLE_OVPN_BAK_FILE} + +# echo `cat ${}` + + + + diff --git a/openvpn/ovpn_config_pwd_server.sh b/openvpn/ovpn_config_pwd_server.sh new file mode 100755 index 0000000..407521b --- /dev/null +++ b/openvpn/ovpn_config_pwd_server.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +cp server_pwd.conf /etc/openvpn/server +cp checkps.sh /etc/openvpn/checkpsw.sh +touch /etc/openvpn/via-file diff --git a/openvpn/ovpn_config_server.sh b/openvpn/ovpn_config_server.sh new file mode 100755 index 0000000..ad7828c --- /dev/null +++ b/openvpn/ovpn_config_server.sh @@ -0,0 +1,38 @@ +#!/bin/bash +export SERVER=server + +cp vars softs/easy-rsa/easyrsa3/ +cd softs/easy-rsa/easyrsa3 + +#1. 目录初始化 +./easyrsa init-pki + +#2. 创建根证书 +# ./easyrsa build-ca nopass +# ./easyrsa build-ca nopass #生成 CA 根证书, 输入 Common Name,名字随便起。 +./easyrsa --batch build-ca nopass > /dev/null 2>&1 || return 1 + + + +EASYRSA_CERT_EXPIRE=36500 ./easyrsa build-server-full $SERVER nopass +./easyrsa gen-dh +/usr/local/sbin/openvpn --genkey --secret ta.key + + + +mkdir -p /etc/openvpn/server/certs && cd /etc/openvpn/server/certs/ +cp /root/openvpn/softs/easy-rsa/easyrsa3/pki/dh.pem ./ # SSL 协商时 Diffie-Hellman 算法需要的 key +cp /root/openvpn/softs/easy-rsa/easyrsa3/pki/ca.crt ./ # CA 根证书 +cp /root/openvpn/softs/easy-rsa/easyrsa3/pki/issued/server.crt ./ # open VPN 服务器证书 +cp /root/openvpn/softs/easy-rsa/easyrsa3/pki/private/server.key ./ # open VPN 服务器证书 key +cp /root/openvpn/softs/easy-rsa/easyrsa3/ta.key ./ # tls-auth key +cp /root/openvpn/server.conf ./ + + +# 创建 open VPN 日志目录 +mkdir -p /var/log/openvpn/ +# chown openvpn:openvpn /var/log/openvpn + + + +cp server.conf /etc/openvpn/server diff --git a/openvpn/ovpn_create_user.sh b/openvpn/ovpn_create_user.sh new file mode 100755 index 0000000..67266e0 --- /dev/null +++ b/openvpn/ovpn_create_user.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +OVPN_USER_KEYS_DIR=/etc/openvpn/client/keys +EASY_RSA_VERSION=easyrsa3 +#EASY_RSA_DIR=/etc/openvpn/easy-rsa/ +EASY_RSA_DIR=/root/openvpn/softs/easy-rsa +PKI_DIR=$EASY_RSA_DIR/$EASY_RSA_VERSION/pki + +for user in "$@" +do + if [ -d "$OVPN_USER_KEYS_DIR/$user" ]; then + rm -rf $OVPN_USER_KEYS_DIR/$user + rm -rf $PKI_DIR/reqs/$user.req + sed -i '/'"$user"'/d' $PKI_DIR/index.txt + fi + cd $EASY_RSA_DIR/$EASY_RSA_VERSION + # 生成客户端 ssl 证书文件 + ./easyrsa build-client-full $user nopass + # 整理下生成的文件 + mkdir -p $OVPN_USER_KEYS_DIR/$user + cp $PKI_DIR/ca.crt $OVPN_USER_KEYS_DIR/$user/ # CA 根证书 + cp $PKI_DIR/issued/$user.crt $OVPN_USER_KEYS_DIR/$user/ # 客户端证书 + cp $PKI_DIR/private/$user.key $OVPN_USER_KEYS_DIR/$user/ # 客户端证书密钥 + cp /root/openvpn/client.conf $OVPN_USER_KEYS_DIR/$user/$user.ovpn # 客户端配置文件 + sed -i 's/admin/'"$user"'/g' $OVPN_USER_KEYS_DIR/$user/$user.ovpn + #cp /etc/openvpn/server/certs/ta.key $OVPN_USER_KEYS_DIR/$user/ta.key # auth-tls 文件 + cp /root/openvpn/softs/easy-rsa/easyrsa3/ta.key $OVPN_USER_KEYS_DIR/$user/ta.key # auth-tls 文件 + cd $OVPN_USER_KEYS_DIR + sh /root/openvpn/mergesingle.sh $user + zip -r $user.zip $user + echo "$OVPN_USER_KEYS_DIR" +done +exit 0 diff --git a/openvpn/ovpn_create_user_by_pwd.sh b/openvpn/ovpn_create_user_by_pwd.sh new file mode 100755 index 0000000..e9ea4da --- /dev/null +++ b/openvpn/ovpn_create_user_by_pwd.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +OVPN_USER_KEYS_DIR=/etc/openvpn/client/keys +EASY_RSA_VERSION=easyrsa3 +#EASY_RSA_DIR=/etc/openvpn/easy-rsa/ +EASY_RSA_DIR=/root/openvpn/softs/easy-rsa +PKI_DIR=$EASY_RSA_DIR/$EASY_RSA_VERSION/pki + +for user in "$@" +do + if [ -d "$OVPN_USER_KEYS_DIR/$user" ]; then + rm -rf $OVPN_USER_KEYS_DIR/$user + rm -rf $PKI_DIR/reqs/$user.req + sed -i '/'"$user"'/d' $PKI_DIR/index.txt + fi + cd $EASY_RSA_DIR/$EASY_RSA_VERSION + # 生成客户端 ssl 证书文件 + ./easyrsa build-client-full $user nopass + # 整理下生成的文件 + mkdir -p $OVPN_USER_KEYS_DIR/$user + cp $PKI_DIR/ca.crt $OVPN_USER_KEYS_DIR/$user/ # CA 根证书 + cp $PKI_DIR/issued/$user.crt $OVPN_USER_KEYS_DIR/$user/ # 客户端证书 + cp $PKI_DIR/private/$user.key $OVPN_USER_KEYS_DIR/$user/ # 客户端证书密钥 + cp /root/openvpn/client_pwd.conf $OVPN_USER_KEYS_DIR/$user/$user.ovpn # 客户端配置文件 + sed -i 's/admin/'"$user"'/g' $OVPN_USER_KEYS_DIR/$user/$user.ovpn + #cp /etc/openvpn/server/certs/ta.key $OVPN_USER_KEYS_DIR/$user/ta.key # auth-tls 文件 + cp /root/openvpn/softs/easy-rsa/easyrsa3/ta.key $OVPN_USER_KEYS_DIR/$user/ta.key # auth-tls 文件 + cd $OVPN_USER_KEYS_DIR + zip -r $user.zip $user + echo "$OVPN_USER_KEYS_DIR" +done +exit 0 diff --git a/openvpn/ovpn_del_user.sh b/openvpn/ovpn_del_user.sh new file mode 100755 index 0000000..68454a9 --- /dev/null +++ b/openvpn/ovpn_del_user.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e +OVPN_USER_KEYS_DIR=/etc/openvpn/client/keys +EASY_RSA_VERSION=easyrsa3 +EASY_RSA_DIR=/root/openvpn/softs/easy-rsa +for user in "$@" +do + cd $EASY_RSA_DIR/$EASY_RSA_VERSION + echo -e 'yes\n' | ./easyrsa revoke $user + ./easyrsa gen-crl + # 吊销掉证书后清理客户端相关文件 + if [ -d "$OVPN_USER_KEYS_DIR/$user" ]; then + rm -rf $OVPN_USER_KEYS_DIR/${user}* + fi + + if [ -f "${OVPN_USER_KEYS_DIR}/single/${user}.ovpn" ]; then + rm -rf "${OVPN_USER_KEYS_DIR}/single/${user}.ovpn" + fi + + if [ -f "${OVPN_USER_KEYS_DIR}/single/${user}_bak.ovpn" ]; then + rm -rf "${OVPN_USER_KEYS_DIR}/single/${user}_bak.ovpn" + fi +# systemctl restart openvpn@server +done +echo "请执行sh ovpn_restart.sh; 重启服务" +cd /root/openvpn +sh ovpn_stop.sh +sh ovpn_start.sh + +exit 0 diff --git a/openvpn/ovpn_get_online_user.sh b/openvpn/ovpn_get_online_user.sh new file mode 100755 index 0000000..da29051 --- /dev/null +++ b/openvpn/ovpn_get_online_user.sh @@ -0,0 +1,5 @@ +#!/bin/bash +SCRIPT=`basename $0` +export CURPWD=$(cd `dirname $0`; pwd) +cat ${CURPWD}/openvpn-status.log | sed -n '/OpenVPN CLIENT LIST/,/ROUTING TABLE/p' | tail -n+4 | sed "s/ROUTING TABLE//g"; + diff --git a/openvpn/ovpn_get_online_usercount.sh b/openvpn/ovpn_get_online_usercount.sh new file mode 100755 index 0000000..eab0b02 --- /dev/null +++ b/openvpn/ovpn_get_online_usercount.sh @@ -0,0 +1,5 @@ +#!/bin/bash +SCRIPT=`basename $0` +export CURPWD=$(cd `dirname $0`; pwd) + +sh ${CURPWD}/ovpn_get_online_user.sh |wc -l diff --git a/openvpn/ovpn_get_pid.sh b/openvpn/ovpn_get_pid.sh new file mode 100755 index 0000000..7119423 --- /dev/null +++ b/openvpn/ovpn_get_pid.sh @@ -0,0 +1,11 @@ +#!/bin/bash +SCRIPT=`basename $0` +export CURPWD=$(cd `dirname $0`; pwd) +pid=`ps -ef|grep openvpn| grep -v "grep" | grep -v "ovpn_get_pid" | grep -v "ovpn_get_running_time"` +if [ $? -eq 0 ]; then + echo $pid |awk '{print $2}'|sed -n '1p' > ${CURPWD}/pid.txt +else + echo "not process openvpn" >&2 + exit 1 +fi + diff --git a/openvpn/ovpn_get_running_time.sh b/openvpn/ovpn_get_running_time.sh new file mode 100755 index 0000000..4bbc895 --- /dev/null +++ b/openvpn/ovpn_get_running_time.sh @@ -0,0 +1,12 @@ +#!/bin/bash +SCRIPT=`basename $0` +export CURPWD=$(cd `dirname $0`; pwd) +sh ${CURPWD}/ovpn_get_pid.sh + +pid=`cat $CURPWD/pid.txt` +if [ $? -eq 0 ]; then + ps -p $pid -o etimes | sed -n '2p' +else + exit 1 +fi + diff --git a/openvpn/ovpn_isexist_user.sh b/openvpn/ovpn_isexist_user.sh new file mode 100755 index 0000000..e3fcb2c --- /dev/null +++ b/openvpn/ovpn_isexist_user.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e +OVPN_USER_KEYS_DIR=/etc/openvpn/client/keys +EASY_RSA_VERSION=easyrsa3 +EASY_RSA_DIR=/root/openvpn/softs/easy-rsa + +user=$1 +echo $user + +if [ "$user" = "" ] +then + echo "user is not set!" + exit 1 +else + ls /etc/openvpn/client/keys/$user + # ls /tmp/keys/$user + #echo "/tmp/keys/$user" + + if [ $? -ne 0 ]; then + echo "${user} is not found" + exit 1 + else + echo "success" + exit 0 + fi + +fi + + +exit 0 + diff --git a/openvpn/ovpn_list_user.sh b/openvpn/ovpn_list_user.sh new file mode 100755 index 0000000..221d9b9 --- /dev/null +++ b/openvpn/ovpn_list_user.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ls /etc/openvpn/client/keys/*.zip diff --git a/openvpn/ovpn_restart.sh b/openvpn/ovpn_restart.sh new file mode 100755 index 0000000..753b17b --- /dev/null +++ b/openvpn/ovpn_restart.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sh ovpn_stop.sh +sh ovpn_start.sh diff --git a/openvpn/ovpn_rollback_user_cert.sh b/openvpn/ovpn_rollback_user_cert.sh new file mode 100755 index 0000000..83f421e --- /dev/null +++ b/openvpn/ovpn_rollback_user_cert.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ $# != 1 ] ; then +echo "USAGE: $0 user" +echo " e.g.: $0 user1" +exit 1; +fi + +user=$1 +FOLDER=/etc/openvpn/client/keys/${user} +SINGLE_OVPNFILE_FOLDER=/etc/openvpn/client/keys/single/ +SINGLE_OVPN_FILE=${SINGLE_OVPNFILE_FOLDER}/${user}.ovpn +SINGLE_OVPN_BAK_FILE=${SINGLE_OVPNFILE_FOLDER}/${user}_bak.ovpn + +echo "cp ${SINGLE_OVPN_BAK_FILE} ${SINGLE_OVPN_FILE}" +cp ${SINGLE_OVPN_BAK_FILE} ${SINGLE_OVPN_FILE} + +# echo `cat ${}` +exit 0 diff --git a/openvpn/ovpn_start.sh b/openvpn/ovpn_start.sh new file mode 100755 index 0000000..c7a1e0b --- /dev/null +++ b/openvpn/ovpn_start.sh @@ -0,0 +1,9 @@ +#!/bin/bash +/usr/local/sbin/openvpn --config /etc/openvpn/server/server.conf & echo $! > pid.txt +if [ $? -eq 0 ]; then + echo "openvpn run succeed" +else + echo "openvpn run failed" + +fi + exit 0 diff --git a/openvpn/ovpn_stop.sh b/openvpn/ovpn_stop.sh new file mode 100755 index 0000000..669932f --- /dev/null +++ b/openvpn/ovpn_stop.sh @@ -0,0 +1,14 @@ +#!/bin/bash +function stop_name() +{ + echo "close $1 pid" + pid=`ps -ef|grep $1|grep -v "grep"|grep -v "stopServer" | grep -v "ovpn_del_user" |awk '{print $2}'` + if [ x"$pid" != x"" ] + then + echo "$pid is running...close it!" + kill -9 ${pid} + fi +} + +stop_name 'openvpn' +exit 0 diff --git a/openvpn/ovpn_sys_config.sh b/openvpn/ovpn_sys_config.sh new file mode 100755 index 0000000..8d1374d --- /dev/null +++ b/openvpn/ovpn_sys_config.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +SYSCTL_FILE=/etc/sysctl.conf + +grep "ip_forward" ${SYSCTL_FILE} >> /dev/null +if [ $? -eq 0 ]; then + echo "succeed" +else + # 配置内核转发 + echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf + sysctl -p + + # 关闭selinux + systemctl stop firewalld.service + systemctl disable firewalld.service + sed -i 's/enforcing/disabled/g' /etc/selinux/config + # 即时生效 + setenforce 0 + +fi + + + diff --git a/openvpn/rsync.exclude b/openvpn/rsync.exclude new file mode 100644 index 0000000..ab1cfb4 --- /dev/null +++ b/openvpn/rsync.exclude @@ -0,0 +1 @@ +test/* diff --git a/openvpn/server.conf b/openvpn/server.conf new file mode 100644 index 0000000..5330803 --- /dev/null +++ b/openvpn/server.conf @@ -0,0 +1,56 @@ +# OpenVPN应该监听哪个本地IP地址(可选) +# 如果不设置,默认监听所有IP +local 0.0.0.0 + +# OpenVPN应该监听哪个端口(TCP/UDP) +# 如果想在同一台计算机上运行多个OpenVPN实例,可以使用不同的端口号来区分它们 +# 在防火墙上打开这个端口 +port 1194 + +# 服务器使用TCP还是UDP协议 +proto tcp + +# 指定OpenVPN创建的通信隧道类型 +dev tun + +ca /etc/openvpn/server/certs/ca.crt +cert /etc/openvpn/server/certs/server.crt +key /etc/openvpn/server/certs/server.key # This file should be kept secret +dh /etc/openvpn/server/certs/dh.pem +tls-auth /etc/openvpn/server/certs/ta.key 0 # tls-auth key,参数 0 可以省略,如果不省略,那么客户端 + +#虚拟局域网网段 +server 10.8.0.0 255.255.255.0 + +ifconfig-pool-persist ipp.txt +push "redirect-gateway def1 bypass-dhcp" +push "dhcp-option DNS 8.8.8.8" +keepalive 10 120 +comp-lzo + +# 最多链接的用户 +max-clients 100 + +persist-key +persist-tun + +# 日志 +status openvpn-status.log +log-append /var/log/openvpn.log + +# 日志等级 +verb 3 + +# 验证证书,吊销的用户无法登陆 +#crl-verify /root/openvpn/softs/easy-rsa/easyrsa3/pki/crl.pem +# +management 0.0.0.0 19999 +client-config-dir /root/openvpn/ccd + + +# for vpn auth by ldap +#auth-user-pass-verify /tmp/check_credit.py via-file +#client-cert-not-required +#username-as-common-name +#script-security 3 +#duplicate-cn diff --git a/openvpn/server_pwd.conf b/openvpn/server_pwd.conf new file mode 100644 index 0000000..e261106 --- /dev/null +++ b/openvpn/server_pwd.conf @@ -0,0 +1,40 @@ +# OpenVPN应该监听哪个本地IP地址(可选) +# 如果不设置,默认监听所有IP +local 0.0.0.0 + +# OpenVPN应该监听哪个端口(TCP/UDP) +# 如果想在同一台计算机上运行多个OpenVPN实例,可以使用不同的端口号来区分它们 +# 在防火墙上打开这个端口 +port 1194 + +# 服务器使用TCP还是UDP协议 +proto tcp + +# 指定OpenVPN创建的通信隧道类型 +dev tun + +ca /etc/openvpn/server/certs/ca.crt +cert /etc/openvpn/server/certs/server.crt +key /etc/openvpn/server/certs/server.key # This file should be kept secret +dh /etc/openvpn/server/certs/dh.pem +tls-auth /etc/openvpn/server/certs/ta.key 0 # tls-auth key,参数 0 可以省略,如果不省略,那么客户端 + +#虚拟局域网网段 +server 10.8.0.0 255.255.255.0 + +client-to-client +duplicate-cn +keepalive 10 120 +cipher AES-256-CBC +comp-lzo +persist-key +persist-tun +status openvpn-status.log +verb 3 +#user passwd login start# +script-security 3 +auth-user-pass-verify /etc/openvpn/checkpsw.sh via-env ###指定只用的认证脚本 +client-cert-not-required +;username-as-common-name #加不加均可,不影响实际效果 +#user passwd login end# +log-append /var/log/openvpn.log diff --git a/openvpn/softs/EasyRSA-3.0.8.tgz b/openvpn/softs/EasyRSA-3.0.8.tgz new file mode 100644 index 0000000..a92da67 Binary files /dev/null and b/openvpn/softs/EasyRSA-3.0.8.tgz differ diff --git a/openvpn/softs/lzo-2.10.tar.gz b/openvpn/softs/lzo-2.10.tar.gz new file mode 100644 index 0000000..f379058 Binary files /dev/null and b/openvpn/softs/lzo-2.10.tar.gz differ diff --git a/openvpn/softs/openvpn-2.3.14.tar.gz b/openvpn/softs/openvpn-2.3.14.tar.gz new file mode 100644 index 0000000..73e1bf2 Binary files /dev/null and b/openvpn/softs/openvpn-2.3.14.tar.gz differ diff --git a/openvpn/softs/openvpn.zip b/openvpn/softs/openvpn.zip new file mode 100644 index 0000000..fee3ab4 --- /dev/null +++ b/openvpn/softs/openvpn.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0db981e7a99ce48a86067f2bcd6e933d24e135d74ebd3a0abbb5f1e236f8ab51 +size 2673305 diff --git a/openvpn/vars b/openvpn/vars new file mode 100644 index 0000000..a6110c9 --- /dev/null +++ b/openvpn/vars @@ -0,0 +1,221 @@ +# Easy-RSA 3 parameter settings + +# NOTE: If you installed Easy-RSA from your distro's package manager, don't edit +# this file in place -- instead, you should copy the entire easy-rsa directory +# to another location so future upgrades don't wipe out your changes. + +# HOW TO USE THIS FILE +# +# vars.example contains built-in examples to Easy-RSA settings. You MUST name +# this file 'vars' if you want it to be used as a configuration file. If you do +# not, it WILL NOT be automatically read when you call easyrsa commands. +# +# It is not necessary to use this config file unless you wish to change +# operational defaults. These defaults should be fine for many uses without the +# need to copy and edit the 'vars' file. +# +# All of the editable settings are shown commented and start with the command +# 'set_var' -- this means any set_var command that is uncommented has been +# modified by the user. If you're happy with a default, there is no need to +# define the value to its default. + +# NOTES FOR WINDOWS USERS +# +# Paths for Windows *MUST* use forward slashes, or optionally double-escaped +# backslashes (single forward slashes are recommended.) This means your path to +# the openssl binary might look like this: +# "C:/Program Files/OpenSSL-Win32/bin/openssl.exe" + +# A little housekeeping: DON'T EDIT THIS SECTION +# +# Easy-RSA 3.x doesn't source into the environment directly. +# Complain if a user tries to do this: +if [ -z "$EASYRSA_CALLER" ]; then + echo "You appear to be sourcing an Easy-RSA 'vars' file." >&2 + echo "This is no longer necessary and is disallowed. See the section called" >&2 + echo "'How to use this file' near the top comments for more details." >&2 + return 1 +fi + +# DO YOUR EDITS BELOW THIS POINT + +# This variable is used as the base location of configuration files needed by +# easyrsa. More specific variables for specific files (e.g., EASYRSA_SSL_CONF) +# may override this default. +# +# The default value of this variable is the location of the easyrsa script +# itself, which is also where the configuration files are located in the +# easy-rsa tree. + +#set_var EASYRSA "${0%/*}" + +# If your OpenSSL command is not in the system PATH, you will need to define the +# path to it here. Normally this means a full path to the executable, otherwise +# you could have left it undefined here and the shown default would be used. +# +# Windows users, remember to use paths with forward-slashes (or escaped +# back-slashes.) Windows users should declare the full path to the openssl +# binary here if it is not in their system PATH. + +#set_var EASYRSA_OPENSSL "openssl" +# +# This sample is in Windows syntax -- edit it for your path if not using PATH: +#set_var EASYRSA_OPENSSL "C:/Program Files/OpenSSL-Win32/bin/openssl.exe" + +# Edit this variable to point to your soon-to-be-created key directory. By +# default, this will be "$PWD/pki" (i.e. the "pki" subdirectory of the +# directory you are currently in). +# +# WARNING: init-pki will do a rm -rf on this directory so make sure you define +# it correctly! (Interactive mode will prompt before acting.) + +#set_var EASYRSA_PKI "$PWD/pki" + +# Define directory for temporary subdirectories. + +#set_var EASYRSA_TEMP_DIR "$EASYRSA_PKI" + +# Define X509 DN mode. +# This is used to adjust what elements are included in the Subject field as the DN +# (this is the "Distinguished Name.") +# Note that in cn_only mode the Organizational fields further below aren't used. +# +# Choices are: +# cn_only - use just a CN value +# org - use the "traditional" Country/Province/City/Org/OU/email/CN format + +#set_var EASYRSA_DN "cn_only" + +# Organizational fields (used with 'org' mode and ignored in 'cn_only' mode.) +# These are the default values for fields which will be placed in the +# certificate. Don't leave any of these fields blank, although interactively +# you may omit any specific field by typing the "." symbol (not valid for +# email.) + +set_var EASYRSA_REQ_COUNTRY "CN" +set_var EASYRSA_REQ_PROVINCE "FUJIAN" +set_var EASYRSA_REQ_CITY "FUZHOU" +set_var EASYRSA_REQ_ORG "SDWAN" +set_var EASYRSA_REQ_EMAIL "7671557@qq.com" +set_var EASYRSA_REQ_OU "FZ OpenVPN" + +# Choose a size in bits for your keypairs. The recommended value is 2048. Using +# 2048-bit keys is considered more than sufficient for many years into the +# future. Larger keysizes will slow down TLS negotiation and make key/DH param +# generation take much longer. Values up to 4096 should be accepted by most +# software. Only used when the crypto alg is rsa (see below.) + +#set_var EASYRSA_KEY_SIZE 2048 + +# The default crypto mode is rsa; ec can enable elliptic curve support. +# Note that not all software supports ECC, so use care when enabling it. +# Choices for crypto alg are: (each in lower-case) +# * rsa +# * ec +# * ed + +#set_var EASYRSA_ALGO rsa + +# Define the named curve, used in ec & ed modes: + +#set_var EASYRSA_CURVE secp384r1 + +# In how many days should the root CA key expire? + +set_var EASYRSA_CA_EXPIRE 365000 + +# In how many days should certificates expire? + +set_var EASYRSA_CERT_EXPIRE 36500 + +# How many days until the next CRL publish date? Note that the CRL can still be +# parsed after this timeframe passes. It is only used for an expected next +# publication date. +#set_var EASYRSA_CRL_DAYS 180 + +# How many days before its expiration date a certificate is allowed to be +# renewed? +#set_var EASYRSA_CERT_RENEW 30 + +# Random serial numbers by default, set to no for the old incremental serial numbers +# +#set_var EASYRSA_RAND_SN "yes" + +# Support deprecated "Netscape" extensions? (choices "yes" or "no".) The default +# is "no" to discourage use of deprecated extensions. If you require this +# feature to use with --ns-cert-type, set this to "yes" here. This support +# should be replaced with the more modern --remote-cert-tls feature. If you do +# not use --ns-cert-type in your configs, it is safe (and recommended) to leave +# this defined to "no". When set to "yes", server-signed certs get the +# nsCertType=server attribute, and also get any NS_COMMENT defined below in the +# nsComment field. + +#set_var EASYRSA_NS_SUPPORT "no" + +# When NS_SUPPORT is set to "yes", this field is added as the nsComment field. +# Set this blank to omit it. With NS_SUPPORT set to "no" this field is ignored. + +#set_var EASYRSA_NS_COMMENT "Easy-RSA Generated Certificate" + +# A temp file used to stage cert extensions during signing. The default should +# be fine for most users; however, some users might want an alternative under a +# RAM-based FS, such as /dev/shm or /tmp on some systems. + +#set_var EASYRSA_TEMP_FILE "$EASYRSA_PKI/extensions.temp" + +# !! +# NOTE: ADVANCED OPTIONS BELOW THIS POINT +# PLAY WITH THEM AT YOUR OWN RISK +# !! + +# Broken shell command aliases: If you have a largely broken shell that is +# missing any of these POSIX-required commands used by Easy-RSA, you will need +# to define an alias to the proper path for the command. The symptom will be +# some form of a 'command not found' error from your shell. This means your +# shell is BROKEN, but you can hack around it here if you really need. These +# shown values are not defaults: it is up to you to know what you're doing if +# you touch these. +# +#alias awk="/alt/bin/awk" +#alias cat="/alt/bin/cat" + +# X509 extensions directory: +# If you want to customize the X509 extensions used, set the directory to look +# for extensions here. Each cert type you sign must have a matching filename, +# and an optional file named 'COMMON' is included first when present. Note that +# when undefined here, default behaviour is to look in $EASYRSA_PKI first, then +# fallback to $EASYRSA for the 'x509-types' dir. You may override this +# detection with an explicit dir here. +# +#set_var EASYRSA_EXT_DIR "$EASYRSA/x509-types" + +# If you want to generate KDC certificates, you need to set the realm here. +#set_var EASYRSA_KDC_REALM "CHANGEME.EXAMPLE.COM" + +# OpenSSL config file: +# If you need to use a specific openssl config file, you can reference it here. +# Normally this file is auto-detected from a file named openssl-easyrsa.cnf from the +# EASYRSA_PKI or EASYRSA dir (in that order.) NOTE that this file is Easy-RSA +# specific and you cannot just use a standard config file, so this is an +# advanced feature. + +#set_var EASYRSA_SSL_CONF "$EASYRSA/openssl-easyrsa.cnf" + +# Default CN: +# This is best left alone. Interactively you will set this manually, and BATCH +# callers are expected to set this themselves. + +#set_var EASYRSA_REQ_CN "ChangeMe" + +# Cryptographic digest to use. +# Do not change this default unless you understand the security implications. +# Valid choices include: md5, sha1, sha256, sha224, sha384, sha512 + +#set_var EASYRSA_DIGEST "sha256" + +# Batch mode. Leave this disabled unless you intend to call Easy-RSA explicitly +# in batch mode without any user input, confirmation on dangerous operations, +# or most output. Setting this to any non-blank string enables batch mode. + +#set_var EASYRSA_BATCH "" + diff --git a/redis/docker-compose.yml b/redis/docker-compose.yml index c57cb3e..3e56a4d 100644 --- a/redis/docker-compose.yml +++ b/redis/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.2' services: redis: - image: redis:3.2.11 + image: redis:6.2.1 ports: - 11080:6379 volumes: @@ -12,6 +12,8 @@ services: placement: constraints: [node.role == manager] command: redis-server /usr/local/etc/redis/redis.conf + environment: + - TZ=Asia/Shanghai # 设置时区 redis-commander: container_name: redis-commander hostname: redis-commander diff --git a/redis/redis.conf b/redis/redis.conf new file mode 100644 index 0000000..9a548ab --- /dev/null +++ b/redis/redis.conf @@ -0,0 +1,4 @@ +#bind 127.0.0.1 +protected-mode no +appendonly yes +requirepass foo diff --git a/redis/start_redis_service.sh b/redis/start_redis_service.sh old mode 100755 new mode 100644 index 934084a..3de7455 --- a/redis/start_redis_service.sh +++ b/redis/start_redis_service.sh @@ -1,3 +1,5 @@ #!/bin/bash source ./config.sh +sed -i "s/requirepass.*/requirepass\ ${PASSWORD}/g" redis.conf + docker-compose up -d diff --git a/redis/stop_redis_service.sh b/redis/stop_redis_service.sh index e3b72b5..2d97f8f 100755 --- a/redis/stop_redis_service.sh +++ b/redis/stop_redis_service.sh @@ -1,3 +1,4 @@ #!/bin/bash #docker rm -f local_redis +source ./config.sh docker-compose down diff --git a/samba/README.md b/samba/README.md new file mode 100644 index 0000000..27a9018 --- /dev/null +++ b/samba/README.md @@ -0,0 +1,4 @@ +创建了一个用户durant, 密码 123456 + +参考资料: +https://blog.csdn.net/wc1695040842/article/details/91866500 diff --git a/samba/create.sh b/samba/create.sh new file mode 100755 index 0000000..83bb68a --- /dev/null +++ b/samba/create.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +username=$1 +password=`echo -n "$2"|md5sum|cut -d ' ' -f1` +# 配置文件必须要小写 +config_name=`echo "$1" | tr 'A-Z' 'a-z'` +config_path=$config_name'.smb.conf' +group=$3 + + +egrep "^$group" /etc/group >& /dev/null +if [ $? -ne 0 ];then + groupadd $group +fi +if [ ! -d "/data/$group" ]; then + mkdir -p /data/$group + chmod 770 -R /data/$group + chown -R :$group /data/$group +fi + +pdbedit -L | grep "^$username:" &>/dev/null +if [ $? -ne 0 ]; then + useradd -s /sbin/nologin -G $group $username + echo "$password" | passwd --stdin $username 1>/dev/null 2>>addsmbuser.log + echo -e "$password\n$password" | pdbedit -a -t -u $username 2>>addsmbuser.log + if [ $? -eq 0 ]; then + echo "$username 创建成功" + else + echo "错误" + exit 1 + fi +else + echo -e "$username 已存在" +fi + +mkdir -p /data/$username +chown -R $username:$username /data/$username +chmod 700 -R /data/$username + +mkdir -p /etc/samba/config +cat>/etc/samba/config/${config_path}</etc/samba/config/mydemo.smb.conf< + + + + KeepAlive + + SuccessfulExit + + + Label + supervisord + ProgramArguments + + /usr/local/bin/supervisord + -n + -c + /usr/local/etc/supervisord.ini + + RunAtLoad + + + + diff --git a/user/disable_root_user_login.sh b/user/disable_root_user_login.sh new file mode 100644 index 0000000..64bb3e7 --- /dev/null +++ b/user/disable_root_user_login.sh @@ -0,0 +1,4 @@ +sed -i 's/PermitRootLogin.*/PermitRootLogin\ no/g' /etc/ssh/sshd_config +service sshd restart + + diff --git a/user/enable_root_user_login.sh b/user/enable_root_user_login.sh new file mode 100644 index 0000000..08ff4e0 --- /dev/null +++ b/user/enable_root_user_login.sh @@ -0,0 +1,4 @@ +sed -i 's/PermitRootLogin.*/PermitRootLogin\ yes/g' /etc/ssh/sshd_config +service sshd restart + +