解决Centos7系统yum命令用不了问题

   MacOS安装了虚拟机,在设置静态IP时出现了yum命令用不了,原路退回时,还是用不了;屋漏偏防连夜雨,蛋疼的时,连wget命令也用不了。一趟折腾,终于解决,现在把解决方案记录如下,望日后遇到类似问题兄弟少走弯路。

一.解决wget命令问题
由于yum命令用不了,只能采用rpm方式安装软件,官网上冒似是源码包,不想走编译的路线。
到网易镜像源(地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/)下载Centos7对应的eI7版本吧。
我安装的是下面这个版本wget-1.14-18.el7_6.1.x86_64.rpm
下载地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
下载完成后,把它拖到服务器上任意能有权限执行的地方即可。比如,我放到/root/根用户目录下
然后执行下面命令:
cd /root
rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm

二.解决yum问题
1.先卸载原有的yum
rpm -qa | grep yum | xargs rpm -e –nodeps
再确认下有没有原安装包,没有列表返回,即说明已经卸载干净
rpm -qa | grep yum

2.到网易镜像源http://mirrors.163.com下载下面4个包
RPM-GPG-KEY-EPEL-7 ##在http://mirrors.163.com/centos/7/os/x86_64/下面

下面4个包在http://mirrors.163.com/centos/7/os/x86_64/Packages/下面

python-iniparse-0.4-9.el7.noarch.rpm
yum-3.4.3-163.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

如果使用wget下载,就使用wget下载,下载不了,就下接用浏览器下载,下载完成后再上传到服务器(二选一,视实际情况而定)。

服务器上操作通过wget下载命令如下:

wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/RPM-GPG-KEY-CentOS-7
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

通过浏览器下载地址如下:

http://mirrors.163.com/centos/7.7.1908/os/x86_64/RPM-GPG-KEY-CentOS-7
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

3.执行安装命令
chmod u+x ./*.rpm
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm yum-3.4.3-163.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm

4.重新清理下
yum clean all
yum makecache
yum update -y

MacOS系统虚拟机VMware Fusion中NAT模式并配置静态IP方法

MacOS系统虚拟机VMware Fusion默认是NAT模式dhcp动态分配IP,IP经常变来变去,特别不方便做测试。下面介绍下如何配置静态IP。
1.首先在VMware Fusion自定义网络
VMware Fusion>偏好设置>网络>➕>☑️允许该网络上的虚拟机连接到外部网络(NAT)》手动配置子网ip,如:192.168.250.0
子网掩码不变255.255.255.0
点“应用”后,就会多出一个 vmnet2的网络。
如下图所示:


2.MacOS主机上检查vnet配置
执行查看命令:
cat /Library/Preferences/VMware\ Fusion/networking
你会看到,除了VNET1和VNET8之外,中间多了一系列VNET_2配置
如下图所示:

3.MacOS主机上检查vnet2的nat配置
执行查看命令:
vim /Library/Preferences/VMware\ Fusion/vmnet2/nat.conf
你会看到vmnet2的网关和mask
如下图所示:

4.在VMware Fusion修改虚拟机网络配置
虚拟机–>网络适配器–>网络适配器设置–>vmnet2 ⊙
勾选vmnet2,如下图所示:


5.进入虚拟机,修改虚拟机的网卡配置文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
增加或修改如下几个参数
BOOTPROTO=static # 修改本行,默认值为dhcp,改为static
ONBOOT=yes # 修改本行,默认值为no,改为yes
IPADDR=192.168.250.132 # 新增本行
NETMASK=255.255.255.0 # 新增本行
GATEWAY=192.168.250.2 # 新增本行,这是前面vnet2的gateway ip
DNS1=8.8.8.8
DNS2=114.114.114.114 # 新增本行
最终结果如下图所示:


6.重启虚拟机网卡或重启虚机

重启网卡(推荐)

systemctl restart network

重启虚拟机(没必要)

reboot

7.验证
在linux虚拟机:ping 192.168.0.100 #MacOS主机ip
在linux虚拟机:ping baidu.com
在MacOS主机:ping 192.168.250.132 #我们为刚才的虚拟机配置的静态IP
如下图所示:

到此就完成了VMware Fusion虚拟机NAT模式配置静态IP了。

Centos7上搭建docker私有仓库

前置:本人安装docker私有仓库的服务器IP地址为192.168.250.139 解决证书安全注册时用到该IP,所以同学们自己确认好自己服务器的IP地址,不要照搬。

1.从官网仓库拉取registry镜像
docker pull registry:latest #注意:这里我拉取的最新版本,如果生产环境,建议使用稳定版本

2.启动私有仓库容器
docker run -e REGISTRY_STORAGE_DELETE = true \
-itd -p 5000:5000 –name = registry \
-v /opt/data/registry:/var/lib/registry \
registry:latest

注意:

-e REGISTRY_STORAGE_DELETE = true 是用来启用docker仓库删除权限

在这里插入图片描述

3.解判局域网docker私有仓库SSL证书问题
由于局域网没有必要设置ssl证书,但官网新版本的又几须要证书才能正常运行,因此需要手工设置/etc/docker/daemon.json文件,在该文件中添加insecure-registry参数

执行命令: vim /etc/docker/daemon.json
{“insecure-registry”:[“192.168.250.139:5000”]}

注意:上面的IP是服务器的IP地址

然后重启docker服务使其生效
systemctl restart docker

4.验证测试
验证最效的方法创建自己的镜像,把镜像push到私有仓库上,然后在本机或别的服务器拉取刚才的镜像
现在从官网上拉取nginx镜像测试,同学们可以使用其它镜像,没有限制
docker pull nginx
docker tag docker.io/nginx 192.168.250.139:5000/nginx
docker push 192.168.250.139:5000/nginx

注意:上面的IP地址要更换成自己服务器的IP地址

在这里插入图片描述

下面查看下挂载目录下有没有推上来的镜像
ls /opt/data/registry/docker/registry/v2/repositories

5.在本机或别的服务器拉取刚才镜像
docker pull 192.168.250.139:5000/nginx

域名检测

博客资料:

https://www.imtqy.com/domain-gfw.html

https://blog.csdn.net/moxun2011/article/details/90258340

检测工具:

https://www.checkgfw.com/

https://00738.com/

http://www.009.com/gfw/

http://www.009.com/polluted/

http://www.620138.com/

https://www.11cm.com/

https://www.ymbq.com/

https://www.toolnb.com/beiqiang/p58.com.html

http://www.gjw123.com/beiqiang/p58.com.html

https://www.xz.com/domainTool/batchSearch

http://api.uomg.com/doc-ck_qiang.html

git clone非标准ssh端口(非22端口)处理方法

公司在内网搭建了gitLab服务器,同时使用了FRP将公司的这个内网服务器映射出去,能够让部分的外网用户可以访问到,但是在设置外网ssh登陆服务器的时候,限制了端口为10022

公司在内网搭建了gitLab服务器,同时使用了FRP将公司的这个内网服务器映射出去,能够让部分的外网用户可以访问到,但是在设置外网ssh登陆服务器的时候,限制了端口为10022
当我使用git clone git@xxx:10022:develop/xxx.git 发现不能实现代码的clone
原来,当ssh的端口访问改变的时候,原来的方式就不行了,就要使用新的方式
git clone ssh://git@hostname:port/…/xxx.git

hostname:可以是主机的IP地址也可以是域名,域名会自动通过DNS进行解析
port:端口号
样例如下所示:
git clone ssh://git@hostname:10022/develop/test.git

Git命令使用说明

一、git切换分支

一、git切换分支
1、本地没有对应的远程分支

git fetch origin

git checkout -t origin/远程分支名称

#切换分支

git checkout  分支名称

2、本地有对应的远程分支

git checkout  分支名称

二、git删除本地分支及远程分支

1、删除本地分支

#查看本地分支

git branch

#删除本地分支

git branch -d 分支名称

2、删除远程分支

#查看远程分支列表

git branch -a

#删除远程分支

git push origin –delete 远程分支名称

三、git撤销本地修改与回退版本

1. 使用 git checkout 撤销本地修改;即放弃对本地已修改但尚未提交的文件的修改,还原其到未修改前的状态

注意: 已 add/ commit 的文件不适用个方法,应该用本文提到的第二种方法。

命令如下:

git checkout .      # 撤销对所有已修改但未提交的文件的修改,但不包括新增的文件

git checkout [filename]     # 撤销对指定文件的修改,[filename]为文件名

2. 使用 git reset 回退项目版本;可以回退到任意已经提交过的版本。已 add / commit 但未 push 的文件也适用

命令如下:

git log #查看commit 的哈希值

git reset –hard [commit-hashcode]

# [commit-hashcode]是某个 commit 的哈希值,可以用 git log 查看;因此一般用法是先用 git log 查看具体commit的哈希值,然后 reset 到那个版本

四、创建分支

git checkout -b 分支名称

git branch  分支名称

Sc create官方使用文档

Applies To: Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012, Windows Server 2003 with SP1, Windows 8

Applies To: Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012, Windows Server 2003 with SP1, Windows 8

Creates a subkey and entries for a service in the registry and in the Service Control Manager database.

For examples of how to use this command, see Examples.

Syntax

sc [<ServerName>] create [<ServiceName>] [type= {own | share | kernel | filesys | rec | interact type= {own | share}}] [start= {boot | system | auto | demand | disabled}] [error= {normal | severe | critical | ignore}] [binpath= <BinaryPathName>] [group= <LoadOrderGroup>] [tag= {yes | no}] [depend= <dependencies>] [obj= {<AccountName> | <ObjectName>}] [displayname= <DisplayName>] [password= <Password>]

Parameters

Parameter
Description
<ServerName>
Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format (for example, \\myserver). To run SC.exe locally, omit this parameter.
<ServiceName>
Specifies the service name returned by the getkeyname operation.
type= {own | share | kernel | filesys | rec | interact type= {own | share}}
Specifies the service type. The default setting is type= own.
own – Specifies that the service runs in its own process. It does not share an executable file with other services. This is the default setting.
share – Specifies that the service runs as a shared process. It shares an executable file with other services.
kernel – Specifies a driver.
filesys – Specifies a file system driver.
rec – Specifies a file system recognized driver (identifies file systems used on the computer).
interact – Specifies that the service can interact with the desktop, receiving input from users. Interactive services must be run under the LocalSystem account. This type must be used in conjunction with type= own or type= shared. Using type= interact by itself will generate an “invalid parameter” error.
start= {boot | system | auto | demand | disabled}
Specifies the start type for the service. The default setting is start= demand.
boot – Specifies a device driver that is loaded by the boot loader.
system – Specifies a device driver that is started during kernel initialization.
auto – Specifies a service that automatically starts each time the computer is restarted. Note that the service runs even if no one logs on to the computer.
demand – Specifies a service that must be started manually. This is the default value if start= is not specified.
disabled – Specifies a service that cannot be started. To start a disabled service, change the start type to some other value.
error= {normal | severe | critical | ignore}
Specifies the severity of the error if the service fails when the computer is started. The default setting is error= normal.
normal – Specifies that the error is logged. A message box is displayed, informing the user that a service has failed to start. Startup will continue. This is the default setting.
severe – Specifies that the error is logged (if possible). The computer attempts to restart with the last-known good configuration. This could result in the computer being able to restart, but the service may still be unable to run.
critical – Specifies that the error is logged (if possible). The computer attempts to restart with the last-known good configuration. If the last-known good configuration fails, startup also fails, and the boot process halts with a Stop error.
ignore – Specifies that the error is logged and startup continues. No notification is given to the user beyond recording the error in the event log.
binpath= <BinaryPathName>
Specifies a path to the service binary file. There is no default for binpath=, and this string must be supplied.
group= <LoadOrderGroup>
Specifies the name of the group of which this service is a member. The list of groups is stored in the registry in theHKLM\System\CurrentControlSet\Control\ServiceGroupOrder subkey. The default value is null.
tag= {yes | no}
Specifies whether or not a TagID is to be obtained from the CreateService call. Tags are used only for boot-start and system-start drivers.
depend= <dependencies>
Specifies the names of services or groups that must start before this service starts. The names are separated by forward slashes (/).
obj= {<AccountName> | <ObjectName>}
Specifies the name of an account in which a service will run, or specifies a name of the Windows driver object in which the driver will run.
displayname= <DisplayName>
Specifies a friendly name that can be used by user interface programs to identify the service.
password= <Password>
Specifies a password. This is required if an account other than LocalSystem is used.
/?
Displays help at the command prompt.

Remarks

  • For each command-line option, the equal sign is part of the option name.
  • A space is required between an option and its value (for example, type= own. If the space is omitted the operation will fail.

Examples

The following examples show how you can use the sc create command:

sc \\myserver create NewService binpath= c:\windows\system32\NewServ.exe

sc create NewService binpath= c:\windows\system32\NewServ.exe type= share start= auto depend= “+TDI NetBIOS”

Additional references

Command-Line Syntax Key

Centos7上安装部署frp内网穿透工具

一、安装

一、安装

1、源码地址

https://github.com/fatedier/frp

2、中文文档

https://github.com/fatedier/frp/blob/master/README_zh.md

3、安装部署

#所有发布版本下载地址

https://github.com/fatedier/frp/releases

#安装命令(服务端和客户端都执行)

wget https://github.com/fatedier/frp/releases/download/v0.29.0/frp_0.29.0_linux_amd64.tar.gz

tar -xvf frp_0.29.0_linux_amd64.tar.gz -C /usr/local/

cd /usr/local/

mv frp_0.29.0_linux_amd64 frp

cd frp

#在服务端删除frpc和frpc.ini两个文件

rm -f frpc frpc.ini

#在服务端删除frps和frps.ini两个文件

rm -f frps frps.ini

二、配置文件

1、客户端修改frps.ini文件

#添加内容如下所示

[common]

bind_addr = 0.0.0.0

bind_port = 10000

bind_udp_port = 10001

vhost_http_port = 10003

vhost_https_port = 443

#kcp_bind_port = 10000

token = Abc#123&2wsx  #和客户端token一致辞

authentication_timeout = 900

max_pool_count = 20

##日志记录

log_file = /var/log/frps.log

log_level = info

log_max_days = 3

##端口白名单

allow_ports = 10001,10048,10058,10076,10078,11110,11222,11112,11122,11123

##dashboard滥测面板

dashboard_port = 10002

dashboard_user = admin

dashboard_pwd = admin#123@zbc

2、客户端修改frpc.ini文件

#添加内容如下所示

[common]

#server_addr = 101.65.43.134

server_addr = asdf.test.com   #此域名解释到服务端

server_port = 10000

#protocol = kcp

##指定需要使用的协议类型,默认类型为 TCP

tls_enable = true

token = Abc#123&2wsx  #和服务端token一致辞

pool_count = 1

##日志记录

log_file = /var/log/frpc.log

log_level = info

log_max_days = 3

##配置客户端热加载

admin_addr = 127.0.0.1

admin_port = 7400

admin_user = admin

admin_pwd = admin

##织语客户端外网连接

[range:ccwork_tcp]

type = tcp

local_ip = 192.168.63.140

local_port = 10001,10048,10058,10076,10078,11110,11222,11112,11122,11123

remote_port = 10001,10048,10058,10076,10078,11110,11222,11112,11122,11123

use_encryption = true

use_compression = true

三、设置成systemd服务

1、服务端frps服务

vi /etc/systemd/system/frps.service

#添加内容如下所示

[Unit]

Description=FRP Server Daemon

[Service]

Type=simple

ExecStartPre=-/sbin/setcap cap_net_bind_service=+ep /usr/local/frp/frps

ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini

Restart=always

RestartSec=20s

User=nobody

PermissionsStartOnly=true

[Install]

WantedBy=multi-user.target

2、客户端frpc服务

vi /etc/systemd/system/frpc.service

#添加内容如下所示

[Unit]

Description=FRP Client Daemon

[Service]

Type=simple

ExecStartPre=-/sbin/setcap cap_net_bind_service=+ep /usr/local/frp/frpc

ExecStart=/usr/local/frp/frpc -c /usr/local/frp/frpc.ini

Restart=always

RestartSec=20s

User=nobody

PermissionsStartOnly=true

[Install]

WantedBy=multi-user.target

3、管理服务

#服务端

systemctl daemon-reload

systemctl enable frps

systemctl start frps

systemctl restart frps

systemctl stop frps

systemctl status frps

#客户端

systemctl daemon-reload

systemctl enable frpc

systemctl start frpc

systemctl restart frpc

systemctl stop frpc

systemctl status frpc

四、云厂商防火墙开放下列端口

443,10000-10003,10001,10048,10058,10076,10078,11110,11222,11112,11122,11123

五、服务端主机本地开放端口(或者关闭本地防火墙)

443,10000-10003,10001,10048,10058,10076,10078,11110,11222,11112,11122,11123

#执行命令

systemctl start firewalld

systemctl enable firewalld

firewall-cmd –zone=public –add-port=443/tcp –permanent

firewall-cmd –zone=public –add-port=10000-10003/tcp –permanent

firewall-cmd –zone=public –add-port=10048/tcp –permanent

firewall-cmd –zone=public –add-port=10058/tcp –permanent

firewall-cmd –zone=public –add-port=10076/tcp –permanent

firewall-cmd –zone=public –add-port=10078/tcp –permanent

firewall-cmd –zone=public –add-port=11110/tcp –permanent

firewall-cmd –zone=public –add-port=11222/tcp –permanent

firewall-cmd –zone=public –add-port=11112/tcp –permanent

firewall-cmd –zone=public –add-port=11122/tcp –permanent

firewall-cmd –zone=public –add-port=11123/tcp –permanent

firewall-cmd –reload

Centos7上yum升级nginx或安装最新版本nginx

1、查看是否为最新版

1、查看是否为最新版

yum info nginx

2、设置nginx.repo文件

vi /etc/yum.repos.d/修改nginx.repo

#添加内容如下所示

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

3、升级或安装

yum update nginx

# 或

yum install -y nginx

4、若nginx模块版本之间的冲突,例如下列情况,则卸载模块

如果碰到 file /usr/lib64/nginx/modules/ngx_http_geoip_module.so from install of nginx-module-geoip-1:1.16.0-1.el7.ngx.x86_64 conflicts with file from package nginx-mod-http-geoip-1:1.12.2-3.el7.x86_64 这类模块错误。

yum remove nginx-mod*

5、重新安装模块

yum install nginx-module-*

6、重启nginx服务

systemctl restart nginx

若之前是用nginx启动的,先执行

pkill nginx