
Hi, my name is Bing Zhang, I always focus on Java, .Net, Frontend, Database, CI and Docker.
Introduce how to operate MySQL on CentOS. Installation wget rpm from http://dev.mysql.com/downloads/repo/yum/. Install release package (Example): sudo rpm -Uvh mysql80-community-release-el6-n.noarch.rpm Select Version yum repolist all | grep mysql sudo yum-config-manager --disable mysql80-community sudo yum-config-manager --enable mysql57-community yum repolist enabled | grep mysql Install & Config MySQL sudo yum install mysql-community-server sudo systemctl start mysqld.service sudo systemctl enable mysqld.service // as service at start sudo grep 'temporary password' /var/log/mysqld.log mysql -uroot -p MYSQL > ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword!'; Remote Access SQL UPDATE user SET Host='%' WHERE User='root'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES; Firewall firewall-cmd --add-port=3306/tcp firewall-cmd --permanent --add-port=3306/tcp MISC https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
Git Commands Useful Commands Commit with empty message git config --global alias.nccommit "commit -a --allow-empty-message -m ''" git nccommit Undoing Things Overwrite commit git commit -m 'initial commit' git add . git commit --amend Unstaging a Staged File $ git add * $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: README.md -> README modified: CONTRIBUTING.md $ git reset HEAD CONTRIBUTING.md Unstaged changes after reset: M CONTRIBUTING.md $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: README.md -> README Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: CONTRIBUTING.md Unmodifying a Modified File Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: CONTRIBUTING.md $ git checkout -- CONTRIBUTING.md $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: README.md -> README View all logs git reflog Push changes to new branch git checkout -b newBranch git push -u origin newBranch // -u is short for --set-upstream New branch from remote git checkout -b localBranch origin/remote_branch Stash Usage git stash // stash current changes git stash pop // pop last stash and remove from history git stash save 'message' // stash current changes with message git stash list // show all stashes git stash apply <id> // apply <id> stash Common Alias git config --global alias.s "status" git config --global alias.a "!git add . && git status" git config --global alias.au "!git add -u . && git status" git config --global alias.aa "!git add . && git add -u . && git status" git config --global alias.c "commit" git config --global alias.cm "commit -m" git config --global alias.ca "commit --amend" git config --global alias.ac "!git add . && git commit" git config --global alias.acm "!git add . && git commit -m" git config --global alias.l "log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset" git config --global alias.ll "log --stat --abbrev-commit" git config --global alias.lg "log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" git config --global alias.llg 'log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit" git config --global alias.d "diff" git config --global alias.master "checkout master" git config --global alias.spull "svn rebase" git config --global alias.spush "svn dcommit" git config --global alias.alias "!git config --list | grep 'alias.' | sed 's/alias.(1)=(.)/1 => 2/' | sort" Workflow with Git: Fork, Branching, Commits, and Pull Request Fork a repo. Clone the forked project to your local machine: `$ git clone git@github.com:USERNAME/<forked_repo>` Configure remotes: `$ git remote add upstream git://github.com/<origin_repo>` Create a branch for new feature: `$ git checkout -b my-new-branch` Develop on my-new-branch branch only, but Do not merge my-new-branch branch to the your master (as it should stay equal to upstream master)!! Commit changes to my-new-branch branch: $ git add . $ git commit -m "commit message" Push branch to GitHub, to allow your mentor to review your code: `$ git push origin my-new-branch` Repeat steps 5-7 till development is complete. Fetch upstream changes that were done by other contributors: `$ git fetch upstream` Update local master: $ git checkout master $ git pull upstream master ATTENTION: any time you lost of track of your code – launch “gitk —all” in source folder, UI application come up that will show all branches and history in pretty view, explanation. Rebase my-new-branch branch on top of the upstream master: $ git checkout my-new-branch $ git rebase master In the process of the rebase, it may discover conflicts. In that case it will stop and allow you to fix the conflicts. After fixing conflicts, use git add . to update the index with those contents, and then just run:$ git rebase --continue Push branch to GitHub (with all your final changes and actual code):We forcing changes to your issue branch(our sand box) is not common branch, and rebasing means recreation of commits so no way to push without force. NEVER force to common branch. $ git push origin my-new-branch --force Created build for testing and send it to any mentor for testing. Only after all testing is done – Send a Pull Request.Attention: Please recheck that in your pull request you send only your changes, and no other changes!!Check it by command:git diff my-new-branch upstream/master submodule git submodule add submodule-repo path git submodule update --init --recursive git rm submodule-name git rm submodule-name --cached = ↩
Installation and Configuration on CentOS Requirement Open a terminal and switch to root user. su - yum install -y java-1.8.0 wget java -version Create Tomcat Service Account groupadd tomcat useradd -g tomcat -d /opt/tomcat -s /bin/nologin tomcat Download & Setup Apache Tomcat wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz tar -zxvf apache-tomcat-*.tar.gz mv apache-tomcat-8.5.20/* /opt/tomcat/ chown -R tomcat:tomcat /opt/tomcat/ Set Environment Variables mkdir /opt/tomcat/bin/setenv.sh chmod 777 /opt/tomcat/bin/setenv.sh Example: export variableName=value ... Systemd vi /etc/systemd/system/tomcat.service Add below information to Tomcat systemd service file. [Unit] Description=Apache Tomcat 8.x Web Application Container Wants=network.target After=network.target [Service] Type=forking Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment='CATALINA_OPTS=-Xms512M -Xmx1G -Djava.net.preferIPv4Stack=true' Environment='JAVA_OPTS=-Djava.awt.headless=true' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh SuccessExitStatus=143 User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target Reload systemd daemon. systemctl daemon-reload systemctl start tomcat systemctl status tomcat systemctl enable tomcat //Enable the auto start of Tomcat service on system start Verify Apache Tomcat By default, Tomcat runs on port no 8080. Use netstat command to check whether the service is listening on port 8080 or not. netstat -antup | grep 8080 Output: tcp6 0 0 :::8080 :::* LISTEN 2428/java Firewall You may need to allow port 8080 in the firewall so that we can access Tomcat from external networks. firewall-cmd --permanent --add-port=8080/tcp firewall-cmd --reload