Xshell安装,安装免费版的Xshell和XFTP
Xshell新建连接
新建连接后的窗口可能没有标签页,直接ctrl+shift+t调出来:
安装MySQL:
在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB。
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
1 下载并安装MySQL官方的 Yum Repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装:
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
之后就开始安装MySQL服务器:
[root@localhost ~]# yum -y install mysql-community-server
这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。
至此MySQL就安装完成了,然后是对MySQL的一些设置。
2 MySQL数据库设置
首先启动MySQL:
[root@localhost ~]# systemctl start mysqld.service
查看MySQL运行状态,运行状态如图:
[root@localhost ~]# systemctl status mysqld.service
此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的默认密码,通过如下命令可以在日志文件中找出密码:
[root@localhost ~]# grep "password" /var/log/mysqld.log
如下命令进入数据库:
[root@localhost ~]# mysql -uroot -p
输入默认初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新设置一个密码';
数据库中的语句一定要结尾加分号;
注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功。
3 开启mysql的远程访问
执行以下命令开启远程访问限制(开启所有IP,用%代替IP):
grant all privileges on *.* to 'root'@'%' identified by '新设置的密码' with grant option;
如果要开启特定IP,在%位置用具体IP代替。一定要开启权限,否则远程navicat无法访问。
然后再输入下面两行命令刷新权限退出:
mysql> flush privileges;
mysql> exit
4 sql模式更改
vim /etc/my.cnf
在[mysqld]
下方添加:
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Nginx安装配置
1 安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
官网下载
1.直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
2.使用wget命令下载(推荐)
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
1.10.1版本,目前比较稳定。
解压
依然是直接命令:
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1
配置
其实在 nginx-1.10.1 版本中你就不需要去配置相关东西,默认就可以了。当然,如果你要自己配置目录也是可以的。
1.使用默认配置
./configure
2.自定义配置(不推荐)
./configure \
--prefix=/service/common/nginx \
--conf-path=/service/common/nginx/conf/nginx.conf \
--pid-path=/service/common/nginx/conf/nginx.pid \
--lock-path=/service/common/nginx/lock/nginx.lock \
--error-log-path=/service/common/nginx/error.log \
--http-log-path=/service/common/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/service/common/nginx/client \
--http-proxy-temp-path=/service/common/nginx/proxy \
--http-fastcgi-temp-path=/service/common/nginx/fastcgi \
--http-uwsgi-temp-path=/service/common/nginx/uwsgi \
--http-scgi-temp-path=/service/common/nginx/scgi --with-http_ssl_module
mkdir -p /var/temp/nginx/
./configure \
--prefix=/service/common/nginx \
--conf-path=/service/common/nginx/conf/nginx.conf \
--pid-path=/service/common/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi --with-http_ssl_module
注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
编译安装
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
1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
./nginx -s quit
./nginx
2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:
./nginx -s reload
安装redis
第一步:下载redis安装包
在/usr/local
路径下,其他习惯的记得住的都行。
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
wget http://download.redis.io/releases/redis-6.2.6.tar.gz
正常情况会显示:
[root@iZwz991stxdwj560bfmadtZ local]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz
--2017-12-13 12:35:12-- http://download.redis.io/releases/redis-4.0.6.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1723533 (1.6M) [application/x-gzip]
Saving to: ‘redis-4.0.6.tar.gz’
100%[==========================================================================================================>] 1,723,533 608KB/s in 2.8s
2017-12-13 12:35:15 (608 KB/s) - ‘redis-4.0.6.tar.gz’ saved [1723533/1723533]
第二步:解压压缩包
tar -zxvf redis-4.0.6.tar.gz
Xshell解压命令tar -zxvf xxx.tar.gz
一定要记住。
正常情况会显示:
[root@iZwz991stxdwj560bfmadtZ local]# tar -zxvf redis-4.0.6.tar.gz
第三步:yum安装gcc依赖
安装gcc编译环境,如果已经安装过了就会提示nothing to do。如果已经安装就无需再安装
yum install gcc-c++
遇到选择,输入y即可
第四步:跳转到redis解压目录下
cd redis-4.0.6
第五步:编译安装
make MALLOC=libc
将/usr/local/redis-4.0.6/src目录下的文件加到/usr/local/bin目录
cd src && make install
安装成功会显示一列INSTALL install
[root@iZwz991stxdwj560bfmadtZ redis-4.0.6]# cd src && make install
CC Makefile.dep
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
第六步:启动redis的三种方式
先切换到redis src目录下
[root@iZwz991stxdwj560bfmadtZ redis-4.0.6]# cd src
1、直接启动redis
./redis-server
启动成功会如下:
[root@iZwz991stxdwj560bfmadtZ src]# ./redis-server
18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18685, just started
18685:C 13 Dec 12:56:12.507 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.6 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 18685
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18685:M 13 Dec 12:56:12.508 # Server initialized
18685:M 13 Dec 12:56:12.508 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
18685:M 13 Dec 12:56:12.508 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
18685:M 13 Dec 12:56:12.508 * Ready to accept connections
但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。
要关闭直接一直ctrl + c
2、以后台进程方式启动redis
第一步:修改redis.conf文件
vim redis.conf
vim 相比 vi 命令对文本有上色,方便查看。
将
daemonize no
修改为
daemonize yes
如果在redis.conf文件里难找,直接/daemonize搜索定位,然后按i
进入编辑模式,修改完成按ESC
,然后输入:wq
保存退出。命令:q!
是不保存退出。
第二步:指定redis.conf文件启动
[root@iZwz991stxdwj560bfmadtZ src]# ./redis-server /usr/local/redis-4.0.6/redis.conf
./redis-server ../redis.conf
18713:C 13 Dec 13:07:41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18713:C 13 Dec 13:07:41.109 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18713, just started
18713:C 13 Dec 13:07:41.109 # Configuration loaded
第三步:关闭redis进程
首先使用ps -aux | grep redis查看redis进程
[root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
root 18714 0.0 0.1 141752 2008 ? Ssl 13:07 0:00 ./redis-server 127.0.0.1:6379
root 18719 0.0 0.0 112644 968 pts/0 R+ 13:09 0:00 grep --color=auto redis
使用kill命令杀死进程
[root@iZwz991stxdwj560bfmadtZ src]# kill 18714
3、设置redis开机自启动(可自行选择)
1、在/etc目录下新建redis目录
mkdir redis
2、将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis目录下,并命名为xxx.conf
[root@iZwz991stxdwj560bfmadtZ redis]# cp /usr/local/redis-4.0.6/redis.conf /etc/redis/6379.conf
3、将redis的启动脚本复制一份放到/etc/init.d目录下
[root@iZwz991stxdwj560bfmadtZ init.d]# cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd
4、设置redis开机自启动
先切换到/etc/init.d目录下
然后执行自启命令
[root@iZwz991stxdwj560bfmadtZ init.d]# chkconfig redisd on
service redisd does not support chkconfig
看结果是redisd不支持chkconfig
解决方法:
使用vim编辑redisd文件,在第一行加入如下两行注释,保存退出
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
注释的意思是,redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10
后台运行redis命令:
./redis-server /usr/local/redis/redis.conf &
安装JDK
按照习惯在/service
下新建一个common
文件夹,JDK和Nginx安装在这。
yum install java-1.8.0-openjdk-devel.x86_64
遇到选择选y
判断是否安装成功:
java -version
navacat
使用navicat客户端连接虚拟机数据库
1. 打开navicat客户端,编辑SSH
注意这里的用户名密码是Xshell中的用户名和密码。
2. 编辑常规
注意这里的用户名和密码是数据库的,就是MySQL新设置的密码。
redis desktop manager–redis工具(缓存)
redis desktop manager网盘下载 提取码:v727
1.进入RedisDesktopManager的主界面
2.新建连接(Name:给该连接起一个名字,Host:redis服务器的ip地址,Port:redis服务器的端口号,Auth:密码字段,如果redis服务器设置了密码验证,则需要填写,实际使用好像没密码连接不上)
该工具支持根据筛选条件查询add new key,key,reload等
支持常用redis操作;如针对目标key执行rename,delete,addrow,reload value操作。
支持命令控制台操作
redis最常用的几个命令,如增删改查。
查看key的类型和数据库中key的数量以及服务器的信息
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m0_55070913/article/details/123677891
Xshell Redis设置密码
vim /usr/local/redis/etc/redis.conf
然后/requirepass
找到单独的密码一行,进行修改。
Xshell Redis修改监听IP
默认只监听本地IP127.0.0.1,所以要修改redis.conf中的bind IP
同样
vim /usr/local/redis/etc/redis.conf
然后/bind
找到bind 127.0.0.0 -::1
,将其改为
bind 0.0.0.0 -::1
就可以实现监听所有端口