Category Archives: Linux

Nginx Error: nginx: [error] CreateFile() “D:\nginx-1.20.1/logs/nginx.pid” failed (2: The system cannot find the file specified)

background

After modifying the Nginx configuration file Nginx.conf, you want to restart Nginx to make the configuration take effect. CMD enter Nginx installation directory and enter the command:   Nginx -s reload

Error: nginx: [error] createfile() “D: \ nginx-1.20.1/logs/nginx. PID” failed (2: the system cannot find the file specified)

Cause analysis

The direct cause of the problem is that there is no Nginx.pid file in the logs directory under the Nginx installation directory. Generally, the Nginx.pid file will be automatically created when Nginx starts

To start or restart Nginx, you need to kill the original Nginx process. You need to find the original process according to Nginx.PID, where PID is actually the original process ID

The reason for this may be that Nginx is not started or Nginx.PID is manually deleted. Sometimes, when Nginx is started by double-clicking on the Windows system, the Nginx.PID file cannot be automatically generated in the logs directory

If Nginx is not started (and you are not sure whether it is started), do not use Nginx – s reload command as the start command to avoid this error

 

Solution:

1. Find the original nginx process (if any) in Task Manager and close it, then use the cmd command to start nginx

2. cmd into the nginx installation directory

3. Enter the command start nginx or nginx.exe to start nginx

4. Go to the nginx directory under the logs directory and see if there is a nginx.pid file; if not, repeat the 123 operation

5. If nginx.pid has been generated, you can restart normally after modifying the configuration file

6.nginx -s reload

Linux: CentOS 7 executes service network restart error [Solved]

Today, we plan to build a Greenplum cluster environment with VirtualBox virtual machine, and the host agrees to install CentOS 7. As a result, an error is reported by Yum install after CentOS 7, indicating that there is no way to connect to the address of the image library, that is, there is no way to surf the Internet. Then curl www.baidu.com prompts that the target cannot be found. The first thing I think about is the network problem. Let’s take a look at the ifconfig command first. The result prompts an unknown command, which is indeed a minimized installation. First, change the network settings of the virtual machine to bridge to ensure that cable connect is checked, and then go to the/etc/sysconfig/network scripts directory to check the settings of the eth0 network port. As a result, the ifcfg-eth0 file was not found.

First, use the IP address command to check the MAC address (that is, the string after link/ether)

Then VI/Etc/sysconfig/network scripts/ifcfg-eth0 add eth0 network port configuration

Save and exit, execute service network restart, and an error is directly reported

Restarting network (via systemctl):   Job  for  network.service failed because the control process exited with error code.

See  "systemctl status network.service"  and  "journalctl -xe"  for  details.     

After entering systemctl status network.service command according to the prompt, the following error message appears:

network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2017-07-14 19:01:47 CST; 1min 16s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4681 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
   CGroup: /system.slice/network.service
           └─1192 /sbin/dhclient -H mini1 -1 -q -lf /var/lib/dhclient/dhclient--ens33.lease -pf /v...
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 systemd[1]: network.service: control process exited, code=exited status=1
7月 14 19:01:47 mini1 systemd[1]: Failed to start LSB: Bring up/down networking.
7月 14 19:01:47 mini1 systemd[1]: Unit network.service entered failed state.
7月 14 19:01:47 mini1 systemd[1]: network.service failed.

Set startup to start a service named networkmanager-wait-online. The command is:
systemctl enable networkmanager-wait-online.service

Reboot restart the host

It is normal to re execute systemctl status network.service. Note that the MAC address behind the hwaddr of the newly created eth0 must be consistent with the local machine

Run curl baidu.com again

 

CentOS7 Failed to start LSB: Bring up/down networking. [How to Solve]

Today, I installed Openstack with CentOS7 RDO, and the documentation says that I have to disable NetworkManager and use the network service to do so.
But when I start with the service network start command, I get the following error.
[root@localhost network-scripts]# service network start
Starting network (via systemctl):  Job for network.service failed. See ‘systemctl status network.service’ and ‘journalctl -xn’ for details.[FAILED][root@localhost network-scripts]# systemctl status network.servicenetwork.service – LSB: Bring up/down networking   Loaded: loaded (/etc/rc.d/init.d/network)   Active: failed (Result: exit-code) since Sat 2015-03-07 02:53:12 EST; 6s ago  Process: 8596 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain network[8596]: RTNETLINK answers: File …Mar 07 02:53:12 localhost.localdomain systemd-sysctl[8913]: Overwriting earli…Mar 07 02:53:12 localhost.localdomain systemd[1]: network.service: control pr…Mar 07 02:53:12 localhost.localdomain systemd[1]: Failed to start LSB: Bring …Mar 07 02:53:12 localhost.localdomain systemd[1]: Unit network.service entere…Hint: Some lines were ellipsized, use -l to show in full.

Then search online because it did not add HWADDR …. I did delete this one ….
First, look at the log that says which NIC is not UP.

[root@localhost network-scripts]# cat /var/log/messages | grep network
Mar  7 03:05:18 localhost kernel: drop_monitor: Initializing network drop monitor serviceMar  7 03:05:19 localhost systemd-udevd[413]: renamed network interface eth1 to enp1s0f1Mar  7 03:05:19 localhost systemd-udevd[416]: renamed network interface eth5 to enp8s0f3Mar  7 03:05:19 localhost systemd-udevd[421]: renamed network interface eth3 to enp8s0f1Mar  7 03:05:19 localhost systemd-udevd[429]: renamed network interface eth4 to enp8s0f2Mar  7 03:05:19 localhost systemd-udevd[411]: renamed network interface eth0 to enp1s0f0Mar  7 03:05:19 localhost systemd-udevd[419]: renamed network interface eth2 to enp8s0f0Mar  7 03:05:25 localhost systemd-udevd[412]: renamed network interface eth1 to enp3s0f1Mar  7 03:05:25 localhost systemd-udevd[414]: renamed network interface eth3 to enp131s0f1Mar  7 03:05:25 localhost systemd-udevd[411]: renamed network interface eth0 to enp3s0f0Mar  7 03:05:25 localhost systemd-udevd[413]: renamed network interface eth2 to enp131s0f0Mar  7 03:05:25 localhost systemd-udevd[415]: renamed network interface eth4 to enp134s0f0Mar  7 03:05:25 localhost systemd-udevd[416]: renamed network interface eth5 to enp134s0f1Mar  7 03:05:30 localhost systemd: Starting Import network configuration from initramfs…Mar  7 03:05:30 localhost systemd: Started Import network configuration from initramfs.Mar  7 03:05:40 localhost systemd: Starting Rollback uncommitted netcf network config change transactions…Mar  7 03:05:40 localhost systemd: Started Rollback uncommitted netcf network config change transactions.Mar  7 03:05:43 localhost systemd: Starting LSB: Bring up/down networking…Mar  7 03:05:45 localhost network: Bringing up loopback interface:  [  OK  ]Mar  7 03:05:45 localhost network: Bringing up interface br0:  ERROR    : [/etc/sysconfig/network-scripts/ifup-eth] Device br0 does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost /etc/sysconfig/network-scripts/ifup-eth: Device br0 does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost network: [FAILED]Mar  7 03:05:45 localhost network: Bringing up interface enp1s0f0:  [  OK  ]Mar  7 03:05:45 localhost network: Bringing up interface enp8s0f0:  ERROR    : [/etc/sysconfig/network-scripts/ifup-eth] Device  does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost /etc/sysconfig/network-scripts/ifup-eth: Device  does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost network: [FAILED]Mar  7 03:05:45 localhost network: Bringing up interface enp8s0f1:  ERROR    : [/etc/sysconfig/network-scripts/ifup-eth] Device  does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost /etc/sysconfig/network-scripts/ifup-eth: Device  does not seem to be present, delaying initialization.Mar  7 03:05:45 localhost network: [FAILED]Mar  7 03:05:45 localhost systemd: network.service: control process exited, code=exited status=1Mar  7 03:05:45 localhost systemd: Failed to start LSB: Bring up/down networking.Mar  7 03:05:45 localhost systemd: Unit network.service entered failed state.Mar  7 03:05:48 localhost xinetd[1863]: xinetd Version 2.3.15 started with libwrap loadavg labeled-networking options compiled in.

ip addr to view the MACs of these two NICs.
[root@localhost network-scripts]# ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    inet 127.0.0.1/8 scope host lo       valid_lft forever preferred_lft forever    inet6 ::1/128 scope host        valid_lft forever preferred_lft forever2: enp1s0f0: mtu 1500 qdisc mq master br0 state UP qlen 1000    link/ether 00:25:90:64:a9:30 brd ff:ff:ff:ff:ff:ff    inet6 fe80::225:90ff:fe64:a930/64 scope link        valid_lft forever preferred_lft forever3: enp1s0f1: mtu 1500 qdisc noop state DOWN qlen 1000    link/ether 00:25:90:64:a9:31 brd ff:ff:ff:ff:ff:ff4: enp8s0f0: mtu 1500 qdisc noop state DOWN qlen 1000    link/ether 00:0c:bd:05:4e:cc brd ff:ff:ff:ff:ff:ff5: enp8s0f1: mtu 1500 qdisc noop state DOWN qlen 1000    link/ether 00:0c:bd:05:4e:cd brd ff:ff:ff:ff:ff:ff6: enp8s0f2: mtu 1500 qdisc noop state DOWN qlen 1000    link/ether 00:0c:bd:05:4e:ce brd ff:ff:ff:ff:ff:ff7: enp8s0f3: mtu 1500 qdisc noop state DOWN qlen 1000    link/ether 00:0c:bd:05:4e:cf brd ff:ff:ff:ff:ff:ff

Then write the macs of the two NICs to the configuration file at
/etc/sysconfig/network-scripts/ifcfg-enp8s0f0
/etc/sysconfig/network-scripts/ifcfg-enp8s0f1
​​
ADD:
HWADDR=00:0c:bd:05:4e:cc​

Then restart network, and it’s OK!

It’s been a long time since I’ve updated it. In fact, the problem is not necessarily a MAC problem, there are other possibilities. Here is another scenario.
CentOS7 in the virtual machine can’t be networked after reboot, restart network found error reported.

 

Solution: Disable NetworkManager

1. systemctl stop NetworkManager

2. systemctl disable NetworkManager

Then restart the network service and you can network normally!

SSH Error: write failed: broken pipe [Three Methods to Solve]

Problem scenario

Server environment: cloud Linux CentOS host

Client: Mac OSX terminal

Problem phenomenon

After connecting to the server with SSH command, if you do not operate for a period of time, you will not respond for a period of time when entering terminal again, and then an error prompt will appear:

Write failed: Broken pipe

You can only reconnect with the SSH command.

Solution:

Method 1: if you have multiple servers and do not want to set them on each server, just add the config file in the ~ /. SSH/folder of the client and add the following configuration:

ServerAliveInterval 60

Method 2: if you have more than one person managing the server, you don’t want to set it on each client, just set it on/etc/SSH/sshd of the server_ Add the following configuration to config:

ClientAliveInterval 60

Method 3: if you only want to keep the current SSH connected, you can use the following command:

$ ssh -o ServerAliveInterval=60 user@sshserver

Git clone Error: RPC failed; curl 18 transfer closed with outstanding read data remaining

Git clone RPC failed; Curl 18 transfer closed with outstanding read data remaining error

Cause 1: buffer overflow

Solution: command line input

git config http.postBuffer 524288000

If the clone fails after executing the above command, consider possible cause 2: slow network download speed

Solution: command line input

git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

If the clone still fails, first shallow clone, and then update the remote library locally

git clone --depth=1 http://gitlab.xxx.cn/yyy/zzz.git
git fetch --unshallow

[Solved] CentOS 7.2 Startup Error: Failed to start IPv4 firewall with iptables

problem

The system is CentOS 7.2 and iptables service has been installed, but after executing the startup command, the error that iptables service cannot be started normally is reported.

The startup command is as follows:

systemctl start iptables.service

Errors are reported as follows:

Job for iptables.service failed because the control process exited with error code. See "systemctl status iptables.service" and "journalctl -xe" for details.

Both servers have the same environment, but one is normal and the other is in this situation. I think there is something wrong. Later, I tried several other methods, including reinstalling iptables service and restarting the server, but this error will still be reported.

Execute journalctl - Xe to view the error log and find more specific reasons. The errors are as follows:

Failed to start IPv4 firewall with iptables.

Here we probably know the cause of the problem.

Solution:

Because the default firewall of CentOS 7 is firewall firewall instead of iptables, you need to turn off the firewall service first or simply use the default firewall firewall.

Because the server that reported the error this time is an alicloud server that has just been purchased, it forgot to turn off the default firewall in operation, which led to a waste of time on this matter.

Close firewall:

systemctl stop firewalld  
systemctl mask firewalld

Using iptables services:

#Open 443 port(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

#Save the above rules
service iptables save

#Turn on service
systemctl restart iptables.service

business as usual.

How to Solve Error: failed to push some refs to git

$ git push -u origin master
To [email protected]:yangchao0718/cocos2d.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ‘[email protected]:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.

The main reason for the error is that the README.md file in github is not in the local code directory
You can merge the code with the following command [Note: pull=fetch+merge]
git pull –rebase origin master
After executing the above code, you can see that the README.md file is added to the local code base
At this point, you can upload the code to github by executing git push -u origin master

Git error: failed to push some refs [How to Solve]

To https://[email protected]/name/mywork.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ‘https://[email protected]/name/mywork.git’
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the ‘Note about
fast-forwards’ section of ‘git push –help’ for details.

 

When using git push, I was prompted with the following error message, and after checking a lot of information about it via git push –help and then /fast-forwards, I was unable to find a solution.
After googling, I found that it was caused by a conflict between the version of the code in the remote repository and the local inconsistency.

Solution:
git pull
Automatically merge again or manually merge conflicts
git push again

successfully solved the problem.

Ubuntu20.04 server Error: Failed to restart docker.service: Unit docker.service not found

1. Reasons

This is because I did not use the official installation package or apt to install docker, but I chose to install docker together when installing Ubuntu, so I installed it with snap

2. Phenomenon

sudo systemctl restart docker
sudo service docker restart
sudo systemctl start docker.service

However, errors are always reported:
failed to restart docker.service: unit docker.service not found

3. Order to solve the problem

sudo snap restart docker

4. Other usages of snap package management tool

snap list     To view the package installed by snap:

sudo snap restart docker     Restart docker
sudo snap remove docker    Uninstall docker

5. Uninstall and reinstall docker

6. Install docker-compose

[Solved] Using jdk11 to deploy Nacos under Linux, the startup error is: could not find or load main class

Deploying Nacos using jdk11 under Linux

Error log

/nacos/jdk-11.0.12/bin/java   -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/nacos/nacos-server-2.0.3-node1/logs/java_heapdump.hprof -XX:-UseLargePages -Dnacos.member.list= -Xlog:gc*:file=/nacos/nacos-server-2.0.3-node1/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400 -Dloader.path=/nacos/nacos-server-2.0.3-node1/plugins/health,/nacos/nacos-server-2.0.3-node1/plugins/cmdb -Dnacos.home=/nacos/nacos-server-2.0.3-node1 -jar /nacos/nacos-server-2.0.3-node1/target/nacos-server.jar  --spring.config.additional-location=file:/nacos/nacos-server-2.0.3-node1/conf/ --logging.config=/nacos/nacos-server-2.0.3-node1/conf/nacos-logback.xml --server.max-http-header-size=524288
Error: Could not find or load main class 
Caused by: java.lang.ClassNotFoundException: 

Solution:

In the Nacos-Server bin/startup.sh
Startup error caused by JAVA_OPT_EXT_FIX configuration

Replace the following configuration in the startup.sh file

x JAVA_OPT_EXT_FIX="-Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"
√ JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}"
√ echo "$JAVA ${JAVA_OPT}"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
x nohup "$JAVA" "$JAVA_OPT_EXT_FIX" ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &
√ echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
√ nohup $JAVA ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &