Tag Archives: centos7

Error reporting in CentOS 7 using yum

Yesterday, we encountered a problem. CentOS 7 reported an error using the yum installation command

yum install unzip zip

yum install unzip zip

Error reporting
Baidu error reporting is probably due to the image problem. To use the alicloud image
modification command, first backup CentOS- Base.repo , rename it

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

Then download the image
centos7:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

And then you see, there’s a new CentOS- Base.repo
Just clear the yum cache and regenerate it

yum clera
yum makecache

When the cache is regenerated, it will run for a while. When the cache is generated and no error is reported, you can download it using yum

Centos7 installing Kafka

Download kafka
website: http://kafka.apache.org/
enter the url: http://kafka.apache.org/downloads
System environment
1, the operating system: 64 CentOS7
2, JDK version: 1.8.0 comes with _271 version
3, they are: they are – 3.4.6
4, three server deployment success: 192.168.192.150; 192.168.192.152; 192.168.192.155;
Pre-setting:

[root@localhost /]# timedatectl set-timezone Asia/Shanghai
root@localhost /]# timedatectl
[root@localhost /]# timedatectl
[root@localhost /]# timedatectl
[root@localhost /]# timedatectl

[root@master /]# yum-y install NTP
p1
[>daoplaceholder1 /]# ntpdate ntp1.aliyun.com
hostname ectl set-hostname master
stname ectl set-hostname node1
h>ame ectl set-hostname node2
hostname ectl set-hostname node2
hostname ectl set-hostname node2
hostname ectl set-hostname node2

192.168.192.150 master
2.168.192.152 node1
1>68.192.155 node2
192.168.192.155

127.0.0.1 localhost
: 1 localhost
1>68.93.150 master
192.168>152 node1
192.168.93.15>de2
192.168.93.155 node2
192.168.93.155 node2

192.168.93.155 nod> br> If you change the hosts in Windows 10, you can copy this file to the desktop and add the above contents. Then replace the hosts file under C:\Windows\System32\ Drivers \etc with
.

props. Put (consumerConfig. Bootstrap_servers_config,”node1:9092,node2:9092″);
tar-zxvf /usr/local/soft/kafka_2.11-2.2.0.tgz -c /usr/local/ kafka
tar-zxvf /usr/local/soft/kafka_2.11-2.2.0.tgz -c /usr/local/
2, configuration, kafka
[root @ localhost] # vi/usr/local/kafka_2. 11-2.2.0/config/server properties
Kafka’s configuration information is configured in server.properties
Find the following two lines of code and comment them separately
#broker.id=0
#zookeeper.connect=localhost:2181
Modify the directory where the logs are stored
The log. The dirs =/kafka_2. 11-2.2.0/kafka – logs
Add the following three configurations at the bottom of the file:
Broker. Id = 1
zookeeper. Connect = 192.168.192.150:2181192168 192.152:2181192168 192.155:2181

Listeners = PlainText :// Master :9092 Listeners :// Master :9092

[root@localhost local]# CD kafka2.11-2.2.0 /
root@localhost kafka2.11-2.2.0]# mkdir kafka-logs
[root@localhost local]# CD kafka2.11-2.2.0 /
[root@localhost kafka2.11-2.2.0]# mkdir kafka-logs

Note: If it is a stand-alone version, the default is fine, we do not need to change anything. Now we are configuring the cluster, so we need to configure some parameters
1), Broker. id: Each machine cannot be the same
2), ZooKeeper. Connect: Since I have 3 ZooKeeper servers, I set ZooKeeper. Connect to 3 servers and must add all of them
3), Listeners: Listeners must be set when configuring the cluster, otherwise the leader error will not be found for future operations
WARN [Producer clientId = console – Producer] Error while fetching the metadata with the correlation id 40: {test = LEADER_NOT_AVAILABLE} workClient (org.apache.kafka.clients.Net)
4) Notice that the two servers, ZooKeeper. Connect, are configured the same as here, but the Broker. ID and Listeners cannot be configured the same
5 copies, kafka to two other servers
[root @ localhost config] # SCP – r/usr/local/kafka_2. 11-2.2.0 [email protected]:/usr/local/
[root @ localhost config] # SCP – r/usr/local/kafka_2. 11-2.2.0 [email protected]:/usr/local /
You will be asked to enter the password of the target machine. Just follow the instructions and modify the Broker. id and Listeners of the two servers as follows:
6, 192.168.192.152
[root @ localhost] # vi/usr/local/kafka_2. 11-2.2.0/config/server properties
Then a change on the broker. Id = 2 and listeners = PLAINTEXT:// 192.168.192.152:9092, the zookeeper. Connect don’t need to change are the same
Broker.
id = 2 zookeeper. Connect = 192.168.192.150:2181192168 192.152:2181192168 192.155:2181
listeners = PLAINTEXT:// node1:9092
7, 192.168.192.155
[root @ localhost] # vi/usr/local/kafka_2. 11-2.2.0/config/server properties
Then a change on the broker. Id = 3 and listeners = PLAINTEXT:// 192.168.192.155:9092, the zookeeper. Connect don’t need to change are the same
Broker. Id = 3
zookeeper. Connect = 192.168.192.150:2181192168 192.152:2181192168 192.155:2181
listeners = PLAINTEXT:// 2:9092
If the firewall has been turned off, it can be ignored.
All three machines must be turned on. Kafka communication is conducted through port 9092 by default, which is the Listed Listeners we have provided above
[root@localhost config]# firewall-cmd –zone=public –add-port=9092/tcp –permanent
[root@localhost config]# firewall-cmd –reload

[root@localhost /]# /usr/local/ ZooKeeper -3.4.6/bin/ zkserver.sh start
[root@localhost /]# /usr/local/ ZooKeeper -3.4.6/bin/ zkserver.sh start
[root@localhost /]# /usr/local/ ZooKeeper -3.4.6/bin/ zkserver.sh start
10, start, kafka,
three is to launch the
[root @ localhost /] #/usr/local/kafka_2. 11-2.2.0/bin/kafka – server – start. Sh – daemon/usr/local/kafka_2. 11-2.2.0/config/server properties

[root@localhost /]# JPS
87 JPS
9>kafka
9224 Kafka
9224 Kafka
[root@localhost /]# CD /usr/local/kafka_2.11-2.2.0/
root@localhost kafka_2.11-2.2.0]# bin/ kafka-Topics. Sh –create — ZooKeeper 192.168.192.150:2181 –replication-factor 1 –partitions 1 –topic test
Created topic test.
If successful, it outputs: Created Topic “test”.
13, see the topic
while 192.168.192.150 created on the topic, but the other two machine also can see that the 192.168.192.152 client
[root@localhost /]# CD /usr/local/kafka_2.11-2.2.0/
[root@localhost kafka_2.11-2.2.0]# bin/ kafka-Topics — List — ZooKeeper 192.168.192.152:2181
st
Note: The IP here can be 192.168.192.150, 192.168.192.152, 192.168.192.155. Themes can be seen on any of the three servers


root@localhost kafka_2.11-2.2.0]# bin/kafka-console-producer.sh –broker — list 192.168.192.150:9092 –topic test
>> a
> b
> c
# bin/kafka-console-consumer.sh –bootstrap-server 192.168.192.152:9092 — Topic test –from — Beginning
a

c>

【Linux】psql: FATAL: Ident authentication failed for user “username” Error and Solution

Question:I have installed Postgresql.x server under Red Hat Enterprise Linux 5. I have created username/password and database. But when I try to connect it via PHP or psql use the following syntax:

psql -d myDb -U username -W
It gives me an error that reads as follows:

psql:Fatal: Ident authentication failed for user “username”.
How do I fix this error?

A. To fix this error, open the PostgreSQL client authentication configuration file /var/lib/pgsql/data/pg_hba.conf:
# vi /var/lib/pgsql/data/pg_hba.conf:
# vi /var/lib/pgsql/data/pg_hba.conf: # vi /var/lib/pgsql/data/pg_hba.conf: # vi /var/lib/pgsql/data/pg_hba.conf.

    Which hosts are allowed to connect, which clients are authenticated, which PostgreSQL usernames are available to which users, and which databases are accessible

By default, Postgresql uses identity-based authentication. All you have to do is allow authentication to your network or web server based on username and password.IDENT will never allow you to log in via the -U and -W options. Add the following to allow logins through local hosts only:

local all all trust
host all 127.0.0.1/32 trust

Save and close the file. Restart the Postgresql server:
# service Postgresql Restart
Now you should be able to log in using the following command:
$ psql -d myDb -U username -W

The most complete solution for service network restart failure under CENTOS 7

Often, after changing the static IP under centOS 7, someone would find that the network service could not be restarted, so they searched the network, tried various methods and finally solved the problem.
is now a summary of various solutions, I hope to let you walk less crooked road.

First things first:
After executing the Service Network Restart command, the following error occurs:

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 input systemctl status network. Service command, 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 三 2018-09-05 13: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...
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 network[4681]: RTNETLINK answers: File exists
9月 05 13:01:47 mini1 systemd[1]: network.service: control process exited, code=exited status=1
9月 05 13:01:47 mini1 systemd[1]: Failed to start LSB: Bring up/down networking.
9月 05 13:01:47 mini1 systemd[1]: Unit network.service entered failed state.
9月 05 13:01:47 mini1 systemd[1]: network.service failed.

The network service cannot be started!! First of all, make sure that ifCFg-XXX (each machine is not the same) in /etc/sysconfig/network-scripts directory is free of errors (if you have made any changes), which refer to things like typing the wrong letters by hand during the change process.
The most common methods on the Internet are as follows:
1, and the NetworkManager service conflict, directly close the NetworkManager service, service NetworkManager stop, and forbid starting chkconfig NetworkManager off, finally restart it.
2. If it does not match the MAC address of the configuration file, use IP ADDR (or IFconfig) to check the MAC address

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    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 forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:b8:e7:21 brd ff:ff:ff:ff:ff:ff
    inet 192.168.65.141/24 brd 192.168.65.255 scope global dynamic ens33
       valid_lft 1193sec preferred_lft 1193sec
    inet6 fe80::cca2:d835:f93:e637/64 scope link 
       valid_lft forever preferred_lft forever

00:0 C :29:b8:e7:21 is the MAC address, change HWADDR in /etc/sysconfig/ net-scripts/ifCFg-XXX to this MAC address
3. Set up and start a service named networkmanager-waiting-online . The command is: systemctl enable networkmanager-waiting-online-service
4, see /etc/sysconfig/network - scripts , will the rest of the network card position papers all deleted, avoid unnecessary influence, is only a file, starting with ifcfg leave that one should use IP addr command to check the IP the second identical at the beginning of (see above for my ens33, I posted the IP addr command execution results), so I only left a ifcfg - ens33. (That's how two of my machines worked, because I made a backup before changing it, so just delete it...)
5. Comment out the DEVICE line in IFCFG-XXX file.
6. Change the NAME in IFCFG-XXX to be the same as the file NAME.
7. Change the network mode to bridge in VMWare edit-Virtual Network Editor.
8. Check whether the network adapter at the bottom right corner of VMWare is connected or not. If it is not connected, it will be connected.

(note: click the network adapter - Settings, and try to change the NAT mode to bridge. After I changed the bridge mode, I could restart the network service, but I could not connect to the network. After restarting,
and then change the bridge mode to NAT mode, and I found that I could both surf the Internet and restart the network service.)
9. Check to see if VMware DHCP Service and VMware NAT Service are disabled on your computer. If so, turn them on.
10. If you change to static IP don't forget to change BOOTPROTO to static.
11,, if the above is not resolved, there is a final move - restart to see if there is a miracle!! (A lot of times you just restart it.)
I have tried almost all of the above methods, some of which are useful or not useful for my machine, but some people have solved them with these methods, and recorded them together for future use

Failed to get D-Bus connection: No such file or directory

when running centos7 image in docker, error
[root@2181bc14e47f /]# systemctl list-units
Failed to get d-bus connection: No such file or directory
d-bus allows the program to register on it to provide services to other programs. It also provides the possibility for the client program to query what services are available. Applications can also be registered to wait for kernel events, such as hardware hotplug. It is a three-tier inter-process communication (IPC) system, including:
function library libdbus, used for calling contacts and interacting messages between two applications. A message constructed based on libdbus, the bus daemon can connect to multiple applications simultaneously and can route messages from one application to 0 or more other programs. A series of Wrapper libraries based on specific application frameworks. D-bus is designed for two specific situations:
communication between two desktop applications within the same desktop session, allowing the desktop session to be integrated as a whole to solve problems related to the process lifecycle. Communication between a desktop session and an operating system, where the operating system generally includes the kernel and system daemons.
after the docker exit
$docker run — br> $docker run –privileged/ti-e “container=docker” centos7-base /usr/sbin/init
-privileged docker introduction, using this parameter, the root in the container has the real root privilege, otherwise, the root in the container is just an external ordinary user privilege. The container that the Privileged starts can see a lot of equipment on host and mount can be performed.
even allows you to start a docker container in a docker container. -e “container=docker” sets the environment variable that processes inside the container can get directly.
can now execute the systemctl command

/root @ bd5aa199dbc9 ~ # systemctl status SSHD
low SSHD. Service – the OpenSSH server daemon
the Loaded: the Loaded (/ usr/lib/systemd/system/SSHD. Service; enabled; Vendor pre: enabled)
Active: inactive (dead)
Docs: man: SSHD (8)
man:sshd_config(5)

Centos7 quick installation of docker and configuration of image acceleration

follow the official documentation step by step

https://docs.docker.com/engine/install/centos/

1: uninstall the old version

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2: download docker dependent packages and configure docker warehouse address

 sudo yum install -y yum-utils
 sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3: install docker’s engine, operate docker’s client, and its container

sudo yum install docker-ce docker-ce-cli containerd.io

after the execution of the installation is complete

start docker command:

sudo systemctl start docker

set docker startup:

sudo systemctl enable docker

view docker version:

docker -v

view docker image:

sudo docker images

configure image acceleration: configure ali cloud

1: create directory

sudo mkdir -p /etc/docker

2: configure the mirror accelerator address

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://17o3zxc0.mirror.aliyuncs.com"]
}
EOF

3: restart docker background thread

sudo systemctl daemon-reload

4: restart docker service

sudo systemctl restart docker