配置centos运行环境
- 一 安装httpd,tomcat,jdk,mysql
- 1 安装httpd
- 2 安装tomcat
- 3 安装jdk
- 三 MySql的安装
- 1 克隆出来两台虚拟机
- 2 配置虚拟机
- 3 链接xhsell
- 4 链接xftp
- 5 mysql8的安装
- 6 mysql5.7的安装
一 安装httpd,tomcat,jdk,mysql
1 安装httpd
- 下载httpd
yum -y install httpd
- 关闭防火墙
systemctl stop firewalld
- 启动httpd的服务
service httpd start
- 浏览器里输入主机号
http://192.168.80.121:80
- 显示效果如图所示
2 安装tomcat
-操作流程
76 mkdir /usr/tomcat
# 77 ll
78 chmod 777 apache-tomcat-7.0.68.tar.gz
# 79 ll
80 tar -zxvf apache-tomcat-7.0.68.tar.gz
# 81 ll
# 82 tar -zxvf apache-tomcat-7.0.68.tar.gz -C /usr/java
83 tar -zxvf apache-tomcat-7.0.68.tar.gz -C /usr/tomcat
# 84 ll
# 85 cd /usr/tomcat/apache-tomcat-7.0.57/bin/
# 86 cd /usr/tomcat/apache-tomcat-7.0.57/bin
87 cd /usr/tomcat/apache-tomcat-7.0.68/bin/
# 88 ll
89 ./startup.sh
- 运行结果
3 安装jdk
- 查看以前是否装了openjdk
rpm -qa | grep java
- 安装核心指令
chmod 777 jdk-8u261-linux-x64.tar.gz
ll
tar -zxvf jdk-8u261-linux-x64.tar.gz
#安装到指定目录
tar -zxvf jdk-8u261-linux-x64.tar.gz -C /usr/java
- 配置环境变量
vi /etc/profile
在底部追加
export JAVA_HOME=/usr/java/jdk1.8.0_261/
export
CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
重启环境变量
source /etc/profile
java -version
- 运行结果
- 查看日志信息
tail -200f /usr/tomcat/apache-tomcat-7.0.68/logs/catalina.out
- 查看日志与启动服务一起
./startup.sh && tail -200f ../logs/catalina.out
- 关闭服务
./shutdown.sh
三 MySql的安装
1 克隆出来两台虚拟机
直接关闭掉,然后点击虚拟机名称,一直修改就可以
2 配置虚拟机
-
mac地址
1.网络适配器,高级
2.点生成mac地址,多点两下
-
主机名
因为我没有设置主机名,所以这一步可以不更改,毕竟主机名的作用就是IP地址的一个别名 -
IP地址
修改ip:192.168.80.121
为 : 192.168.80.122 -
UUID
修改一位就行 -
重启虚拟机
systemctl restart network
3 链接xhsell
4 链接xftp
把mysql安装包传上去
5 mysql8的安装
- 1 给tmp文件提升权限
chmod -R 777 /tmp
- 2 安装前检查依赖,如果不存在,就重新安装
128 rpm -qa|grep libaio
129 rpm -qa|grep net-tools
130 yum install net-tools
131 rpm -qa|grep net-tools
- 3 安装时依次执行下列命令
134 cd /opt
135 ll
136 rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
137 rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
# 138 rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
139 yum remove mysql-libs
140 rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
# 141 rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpmmysql-community-client-8.0.25-1.el7.x86_64.rpm
142 rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
143 history
144 rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
# 145 mysql -version
146 mysql --version
- 4 安装成功
[root@localhost opt]# mysql --version
mysql Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
- 5 服务初始化
这一步初始化完成后会生成一个初始化密码
mysqld --initialize --user=mysql
查看生成的初始密码是什么
[root@localhost opt]# cat /var/log/mysqld.log
2023-04-20T10:40:52.202809Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.25) initializing of server in progress as process 1669
2023-04-20T10:40:52.209496Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-04-20T10:40:52.906412Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-04-20T10:40:53.523745Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: %=5NuG>6Y25p
[root@localhost opt]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
启动服务并查看状态
[root@localhost opt]# systemctl start mysqld
[root@localhost opt]# systemctl status mysqld
开机自启动的一些测试
[root@localhost opt]# systemctl list-unit-files|grep mysqld.service
mysqld.service enabled
[root@localhost opt]# systemctl disable mysqld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
[root@localhost opt]# systemctl list-unit-files|grep mysqld.service
mysqld.service disabled
[root@localhost opt]# systemctl enabled mysqld.service
Unknown operation 'enabled'.
[root@localhost opt]# systemctl enable mysqld.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@localhost opt]# systemctl list-unit-files|grep mysqld.service
mysqld.service enabled
登录并修改密码
[root@localhost opt]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.25
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
测试创建一个数据库
mysql> create database xieyitang;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| xieyitang |
+--------------------+
5 rows in set (0.00 sec)
6 mysql5.7的安装
- 1 给tmp文件提升权限
chmod -R 777 /tmp
- 2 安装前检查依赖,如果不存在,就重新安装
128 rpm -qa|grep libaio
129 rpm -qa|grep net-tools
130 yum install net-tools
131 rpm -qa|grep net-tools
- 3 安装时依次执行下列命令
127 cd /opt
128 ll
129 chmod -R 777 /tmp
130 rpm -qa|grep libaio
131 rpm -qa|grep net-tools
132 yum install net-tools
133 ll
134 rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
135 yum install net-tools
136 rpm -qa|grep net-tools
137 yum install net-tools
138 rpm -qa|grep net-tools
139 rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
140 yum remove mysql-libs
141 ll
142 rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
143 rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
144 rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
145 rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
146 rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
147 mysql --version
148 mysqld --initialize --user=mysql
149 cat /var/log/mysqld.log
150 systemctl status mysqld
151 systemctl start mysqld
152 systemctl status mysqld
153 systemctl list-unit-files|grep
154 systemctl list-unit-files|grep mysqld.service
155 mysql -uroot -p
156 history
- 4 安装成功
[root@localhost opt]# mysql --version
mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper
- 5 进入mysql中修改密码
[root@localhost opt]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases
-> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> aLTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> quit
Bye