You can use the json input type in Filebeat to send JSON logs to Elasticsearch. Here is an example of how you can configure Filebeat to send JSON logs to Elasticsearch 1:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.json
json.keys_under_root: true
json.add_error_key: true
output.elasticsearch:
hosts: ["localhost:9200"]
index: "myindex-%{+yyyy.MM.dd}"
Here is an example of a docker-compose file for
Filebeat, Elasticsearch and Kibana with password :
version: '3.7'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2
container_name: elasticsearch
environment:
- node.name=elasticsearch
- cluster.name=elasticsearch-cluster
- discovery.seed_hosts=elasticsearch
- cluster.initial_master_nodes=elasticsearch
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- ELASTIC_PASSWORD=changeme
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
kibana:
image: docker.elastic.co/kibana/kibana:7.16.2
container_name: kibana
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
ELASTICSEARCH_USERNAME: elastic
ELASTICSEARCH_PASSWORD: changeme
ports:
- 5601:5601
filebeat:
image: docker.elastic.co/beats/filebeat:7.16.2
container_name: filebeat
user: root
volumes:
- ./filebeat.yml:/usr/share/filebeat/filebeat.yml
- /var/lib/docker/containers:/var/lib/docker/containers
command: filebeat -e --strict.perms=false
volumes:
esdata1:
driver: local
To print logs in JSON format with SLF4J in Spring Boot, you can use Logback as the logging framework. You can add the following dependencies to your pom.xml file:
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.6</version>
</dependency>
To cache Next.js pages in Spring Cloud Gateway, you can use Spring Cache and Caffeine. You can write a filter that caches the response for specific requests. Here is an example of how to do it:
@Component
@Slf4j
public class CacheResponseGatewayFilterFactory extends AbstractGatewayFilterFactory<CacheResponseGatewayFilterFactory.Config> {
public CacheResponseGatewayFilterFactory() {
super(Config.class);
}
@Override
public GatewayFilter apply(Config config) {
return (exchange, chain) -> {
String cacheKey = exchange.getRequest().getURI().toString();
Cache.ValueWrapper
cachedResponse = cacheManager.getCache("myCache").get(cacheKey);
if (cachedResponse != null) {
log.info("Returning cached response for {}", cacheKey);
return Mono.just(cachedResponse.get());
}
return chain.filter(exchange).doOnNext(response -> {
if (response.getStatusCode().is2xxSuccessful()) {
log.info("Caching response for {}", cacheKey);
cacheManager.getCache("myCache").put(cacheKey, response);
}
});
};
}
public static class Config {
// Put the configuration properties here
}
}
در این پست به بررسی چگونه پیکربندی mysql برای بهبود کارایی آن پرداخته شده است
منبع: https://medium.com/datadenys/tuning-mysql-8-0-server-for-better-performance-238e463f5583
از داکر کامپوز برای راه اندازی آن استفاده میکنیم
version: '3.3'
services:
db:
image: mysql:latest
container_name: app_db
restart: always
environment:
MYSQL_DATABASE: '---------'
MYSQL_USER: '-------------'
MYSQL_PASSWORD: '------------'
MYSQL_ROOT_PASSWORD: '--------------'
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
--innodb-buffer-pool-size=20G
--innodb-buffer-pool-instances=16
--innodb_log_file_size=20G
--innodb_log_buffer_size=1G
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- ./db/files/:/var/lib/mysql
table.wysiwyg-macro[data-macro-name="rtl"] {direction: rtl;text-align: justify;}table.wysiwyg-macro[data-macro-name="ltr"] {direction: ltr;text-align: initial;}.conf-macro.output-inline[data-macro-name="ltr"] {direction: ltr;text-align: initial;}table.wysiwyg-macro[data-macro-name="code"] {direction: ltr;text-align: initial;}.conf-macro.output-block[data-macro-name="drawio"] {text-align: center;}@font-face {font-family: Vazir;src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v26.0.2/dist/Vazir.ttf') format('truetype');}@font-face {font-family: "Vazir Code";src: url('https://cdn.rawgit.com/rastikerdar/vazir-code-font/v1.1.2/dist/Vazir-Code.ttf') format('truetype');}#title-text, .wiki-content {font-family: Vazir;}.wiki-content {text-align: right !important;direction: rtl;/* text-indent: 1em; */}code {font-family: "Vazir Code";background: rgba(0,0,0,0.03);border: 1px solid #dfe1e5;border-radius: 3px;padding: 1px 6px;}#title-text {direction: rtl;}#content-title-div {direction: rtl;}#main-content {direction: rtl;}.auto-cursor-target {direction: rtl;text-align: justify;}.conf-macro.output-block {direction: ltr;}.toc-macro {direction: rtl !important;}ul.inline-task-list > li {background-position-x: right !important;padding-right: 20px;}
-- install docker
yum install epel-release
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install docker-ce docker-ce-cli containerd.io docker version systemctl enable docker.service systemctl start docker.service-- install docker compose
yum install -y python-pip pip install --upgrade pip yum upgrade python* pip2.7 install cryptography==2.2.2 pip install docker-compose docker-compose version
Automatically generate of Java code. Design your web application based on Spring Boot, with a professional graphical interface.
Remove all the Java related packages (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ):
dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove
sudo apt-get -y autoremove
Purge config files (careful. This command removed libsgutils2-2 and virtualbox config files too):
dpkg -l | grep ^rc | awk '{print($2)}' | xargs sudo apt-get -y purge
Remove Java config and cache directory:
sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf
Remove manually installed JVMs:
sudo rm -rf /usr/lib/jvm/*
Remove Java entries, if there is still any, from the alternatives:
for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done
Search for possible remaining Java directories:
sudo updatedb
sudo locate -b '\pack200'
If the command above produces any output like /path/to/jre1.6.0_34/bin/pack200
remove the directory that is parent of bin, like this: sudo rm -rf /path/to/jre1.6.0_34
.
https://askubuntu.com/questions/84483/how-to-completely-uninstall-java
Mariadb
Mysql
java
ابتدا نیاز است که فایل ها رو فشرده کنیم تا سرعت انتقال افزایش یابد.
با استفاده از دستور زیر پوشه جاری فشرده میشود
# tar cvzf backup.tar.gz /var/www
سپس با استفاده از دستور زیر فایل را به سرور مورد نظر انتقال میدهیم
Copy the file "foobar.txt" from a remote host to the local host
$ scp your_username@remotehost.edu:foobar.txt /some/local/directory
Copy the file "foobar.txt" from the local host to a remote host
$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy the directory "foo" from the local host to a remote host's directory "bar"
$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"
$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/
Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host
$ scp foo.txt bar.txt your_username@remotehost.edu:~
Copy the file "foobar.txt" from the local host to a remote host using port 2264
$ scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy multiple files from the remote host to your current directory on the local host
$ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .
$ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\} .
سپس با استفاده از دستور زیر محتوای فایل فشرده را استخراج میکنیم
# tar -xzf backup.tar.gz