平时都是使用"印象笔记"随手写一些笔记之类的东西,久而久之就导致记录的内容会有重复,相同的东西可能被记录了多次,东一块西一块的,内容过于分散且不够精简。正好最近在整理"印象笔记"中的内容,借此机会把一些整理好的内容发布出来供大家参考,自己也顺便回顾一下,全当是复习了。

一、安装JDK

  • 在Linux上创建目录:/usr/local/java
cd  /usr/local
mkdir  java
  • 下载linux版本的java,通过FileZilla上传到/usr/local/java目录下
FileZilla下载地址:https://pan.baidu.com/s/1n0HAzW2FWCRZ7inDfWESVg  提取码:v12u
JDK地址:https://pan.baidu.com/s/1xMb_1LcrD81fvGdtMQKW-w  提取码:sbiu
  • 解压
tar -zxvf  jdk-8u241-linux-x64.tar.gz
  • 配置环境变量
执行命令:
vi  /etc/profile

在文件末尾添加:
# Environment Variable
export JAVA_HOME=/usr/local/java/jdk1.8.0_241
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

如果出现类似错误

-bash: /usr/local/jdk1.8.0_144/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录

  • 可能是版本下载错误,你的系统可能是64位,结果你下载安装了一个32位的JDK
  • 可以通过执行命令:sudo yum install glibc.i686 来解决;或者重新下载一个正确版本的JDK重新解压安装。

二、安装Tomcat8.5

  • 切换目录
cd  /usr/local
  • 下载tomcat压缩包,并上传到该目录
tomcat 8.5下载地址:https://pan.baidu.com/s/1O11OT4iprZn2DPJVl5z6Rw
提取码:fwe7
  • 解压tomcat压缩包
tar -zxvf  apache-tomcat-8.5.53.tar.gz
  • 修改文件夹名称
mv apache-tomcat-8.5.53 tomcat
  • 启动tomcat
[root@tony webapps]# cd /usr/local/tomcat/bin
[root@tony bin]# ./startup.sh

三、安装Nginx

  • 安装准备
yum install gcc-c++  
 yum install pcre pcre-devel  
 yum install zlib zlib-devel  
 yum install openssl openssl--devel
  • 安装Nginx
安装之前,最好检查一下是否已经安装有nginx
find -name nginx  
如果系统已经安装了nginx,那么就先卸载
yum remove nginx  
然后开始安装
首先进入/usr/local目录cd /usr/local 
从官网下载最新版的nginx
wget -c https://nginx.org/download/nginx-1.12.1.tar.gz
  • 解压nginx压缩包
tar -zxvf nginx-1.12.1.tar.gz
  • 进入目录(最好不要改目录名字)
cd  nginx-1.12.1
  • 安装nginx
// 使用默认配置
./configure

make
make install
  • 顺利完成后,检查安装目录
whereis nginx
  • 启动和停止nginx
cd /usr/local/nginx/sbin/
./nginx 
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -s quit: 此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop: 此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
  • 查询nginx进程
ps aux | grep nginx
  • 先停止再启动(推荐):对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit
./nginx
  • 当 nginx 的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用 -s reload 不用先停止 nginx 再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload
  • 开机自启动
vi /etc/rc.local

追加一行
/usr/local/nginx/sbin/nginx

四、安装Redis

  • 切换目录
cd /usr/local
  • 下载redis压缩包
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
  • 使用默认配置
[root@tony utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful!

五、安装MQ

六、安装MongoDB

七、Yum的方式安装Mysql

1、下载并安装MySQL官方的Yum Repository
下载:
    wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
安装:
    yum -y install mysql57-community-release-el7-10.noarch.rpm
2、安装MySQL服务器
yum -y install mysql-community-server
3、MySQL数据库设置
  • 启动MySQL
systemctl start  mysqld.service
  • 查看MySQL运行状态
systemctl status mysqld.service
4、此时mysql已经启动,查看默认的登录密码
[root@tony local]# grep "password" /var/log/mysqld.log
    ... ...[Note] A temporary password is generated for root@localhost: 4eg9;hOCYb+8
    
其中冒号后边的 4eg9;hOCYb+8 就是默认密码
5、登录mysql
[root@tony local]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.7.29

    Copyright (c) 2000, 2020, 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>
6、输入初始密码,此时不能做任何事情,因为MYSQL默认必须修改密码才能正常使用
  • 注意事项:密码必须足够复杂,最好是大小写+特殊符号+数字。设置的密码过于简单的话,会提示报错
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'tony123';
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ABCdef_123456';
    Query OK, 0 rows affected (0.00 sec)
7、还有一个问题就是Yum Repository,以后每次 yum 操作都会自动更新,需要把这个卸载掉
[root@tony local]# yum -y remove mysql57-community-release-el7-10.noarch
8、远程登录mysql提示报错
报错信息及原因
错误信息:
    ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xxx.xxx.xxx.xxx’
错误原因:
    没有授予相应的权限
问题解决
  • 先进行登录
[root@tony local]# mysql -uroot -p
Enter password:
  • 登录后
#任何主机
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

#指定主机
GRANT ALL PRIVILEGES ON *.* TO 'jack'@’11.11.11.123’ IDENTIFIED BY '123456' WITH GRANT OPTION;

#根据自己的需求选择使用上述哪个命令
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'ABCdef_123456' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.00 sec)

# 然后刷新权限
mysql> flush privileges;
    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> exit;
    Bye
[root@tony local]#
9、修改mysql中user表,是相应的用户能从任意主机登录
mysql>use mysql; 
mysql>update user set host = '%' where user = 'root';   # %代表任意客户端,可换成具体IP地址
mysql>select host, user from user;
10、客户端提供MYSQL的环境不支持中文,进行修改
登录后查看mysql的字符集
mysql> show variables like 'character_set%';
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | utf8                        |
    | character_set_connection | utf8                   |
    | character_set_database   | latin1                   |
    | character_set_filesystem | binary                |
    | character_set_results    | utf8                    |
    | character_set_server     | latin1                     |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.01 sec)
mysql> exit;
    Bye
修改字符集
  • 系统变量及含义:
– character_set_server:默认的内部操作字符集
    – character_set_client:客户端来源数据使用的字符集
    – character_set_connection:连接层字符集
    – character_set_results:查询结果字符集
    – character_set_database:当前选中数据库的默认字符集
    – character_set_system:系统元数据(字段名等)字符集
  • Linux下MySQL配置文件my.cnf
[mysql]
    #在该区域设置默认字符集(default-character-set=utf8),
    #那么这三个character_set_client,character_set_connection,character_set_results,全部生效
    default-character-set=utf8

[mysqld]
    #在该区域设置默认字符集(default-character-set=utf8),
    #那么character_set_server,character_set_database两个全部生效,并且这俩个参数只有在该节中可以设置,其他地方设置会报错
    default-character-set=utf8

[client]
    #在该区域设置默认字符集(default-character-set=utf8),
    #那么这个三个character_set_client,character_set_connection,character_set_results,全部生效
    #如果在[mysql]和[client]节中都设置了默认字符集,那么以[client]为准
    default-character-set=utf8

推荐设置:
    [mysql]
        default-character-set=utf8
    [mysqld]
        default-character-set=utf8
  • 修改自己服务器上的my.cnf配置文件
[root@tony ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8                                 # 追加该行
[root@tony ~]#
重启mysql
[root@tony local]# service mysqld restart
    Redirecting to /bin/systemctl restart  mysqld.service

# 登录后再次查看字符集
mysql> show variables like 'character_set%';
    +--------------------------+----------------------------+
    | Variable_name                | Value                      |
    +--------------------------+----------------------------+
    | character_set_client         | utf8                       |
    | character_set_connection     | utf8                       |
    | character_set_database       | utf8                       |
    | character_set_filesystem     | binary                     |
    | character_set_results        | utf8                       |
    | character_set_server         | utf8                       |
    | character_set_system         | utf8                       |
    | character_sets_dir           | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)
11、设置开机启动
# 开机启动
[root@tony local]# systemctl enable mysqld

# 取消开机启动
[root@tony local]# systemctl disable mysqld

------ 感谢您的阅读 ------
如果您认为文章对您有所帮助的话,劳烦您动动您可爱的小手点个赞,您的认同是我创作最大的动力!