linux命令随记(一)
linux命令笔记
nginx反向代理mysql
1.服务器安装nginx,并且安装了stream模块
dnf -y install nginx nginx-mod-stream
2.修改nginx的配置文件/etc/nginx/nginx.conf ,和http节点平级,添加如下的配置
stream {
upstream mysql {
hash $remote_addr consistent;
server 192.168.10.5:3306 max_fails=3 fail_timeout=30s; #被代理的数据库地址
}
server {
listen 3306;
proxy_connect_timeout 30s;
proxy_timeout 600s;
proxy_pass mysql;
}
}
3.可以通过 nginx -t 测试配置的正确性
nginx -t
若成功,会有以下提示
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
4.重启nginx
systemctl restart nginx
5.navicat测试连接
mac版CRT工具上传和下载文件
Mac不像Win那样,alt+p就可以上传文件
首先安装如下工具
yum install lrzsz
上传文件
rz
下载文件
sz
nginx启动、停止、重启命令
- 首先利用配置文件启动nginx
nginx -c /etc/nginx/nginx.conf
重启服务
service nginx restart
快速停止或关闭Nginx
nginx -s stop
正常停止或关闭Nginx
nginx -s quit
配置文件修改重装载命令
nginx -s reload
查看端口
netstat -ntlp
杀掉进程,需要知道pid
kill pid
搜索进程
ps -ef | grep 线程名称
查看详细端口
lsof -i :2181 端口号,可以查看端口的详细端口占用情况。