[Tools] 001-CentOS7 Minimal Installation Configuration

write in front

I'm lazy, and don't want to knock one command after another. . .

"Laziness is premised, not before or after. "


  • 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


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 

#file copy 
cp -r /bashrc /bak/bashrc

yum update 

tail -f /data/logs/xxxx/xxxx.log 

#View document content

#View document content by page

#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.


Use the reboot command to restart the system to make the environment variables take effect.

5. Test if the installation is successful

java -version


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 

# 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
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

The meaning of each parameter

Configure redis.conf


    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

Install RabbitMQ on CentOS7

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 

Tags: CentOS centos7

Posted by horsefaceba on Wed, 25 May 2022 12:02:07 +0300