write in front
I'm lazy, and don't want to knock one command after another. . . "Laziness is premised, not before or after. "
Briefly
- CentOS 7 minimal installation version: CentOS-7-x86_64-Minimal-1708
Basic configuration
Configure the network
- VM select bridge
- Manually configure the network address
- Verify that you can access the external network
VM clone system set static IP
cd /etc/sysconfig/network-scripts/ vi ifcfg-eno16777736
Comment out UUID, HWADDR
TYPE="Ethernet" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="yes" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" NAME="eno16777736" #UUID="10f47dcb-cc95-4aad-a56c-36fe7920f431" ONBOOT="yes" IPADDR0="192.168.199.200" PREFIX0="24" GATEWAY0="192.168.199.1" DNS1="8.8.8.8" DNS2="9.9.9.9" #HWADDR="00:0C:29:E3:95:59" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes"
restart network service
service network restart
Modify hostname
hostnamectl set-hostname serverHostName
query port
netstat -ntlp|grep 6379
System Time Synchronization Configuration
yum install ntpdate # Synchronized time server ntpdate time.nist.gov # or ntpdate -u 0.pool.ntp.org
There may be a problem with the synchronization time, see Solve the problem of synchronizing time with ntpdate under CentOS7
Install basic tools
Install net-tools
yum -y install net-tools
install wget
yum -y install wget # -c resumes the upload from a breakpoint, -O specifies the file name wget -c -O fileName url
Install curl
yum -y install curl
basic commands
Find the installation path:
whereis nginx
Find the file path:
find / -name nginx
Query the nginx process:
ps aux|grep nginx
Check the CentOS kernel version:
uname -r
Check if gcc is installed
rpm -qa|grep gcc
Uninstall software
Depends on your package format:
# If you have yum, you can directly yum remove xxx # If it is an rpm package, rpm -e xxx # tar package, you need to delete the file directly or make uninstall xxx
Uninstall Docker:
# Check yum list installed | grep docker # uninstall yum -y remove docker.xxx.x86_64 # delete rm -ef /var/lib/docker
#View ip information ip add #Display the full path of the current path pwd #file copy cp -r /bashrc /bak/bashrc #renew yum update tail -f /data/logs/xxxx/xxxx.log #View document content cat #View document content by page more #list all files ls -a #Copy folders and files in folders cp -r tomcat-xxxx tomcat-xxxx-new #Force delete a folder or file rm -rf logs #Empty file contents echo "">catalina.out #find files find / -name my.cnf # Find the process of tomcat-x-cas-server, # The second parameter is pid # kill process by pid ps -ef | grep "tomcat-x-cas-server" | grep -v grep | awk '{print $2}' | xargs kill -9
development environment
install java
1. Uninstall the built-in openjdk
rpm -qa|grep java rpm -e --nodeps java-xxx
2. Download jdk-8u181-linux-x64.tar.gz from Oracle official website
3. Unzip
tar –xzvf jdk-8u45-linux-x64.gz
4.jdk configuration
vi /etc/profile
export JAVA_HOME=jdk the absolute path of export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Use source /etc/profile to reload the configuration for the configuration to take effect.
or
Use the reboot command to restart the system to make the environment variables take effect.
5. Test if the installation is successful
java -version javac
Install Maven
yum -y install maven
Install Git
yum -y install git # git clone --branch [tags label] [git address]
install tomcat
# Download apache-tomcat-8.5.23.tar.gz through wget wget -c -O apache-tomcat-8.5.23.tar.gz http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz # Unzip apache-tomcat-8.5.23.tar.gz tar -xzvf apache-tomcat-8.5.23.tar.gz # start tomcat ./startup.sh # Add port 8080 to firewall exceptions and reboot firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --reload
Install MySQL
#1. Download the mysql repo source wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm #2. Install the mysql repo source rpm -ivh mysql57-community-release-el7-8.noarch.rpm #3. Install mysql yum -y install mysql-server
After Mysql5.7 is installed by default, root has a password.
Get MySQL Temporary Password
To enhance security, MySQL 5.7 randomly generates a password for the root user. In the error log, the location of the error log, if the RPM package is installed, is /var/log/mysqld.log by default.
The temporary password can only be viewed after mysql has been started once
#View original password grep 'temporary password' /var/log/mysqld.log #Add port 3306 to firewall exceptions and reboot firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload
#change Password ALTER USER 'root'@'localhost' IDENTIFIED BY 'eFeG20125'; #Authorize remote network access GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.199.%' IDENTIFIED BY 'eFeG20125' WITH GRANT OPTION; flush privileges;
MySQL 5.7.25 https://blog.csdn.net/qq_30162219/article/details/87768612
Install Redis
#1. Set the repository address of Redis yum -y install epel-release #2. Install Redis yum -y install redis #3. redis related directories and files rpm -ql redis [root[@galsang](https://my.oschina.net/u/3537623) ~]# rpm -ql redis /etc/logrotate.d/redis /etc/redis-sentinel.conf /etc/redis.conf /etc/systemd/system/redis-sentinel.service.d /etc/systemd/system/redis-sentinel.service.d/limit.conf /etc/systemd/system/redis.service.d /etc/systemd/system/redis.service.d/limit.conf /usr/bin/redis-benchmark /usr/bin/redis-check-aof /usr/bin/redis-check-rdb /usr/bin/redis-cli /usr/bin/redis-sentinel /usr/bin/redis-server /usr/lib/systemd/system/redis-sentinel.service /usr/lib/systemd/system/redis.service /usr/libexec/redis-shutdown /usr/share/doc/redis-3.2.12 /usr/share/doc/redis-3.2.12/00-RELEASENOTES /usr/share/doc/redis-3.2.12/BUGS /usr/share/doc/redis-3.2.12/CONTRIBUTING /usr/share/doc/redis-3.2.12/MANIFESTO /usr/share/doc/redis-3.2.12/README.md /usr/share/licenses/redis-3.2.12 /usr/share/licenses/redis-3.2.12/COPYING /usr/share/man/man1/redis-benchmark.1.gz /usr/share/man/man1/redis-check-aof.1.gz /usr/share/man/man1/redis-check-rdb.1.gz /usr/share/man/man1/redis-cli.1.gz /usr/share/man/man1/redis-sentinel.1.gz /usr/share/man/man1/redis-server.1.gz /usr/share/man/man5/redis-sentinel.conf.5.gz /usr/share/man/man5/redis.conf.5.gz /var/lib/redis /var/log/redis /var/run/redis
Configure redis.conf
etc/redis.conf
#bind 127.0.0.1 requirepass redisPassword
open redis port
Add port 6379 to firewall exceptions and reboot
firewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload
start up
Start method
Client connection method
Install Nginx
yum -y install nginx /usr/sbin/nginx -s reload # Restart the nginx service service nginx restart # Add port 80 to firewall exceptions and reboot firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload
Install RabbitMQ
Configure swap swap area
# Determine the optimal block size for your hard drive: dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file dd if=/dev/zero bs=2048 count=500000 of=/root/1Gb.file dd if=/dev/zero bs=4096 count=250000 of=/root/1Gb.file dd if=/dev/zero bs=8192 count=125000 of=/root/1Gb.file # The optimal block size for your system can be determined by comparing the command execution times shown in the command output above. free -m df -h cd /var dd if=/dev/zero of=swapfile bs=1024 count=4096 #dd if=/dev/zero of=swapfile bs=4M count=2048 /sbin/mkswap swapfile ll swapfile /sbin/swapon swapfile /sbin/swapon -s vim /etc/fstab /var/swapfile swap swap defaults 0 0 #Stop all swap partitions swapoff -a