运维随笔

笔记


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

VMware共享文件夹设置方法

发表于 2018-08-27 | 更新于: 2022-06-05 | 分类于 Linux
字数统计: 178 | 阅读时长 ≈ 1

一、安装包依赖:

1
2
$ yum -y install kernel-devel-$(uname -r) 
$ yum -y install net-tools perl gcc gcc-c++

二、安装vmtool

1
2
3
4
5
6
$ mount /dev/cdrom /home/tmp
$ cp /home/tmp/VMwareTools-9.6.0-1294478.tar.gz /tmp
$ cd /tmp
$ tar -zxvf VMwareTools-9.6.0-1294478.tar.gz
$ cd vmware-tools-distrib
$ ./vmware-install.pl

按提示操作即可。

三、问题

有/mnt/hgfs但没有共享文件的解决方法:

1
2
$ mount -t vmhgfs .host:/  /mnt/hgfs
Error: cannot mount filesystem: No such device

这时不能用mount工具挂载,而是得用vmhgfs-fuse,需要安装工具包

1
2
3
$ yum install open-vm-tools-devel -y
有的源的名字并不一定为open-vm-tools-devel(centos) ,而是open-vm-dkms(unbuntu)
执行:vmhgfs-fuse .host:/ /mnt/hgfs

此时进入/mnt/hgfs就能看到你设置的共享文件夹了。

SSL证书制作

发表于 2018-08-27 | 更新于: 2022-06-05 | 分类于 Linux
字数统计: 116 | 阅读时长 ≈ 1

一、环境

OS:centos 7.3

二、步骤

1、安装openssl

1
$ yum install opensll

2、制作CA证书

1
2
$ openssl genrsa -des3 -out my-ca.key 2048
$ openssl req -new -x509 -days 3650 -key my-ca.key -out my-ca.crt

3、生成服务器证书

1
2
3
$ openssl genrsa -des3 -out mars-server.key 1024
$ openssl req -new -key mars-server.key -out mars-server.csr
$ openssl x509 -req -in mars-server.csr -out mars-server.crt -sha1 -CA my-ca.crt -CAkey my-ca.key -CAcreateserial -days 3650

4、生成无密码密钥

1
$ openssl rsa -in mars-server.key -out mars-server.key.insecure

proxy_pass反向代理配置中url后面加不加/的说明

发表于 2018-08-23 | 更新于: 2022-06-05 | 分类于 Linux
字数统计: 1.1k | 阅读时长 ≈ 5

1 环境

OS:centos7

nginx _proxy服务器:192.168.1.23

web服务器:192.168.1.5

2 情况说明

2.1 path路径后面加”/”

2.1.1 情况一

NGINX配置

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy/ {
proxy_pass http://192.168.1.5:8090/;
}
}

这样,访问http://192.168.1.23/proxy/就会被代理到http://192.168.1.5:8090/。匹配的proxy目录不需要存在根目录/var/www/html里面

注意,终端里如果访问http://192.168.1.23/proxy(即后面不带”/”),则会访问失败!因为proxy_pass配置的url后面加了”/”

访问结果如下

1
2
3
4
5
6
7
8
9
10
[root@localhost conf.d]# curl http://192.168.1.23/proxy/
this is 192.168.1.5
[root@localhost conf.d]# curl http://192.168.1.23/proxy
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.3</center>
</body>
</html>

页面访问http://103.110.186.23/proxy的时候,会自动加上”/”(同理是由于proxy_pass配置的url后面加了”/”),并反代到http://103.110.186.5:8090的结果。
图1

2.1.2 情况二

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy/ {
proxy_pass http://192.168.1.5:8090;
}
}

[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
## 那么访问http://192.168.1.23/proxy或http://192.168.1.23/proxy/,都会失败!
## 这样配置后,访问http://192.168.1.23/proxy/就会被反向代理到http://192.168.1.5:8090/proxy/

图2

2.1.3 情况三

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy/ {
proxy_pass http://192.168.1.5:8090/haha/;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@localhost conf.d]# curl http://192.168.1.23/proxy/
192.168.1.5 haha-index.html

这样配置的话,访问http://103.110.186.23/proxy代理到http://192.168.1.5:8090/haha/
图3

2.1.4 情况四

相对于第三种配置的url不加”/”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy/ {
proxy_pass http://192.168.1.5:8090/haha;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@localhost conf.d]# curl http://192.168.1.23/proxy/index.html
192.168.1.5 hahaindex.html

#####################################
上面配置后,访问http://192.168.1.23/proxy/index.html就会被代理到http://192.168.1.5:8090/hahaindex.html
同理,访问http://192.168.1.23/proxy/test.html就会被代理到http://192.168.1.5:8090/hahatest.html
[root@localhost conf.d]# curl http://192.168.1.23/proxy/index.html
192.168.1.5 hahaindex.html

注意,这种情况下,不能直接访问http://192.168.1.23/proxy/,后面就算是默认的index.html文件也要跟上,否则访问失败!
图4

———————————————————————————————————————————
上面四种方式都是匹配的path路径后面加”/”,下面说下path路径后面不带”/”的情况:

2.2 path路径后面不加”/”

2.2.1 情况一

proxy_pass后面url带”/”:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy {
proxy_pass http://192.168.1.5:8090/;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service

图5

2.2.2 情况二,

proxy_pass后面url不带”/”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy {
proxy_pass http://192.168.1.5:8090;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@localhost conf.d]#

这样配置的话,访问http://103.110.186.23/proxy会自动加上”/”(即变成http://103.110.186.23/proxy/),代理到192.168.1.5:8090/proxy/
图7

2.2.3 情况三

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy {
proxy_pass http://192.168.1.5:8090/haha/;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service

这样配置的话,访问http://103.110.186.23/proxy会自动加上”/”(即变成http://103.110.186.23/proxy/),代理到http://192.168.1.5:8090/haha/
图8

2.2.4 情况四

相对于第三种配置的url不加”/”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
}

location /proxy {
proxy_pass http://192.168.1.5:8090/haha;
}
}
[root@localhost conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service

这样配置的话,访问http://103.110.186.23/proxy,和第三种结果一样,同样被代理到http://192.168.1.5:8090/haha/
图9

Xmanager远程连接CentOS7

发表于 2018-08-23 | 更新于: 2022-06-04 | 分类于 Linux
字数统计: 223 | 阅读时长 ≈ 1

1 安装epel源

1
yum install -y epel-release

2 安装lightdm和xfce

1
2
yum install -y lightdm 
yum groupinstall -y xfce

2.1 修改配置文件

1
vim /etc/lightdm/lightdm.conf

内容如下

1
2
3
[XDMCPServer]
enabled=true
port=177

2.2 将Display Manager切换为lightdm

1
systemctl disable gdm && systemctl enable lightdm

2.3 启动lightdm

1
systemctl start lightdm

2.4 关闭防火墙

1
systemctl stop firewalld.service

3 登录

打开Xmanger客户端,选择XDMCP并输入服务器的ip,回车运行即可。
输入账号密码
然后就出现下图:(如果正常跳过这步)
enter description here
或者出现黑屏提示无法建立连接
这是因为刚开始安装的是Gnome,所以系统默认使用它,现在要改成Xfce,最简单的方法就是把xfce.desktopz之外的文件都干掉。

1
2
3
4
cd /usr/share/xsessions/
mkdir bak
mv gnome* bak
systemctl restart lightdm

重新连接
一切正常操作之后就成功连接了。然后就可以快速便捷的工作了。

编辑rc.local启动命令执行不成功处理

发表于 2018-08-23 | 更新于: 2022-06-05 | 分类于 Linux
字数统计: 284 | 阅读时长 ≈ 1

1 问题举例:

rc.local内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
mount -t cifs -o username=backup,password=xxxxxxx //192.168.1.170/192.168.1.11/ /mnt/backup_data/
/usr/local/tomcat/bin/startup.sh

挂载命令执行了,但tomcat没有启动

2 问题原因及处理方法

2.1 原因

因java使用的是解压缩版,在/etc/profile内添加java的环境变量,系统启动时先执行的是rc.local,因此tomcat启动失败

2.2 解决办法

2.2.1 方法1

在rc.local内添加java的环境变量命令(必须放在tomcat启动命令前)

1
2
export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export JRE_HOME=/usr/local/java/jdk1.6.0_18/jre

2.2.2 方法2

在tomcat的启动脚本内添加java路径
分别在tomcat_home/bin目录内的catalina.sh ,setclasspath.sh脚本前面指定JAVA_HOME路径

1
2
export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export JRE_HOME=/usr/local/java/jdk1.6.0_18/jre
1…272829…32
OperationMAN

OperationMAN

日常运维文档整理。

157 日志
9 分类
107 标签
E-Mail GitHub 码云 Linux命令大全 鸟哥的私房菜 RUNOOB.com 陈沙克日志 Bitnami Font Awesome
友情链接
  • Next优化
  • Next深度优化
© 2023 OperationMAN | 豫ICP备 17032296 号