【CentOS7】快速部署常用环境

1. VMware部署虚拟机镜像

1
https://mirrors.tuna.tsinghua.edu.cn/centos/7.8.2003/isos/x86_64/CentOS-7-x86_64-Minimal-2003.iso

2. 静态网络

1
vi /etc/sysconfig/network-scripts/ifcfg-ens33

#虚拟网络编辑器子网网段=虚拟机静态网段
#虚拟网络编辑器网关IP=虚拟机网关IP

1
2
3
4
5
6
ONBOOT=yes
IPADDR=192.168.1.155
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
DNS1=8.8.8.8
DNS2=114.114.114.114

#重启网络服务后可以配置shell连接

1
systemctl restart network

#检查网络上下行

1
ping www.baidu.com

#修改主机名称

1
hostnamectl set-hostname SRSA

3. 配置AliYum源

1
2
3
4
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

4. 安装环境工具

1
yum install -y wget vim tar net-tools lrzsz gcc zlib zlib-devel openssl openssl--devel pcre pcre-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel zlib1g-dev zlib* yum-utils

#配置vim缩进

1
2
3
4
cd
vim .vimrc
set nu
set ts=4

5. 安装JDK

1
2
3
wget https://download.oracle.com/otn/java/jdk/8u391-b13/b291ca3e0c8548b5a51d5a5f50063037/jdk-8u391-linux-x64.tar.gz?AuthParam=1702946371_b88f1bee7d883e538175cc4510f5be04
tar -zxf jdk-8u391-linux-x64.tar.gz\?AuthParam\=1702946371_b88f1bee7d883e538175cc4510f5be04
mv jdk1.8.0_391 /usr/local/jdk8

6. 配置环境变量

1
2
3
4
5
vim /etc/profile
JAVA_HOME=/usr/local/jdk8
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
. /etc/profile

#测试变量

1
2
echo $JAVA_HOME
java -version

7. 部署MySQL

1
2
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum install mysql57-community-release-el7-10.noarch.rpm

#确认版本

1
2
yum repolist enabled | grep "mysql.*-community.*"
yum repolist enabled | grep mysql

#安装服务器

1
yum install mysql-community-server

#如果Failing package

1
2
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-community-server

#启动服务

1
2
3
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld

#查看默认密码

1
grep 'temporary password' /var/log/mysqld.log

#登录修改密码

1
2
3
4
5
6
mysql -uroot -p
84hBXq>x8_d/
ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'YXKglodon!23';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YXKglodon!23' WITH GRANT OPTION;
flush privileges;
select host,user,authentication_string from mysql.user;

#大小写敏感

1
2
3
4
show variables like "%case%";
vim /etc/my.cnf
lower_case_table_names=1
systemctl restart mysqld

8. 关闭防火墙

1
2
systemctl stop firewalld
systemctl disable firewalld