Web Server : Apache Tomcat
Language : JSP (Java Server Pages)
Database : PostgreSQL
Tools : MTPuTTY & WinSCP.
Language : JSP (Java Server Pages)
Database : PostgreSQL
Tools : MTPuTTY & WinSCP.
# hostnamectl
SET TIMEZONE
# timedatectl set-timezone Asia/Jakarta
# timedatectl
Install WGET
# dnf install wget
Install TAR GZ
# dnf install tar gzip
# dnf -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
Melihat versi java
# java -version
Konfigurasi Java Home Environment
# update-alternatives --config java
# vi /etc/environment
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.432.b06-3.el9.x86_64"
Simpan dengan
:wq
Edit bash profile
# vi ~/.bash_profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.432.b06-3.el9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
Save & reload bash profile
# source ~/.bash_profile
Cek JAVA_HOME
# echo $JAVA_HOME
# groupadd tomcat
# useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
# cd /opt
# wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.90/bin/apache-tomcat-9.0.90.tar.gz
# tar -xzvf apache-tomcat-9.0.90.tar.gz
# chown -hR tomcat:tomcat tomcat
# Rename /opt/apache-tomcat-9.0.90/ menjadi /opt/tomcat/
# Edit /opt/tomcat/conf/server.xml
ganti connector port 8080 menjadi 80
Test Tomcat
# /opt/tomcat/bin/startup.sh
View Process
# ps aux
# dnf provides */netstat
Firewall
# iptables -L
# iptables-save
Restart Tomcat
# /opt/tomcat/bin/shutdown.sh
# /opt/tomcat/bin/startup.sh
Custom Setting Library Location
Edit /opt/tomcat/conf/catalina.properties
# common.loader="/lib","/lib/*.jar","/lib","/lib/.jar","/lib/xs_linux_lib","/lib/xs_linux_lib/*.jar","/lib/xs_linux_lib","/lib/xs_linux_lib/*.jar"
Install
Restore Database
Install the repository RPM:
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Disable the built-in PostgreSQL module:
# sudo dnf -qy module disable postgresql
Install PostgreSQL:
# sudo dnf install -y postgresql13-server
Optionally initialize the database and enable automatic start:
inisialisasi database :
# sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
setting PostgreSQL autorun :
# sudo systemctl enable postgresql-13
# sudo systemctl start postgresql-13
verifikasi PostgreSQL berjalan
# sudo systemctl status postgresql-13
cek version
# psql --version
Konfigurasi Awal
1. Ubah Password User 'postgres':
Jalankan perintah berikut untuk masuk ke shell PostgreSQL:
# sudo -i -u postgres
# psql
Ganti password dengan perintah::
# ALTER USER postgres PASSWORD 'password_baru';
Ketik \q untuk keluar.
Install PostgreSQL:
# sudo dnf install -y postgresql13-server
2. Konfigurasi Akses Jaringan (Opsional)
Untuk mengizinkan akses dari jaringan lain, edit file /var/lib/pgsql/9.6/data/pg_hba.conf dan postgresql.conf sesuai kebutuhan.
Restore Database
# /usr/pgsql-13/bin/pg_restore -h localhost -p 5432 -U postgres -d xsatriya -v "/opt/xsatriya.backup"
Backup Database
# /usr/pgsql-13/bin/pg_dump -h localhost -p 5432 -U postgres -F c -b -v -f "/opt/backupdb/xsatriya.backup" xsatriya
Create new file.pgpass.conf in /root/.pgpass for automatic password # nano /root/.pgpass
# chmod 600 /root/.pgpass
# vi /root/.pgpass
localhost:5432:*:postgres:password_db
# sudo yum update
# sudo rpm -q cronie
# sudo yum install cronie
Create Command
# sudo crontab -e
1 6 * * * /opt/backupdb.sh (tiap jam 6 lebih 1 menit)
1 12 * * * /opt/backupdb.sh (tiap jam 12 lebih 1 menit)
1 18 * * * /opt/backupdb.sh (tiap jam 18 lebih 1 menit)
1 1 * * * /opt/vpsrestart.sh (tiap jam 1 lebih 1 menit)
5 1 * * * /opt/webstart.sh (tiap jam 1 lebih 5 menit)
9 6,12,18 * * * /bin/bash /root/rclone.sh >/dev/null 2>&1 (backup ke mega)
Press i (for "insert") to begin editing the file.Pres esc to exit editing mode
Type :wq to save the file.
Cek Penggunaan Memory
# free -m
Restart PostgreSQL
# /etc/rc.d/init.d/postgresql-9.3 restart
Restart Server
# /sbin/shutdown -r now
# /opt/tomcat/bin/startup.sh
# iptables -L
# iptables -F
# iptables -L
# service iptables save
Cek Max Memory
java -XX:+PrintFlagsFinal -version | grep HeapSize
Setting Max Memory to 2048m (2048000000)
export _JAVA_OPTIONS="-Xms64m -Xmx2048m"
add this script to Catalina.sh
if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
. "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
Create a setenv.sh
manually, and put it into the tomcat-folder\bin\
folder.
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=2048m"
Restart Tomcat
- https://www.howtoforge.com/tutorial/how-to-install-tomcat-on-centos/
- http://jurnalinux.blogspot.co.id/2016/04/install-database-postgresql-95-di.html
- https://www.linode.com/docs/databases/postgresql/securely-manage-remote-postgresql-servers-with-pgadmin-on-windows
- https://www.pradha.id/read/setting-postgresql-agar-dapat-diakses-dari-luar
- https://linuxandryan.wordpress.com/2013/03/07/creating-and-using-a-pgpass-file/
- https://serverfault.com/questions/579233/permission-denied-on-owned-file
- https://www.rosehosting.com/blog/automate-system-tasks-using-cron-on-centos-7/
- http://www.pixelstech.net/article/1339424625-Create-cron-job-on-CentOS
- https://albennet.com/automaticallybackupdatatogoogledrive.php
- https://www.mynotepaper.com/mount-google-drive-using-gdrive-on-linux-server-with-own-oauth-credentials
- https://timothy-quinn.com/backing-up-a-directory-to-google-drive-on-centos-7/
- https://dzhorov.com/2017/04/creating-backups-from-linux-to-google-drive
- https://www.cyberciti.biz/faq/centos-memory-info-usage-command/
- https://mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/
- https://stackoverflow.com/questions/12797560/how-can-i-find-java-heap-size-and-memory-used-linux