Academia JavaEE Workspace in MacOS: Difference between revisions
Jump to navigation
Jump to search
(→Redis) |
|||
(34 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Java== | ==Java== | ||
{| | |||
|valign="top"| | |||
/usr/libexec/java_home -v1.8.0_321 | |||
/usr/libexec/java_home -v1.8.0_241 | |||
/usr/libexec/java_home -v22.0.0.2 | |||
/usr/libexec/java_home -v1.7.0_80 | |||
/usr/libexec/java_home -v1.8.0 | |||
|valign="top"| | |||
sudo rm -rf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.0.0.2/ | |||
sudo rm -rf /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/ | sudo rm -rf /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/ | ||
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/ | |||
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/ | |||
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/ | sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/ | ||
|- | |||
|colspan="2"| | |||
---- | |||
|- | |||
|valign="top" colspan="2"| | |||
<source lang="bash"> | <source lang="bash"> | ||
export JAVA_HOME=`/usr/libexec/java_home -v1.8.0` | export JAVA_HOME=`/usr/libexec/java_home -v1.8.0` | ||
brew install java11 | |||
brew install maven | |||
brew install ant | |||
</source> | |||
|- | |||
|colspan="2"| | |||
'''GraalVM:''' | |||
---- | |||
|- | |||
|valign="top" colspan="2"| | |||
<source lang="bash"> | |||
sudo wget -c https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/\ | |||
graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz -P /Library/Java/JavaVirtualMachines/ | |||
sudo tar -xvzf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz\ | |||
-C /Library/Java/JavaVirtualMachines/ | |||
sudo rm -rf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz | |||
export GRAALVM_HOME=`/usr/libexec/java_home -v22.0.0.2` | |||
export JAVA_HOME=`/usr/libexec/java_home -v22.0.0.2` | |||
</source> | </source> | ||
|} | |||
==PostgreSQL== | ==PostgreSQL== | ||
===Install=== | ===Install=== | ||
<source lang="bash" highlight=" | <source lang="bash" highlight="9-11,13,17,27"> | ||
brew formulae | grep postgresql@ | |||
brew services stop postgresql | brew services stop postgresql | ||
brew uninstall postgresql | brew uninstall postgresql | ||
brew cleanup | |||
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.postgresql* | rm -rf ~/Library/LaunchAgents/homebrew.mxcl.postgresql* | ||
rm -rf /usr/local/var/postgres* | rm -rf /usr/local/var/postgres* | ||
brew install | brew install postgresql@14 | ||
brew services start postgresql | brew services start postgresql@14 | ||
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist | ||
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist | ||
brew services list | brew services list | ||
vim /usr/local/var/postgres/postgresql.conf | |||
: <<'END_COMMENT' | |||
listen_addresses = '*' # what IP address(es) to listen on; | |||
# comma-separated list of addresses; | |||
# defaults to 'localhost'; use '*' for all | |||
# 'localhost,10.19.83.10' | |||
# (change requires restart) | |||
END_COMMENT | |||
vim /usr/local/var/postgres/pg_hba.conf | |||
: <<'END_COMMENT' | |||
# IPv4 local connections: | |||
host all all 127.0.0.1/32 trust | |||
host all all 10.19.83.1/24 trust | |||
END_COMMENT | |||
createuser -s postgres | |||
createuser $USER | |||
createdb $USER | createdb $USER | ||
</source> | </source> | ||
=== | <source lang="sql"> | ||
CREATE USER postgres SUPERUSER; | |||
CREATE DATABASE postgres WITH OWNER postgres; | |||
</source> | |||
===Create=== | |||
<source lang="sql"> | <source lang="sql"> | ||
CREATE DATABASE academia; | CREATE DATABASE academia; | ||
Line 34: | Line 97: | ||
psql academia < academia.sql | psql academia < academia.sql | ||
psql -h db00.chorke.org -p 5432 -d academia -U academia | |||
psql -h db00.chorke.org -p 5432 -d academia -U academia -W -f academia.sql | |||
pg_restore -h db00.chorke.org -p 5432 -d academia -U academia academia.dump | |||
===Delete=== | |||
<source lang="sql"> | |||
REVOKE CONNECT ON DATABASE academia FROM public; | |||
SELECT pg_terminate_backend(pg_stat_activity.pid) | |||
FROM pg_stat_activity | |||
WHERE pg_stat_activity.datname in ('academia'); | |||
</source> | |||
ps -ef | grep postgres | |||
kill -9 PID | |||
<source lang="sql"> | |||
DROP DATABASE IF EXISTS academia; | |||
</source> | |||
== pgAdmin4== | |||
brew install --cask pgadmin4 | |||
==Redis== | ==Redis== | ||
Line 39: | Line 123: | ||
brew services stop redis | brew services stop redis | ||
brew uninstall redis | brew uninstall redis | ||
brew cleanup | |||
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.redis* | rm -rf ~/Library/LaunchAgents/homebrew.mxcl.redis* | ||
Line 55: | Line 140: | ||
mkdir -p $HOME/chorke | mkdir -p $HOME/chorke | ||
mkdir -p /opt/dev/$USER/chorke/academia | mkdir -p /opt/dev/$USER/chorke/academia | ||
chown $USER:$USER -R /opt/dev/$USER | |||
export ACADEMIA_WSS="$HOME/chorke/academia" | export ACADEMIA_WSS="$HOME/chorke/academia" | ||
Line 64: | Line 150: | ||
==Git SCM== | ==Git SCM== | ||
<source lang="bash"> | <source lang="bash"> | ||
ssh-keygen -t rsa -b 4096 -C "[email protected]" | ssh-keygen -t rsa -b 4096 -C "[email protected]" | ||
: <<'END_COMMENT' | |||
Generating public/private rsa key pair. | |||
Enter file in which to save the key (/home/user/.ssh/id_rsa): /home/user/.ssh/git_academia_chorke_org_rsa | |||
Enter passphrase (empty for no passphrase): | |||
Enter same passphrase again: | |||
Your identification has been saved in /home/user/.ssh/git_academia_chorke_org_rsa | |||
Your public key has been saved in /home/user/.ssh/git_academia_chorke_org_rsa.pub | |||
The key fingerprint is: | |||
SHA256:TXBbBINcPcVtdVFRjs/P+jaxMFAIwr3uqdlt8tmrLVQ [email protected] | |||
The key's randomart image is: | |||
+---[RSA 4096]----+ | |||
| .oo+*++o.+@| | |||
| .++ =o..o+| | |||
| + .....| | |||
| + . E o | | |||
| S . o o| | |||
| . . o o.| | |||
| . o o =| | |||
| o+.o+ +.| | |||
| o..+=o+ooo| | |||
+----[SHA256]-----+ | |||
END_COMMENT | |||
ls -lah ~/.ssh/ | |||
cat < ~/.ssh/git_academia_chorke_org_rsa.pub | |||
</source> | |||
<source lang="bash"> | |||
nano ~/.ssh/config | |||
: <<'END_COMMENT' | : <<'END_COMMENT' | ||
Host git.academia.chorke.org | Host git.academia.chorke.org | ||
Line 77: | Line 186: | ||
User git | User git | ||
END_COMMENT | END_COMMENT | ||
</source> | |||
<source lang="bash"> | |||
git config --global user.email "[email protected]" | |||
git config --global user.name "FULL NAME" | git config --global user.name "FULL NAME" | ||
ssh -vT git.academia.chorke.org | |||
</source> | |||
==Knowledge== | |||
'''disk usage''' | |||
du -h /var | |||
du -sh /var | |||
du -csh ~/Do* | |||
du -csh /var/log /var/lib | |||
du -sh --apparent-size /var/lib | |||
du -h /var/ | sort -rh | head -5 | |||
<source lang="bash"> | |||
#nano ~/.bashrc | |||
#nano ~/.zshenv | |||
#nano ~/.profile | |||
#nano ~/.bash_profile | |||
export ACADEMIA_WSS="$HOME/chorke/academia" | |||
export ACADEMIA_LOG_PATH="$HOME/.chorke/academia/var/http/logs" | |||
</source> | |||
<source lang="bash"> | |||
source ~/.bashrc | |||
source ~/.profile | |||
source ~/.bash_profile | |||
source ~/.zshenv | |||
source ~/.zprofile/.zlogin | |||
</source> | |||
'''git stashing''' | |||
git stash; git checkout -b new_branch; git stash pop | |||
git add .; git commit -m "new feature added"; git push | |||
<source lang="bash"> | |||
ssh-keygen -p -f ~/.ssh/git_academia_chorke_org_rsa | |||
: <<'END_COMMENT' | |||
Enter old passphrase: | |||
Key has comment '[email protected]' | |||
Enter new passphrase (empty for no passphrase): | |||
Enter same passphrase again: | |||
Your identification has been saved with the new passphrase. | |||
END_COMMENT | |||
</source> | </source> | ||
'''comment and uncomment sql''' | |||
sed -i -e 's|^|-- |g' src/main/resources/db/migration/*.sql | |||
sed -i -e 's|^-- ||g' src/main/resources/db/migration/*.sql | |||
==References== | |||
* [https://stackoverflow.com/questions/15301826 psql: FATAL: role <code>postgres</code> does not exist] | |||
* [https://stackoverflow.com/questions/135688/ Setting environment variables on MacOS] | |||
* [https://gist.github.com/tomysmile/1b8a321e7c58499ef9f9441b2faa0aa8 Install & Config Redis Server in MacOS] | |||
* [https://stackoverflow.com/questions/26378098/ Restore dump on the remote machine] | |||
* [https://stackoverflow.com/questions/17449420 Postgresql unable to drop database] | |||
* [https://stackoverflow.com/questions/2099471/ Add a prefix beginning of each line] | |||
* [https://www.graalvm.org/java/quickstart/ GraalVM Quick Start Guide] | |||
* [[PostgreSQL]] |
Latest revision as of 10:13, 19 November 2023
Java
/usr/libexec/java_home -v1.8.0_321 /usr/libexec/java_home -v1.8.0_241 /usr/libexec/java_home -v22.0.0.2 /usr/libexec/java_home -v1.7.0_80 /usr/libexec/java_home -v1.8.0 |
sudo rm -rf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.0.0.2/ sudo rm -rf /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/ |
| |
export JAVA_HOME=`/usr/libexec/java_home -v1.8.0`
brew install java11
brew install maven
brew install ant
| |
GraalVM: | |
sudo wget -c https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/\
graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz -P /Library/Java/JavaVirtualMachines/
sudo tar -xvzf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz\
-C /Library/Java/JavaVirtualMachines/
sudo rm -rf /Library/Java/JavaVirtualMachines/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz
export GRAALVM_HOME=`/usr/libexec/java_home -v22.0.0.2`
export JAVA_HOME=`/usr/libexec/java_home -v22.0.0.2`
|
PostgreSQL
Install
brew formulae | grep postgresql@
brew services stop postgresql
brew uninstall postgresql
brew cleanup
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.postgresql*
rm -rf /usr/local/var/postgres*
brew install postgresql@14
brew services start postgresql@14
launchctl unload ~/Library/LaunchAgents/[email protected]
launchctl load ~/Library/LaunchAgents/[email protected]
brew services list
vim /usr/local/var/postgres/postgresql.conf
: <<'END_COMMENT'
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# 'localhost,10.19.83.10'
# (change requires restart)
END_COMMENT
vim /usr/local/var/postgres/pg_hba.conf
: <<'END_COMMENT'
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 10.19.83.1/24 trust
END_COMMENT
createuser -s postgres
createuser $USER
createdb $USER
CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;
Create
CREATE DATABASE academia;
CREATE USER academia WITH ENCRYPTED PASSWORD 'academia';
GRANT ALL PRIVILEGES ON DATABASE academia TO academia;
psql academia < academia.sql psql -h db00.chorke.org -p 5432 -d academia -U academia psql -h db00.chorke.org -p 5432 -d academia -U academia -W -f academia.sql pg_restore -h db00.chorke.org -p 5432 -d academia -U academia academia.dump
Delete
REVOKE CONNECT ON DATABASE academia FROM public;
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname in ('academia');
ps -ef | grep postgres kill -9 PID
DROP DATABASE IF EXISTS academia;
pgAdmin4
brew install --cask pgadmin4
Redis
brew services stop redis
brew uninstall redis
brew cleanup
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.redis*
rm -rf /usr/local/var/redis*
brew install redis
brew services start redis
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
vim /usr/local/etc/redis.conf
brew services list
Workspace
mkdir -p $HOME/chorke
mkdir -p /opt/dev/$USER/chorke/academia
chown $USER:$USER -R /opt/dev/$USER
export ACADEMIA_WSS="$HOME/chorke/academia"
ln -s /opt/dev/$USER/chorke/academia $ACADEMIA_WSS
ls -lah $HOME/chorke
vim ~/.bash_profile
Git SCM
ssh-keygen -t rsa -b 4096 -C "[email protected]"
: <<'END_COMMENT'
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): /home/user/.ssh/git_academia_chorke_org_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/git_academia_chorke_org_rsa
Your public key has been saved in /home/user/.ssh/git_academia_chorke_org_rsa.pub
The key fingerprint is:
SHA256:TXBbBINcPcVtdVFRjs/P+jaxMFAIwr3uqdlt8tmrLVQ [email protected]
The key's randomart image is:
+---[RSA 4096]----+
| .oo+*++o.+@|
| .++ =o..o+|
| + .....|
| + . E o |
| S . o o|
| . . o o.|
| . o o =|
| o+.o+ +.|
| o..+=o+ooo|
+----[SHA256]-----+
END_COMMENT
ls -lah ~/.ssh/
cat < ~/.ssh/git_academia_chorke_org_rsa.pub
nano ~/.ssh/config
: <<'END_COMMENT'
Host git.academia.chorke.org
HostName git.academia.chorke.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_academia_chorke_org_rsa
User git
END_COMMENT
git config --global user.email "[email protected]"
git config --global user.name "FULL NAME"
ssh -vT git.academia.chorke.org
Knowledge
disk usage du -h /var du -sh /var du -csh ~/Do* du -csh /var/log /var/lib du -sh --apparent-size /var/lib du -h /var/ | sort -rh | head -5
#nano ~/.bashrc
#nano ~/.zshenv
#nano ~/.profile
#nano ~/.bash_profile
export ACADEMIA_WSS="$HOME/chorke/academia"
export ACADEMIA_LOG_PATH="$HOME/.chorke/academia/var/http/logs"
source ~/.bashrc
source ~/.profile
source ~/.bash_profile
source ~/.zshenv
source ~/.zprofile/.zlogin
git stashing git stash; git checkout -b new_branch; git stash pop git add .; git commit -m "new feature added"; git push
ssh-keygen -p -f ~/.ssh/git_academia_chorke_org_rsa
: <<'END_COMMENT'
Enter old passphrase:
Key has comment '[email protected]'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
END_COMMENT
comment and uncomment sql sed -i -e 's|^|-- |g' src/main/resources/db/migration/*.sql sed -i -e 's|^-- ||g' src/main/resources/db/migration/*.sql