Linux 系统:第十章:服务器环境搭建,附 Java 面经
备份:cp profile profile.bak
修改:vim profile
大写 G,进入文件末尾,输入 i 进行修改模式,末尾添加以下配置:
JAVA_HOME=/opt/jdk1.8.0_152
PATH=PATH
export JAVA_HOME PATH
然后保存退出:按 Esc+:wq
执行当前连接刚刚配置的脚本文件使配置文件生效:source /etc/profile???? 或者 reboot 重启
查看 jdk 版本:java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
查看:path 路径:echo $PATH
/opt/jdk1.8.0_152/bin:/opt/jdk1.8.0_152/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
查看:JAVA_HOME 路径:echo $JAVA_HOME
/opt/jdk1.8.0_152
Tomcat 安装与配置
进入 opt 目录:cd /opt
在 opt 目录下上传 apache-tomcat-8.5.24.tar.gz
解压:?tar -zxvf apache-tomcat-8.5.24.tar.gz
启动 tomcat: /opt/apache-tomcat-8.5.24/bin/startup.sh
如果报错进入 logs 目录查看:cd /opt/apache-tomcat-8.5.24/logs
查看日志:less catalina.out
MySQL 的安装与配置
进入 opt 目录:cd /opt
在 opt 目录下上传 MySQL-server-5.5.52-1.el6.x86_64.rpm 和 MySQL-client-5.5.52-1.el6.x86_64.rpm
忽略依赖关系执行删除:rpm -e --nodeps mariadb-libs-1:5.5.56-2.el7.x86_64
安装服务端:rpm -ivh /opt/MySQL-server-5.5.52-1.el6.x86_64.rpm
安装客户端:rpm -ivh /opt/MySQL-client-5.5.52-1.el6.x86_64.rpm
查看版本:mysqladmin --version
mysqladmin? Ver 8.42 Distrib 5.5.52, for Linux on x86_64
启动 MySQL 服务:systemctl start mysql.service
查看服务状态:systemctl status mysql.service
查看端口:netstat -anp|grep 3306
查看 mysql 运行的进程:ps -ef|grep mysql|grep -v grep
设置 root 用户和密码:mysqladmin -u root password
New password:
Confirm new password:
登录 mysql:mysql -u root -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.52 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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;
使用 test 数据库:user test;
查看表:show tables;
退出:exit;
然后去 windows 的 sqlYog 连接,主机改为 linux 连接:192.168.134.100,用户名:root,密码:root
测试连接不上,linux 中查看防火墙:systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
8 月 12 07:32:47 rich systemd[1]: Starting firewalld - dynamic firewall daemon...
评论