Linux6安装bind错误,CentOS 7.6环境下Bind 9的安装与配置

这篇博客详细介绍了在CentOS 7.6系统上安装和配置Bind 9的过程,包括查看系统版本、安装bind及其依赖、启用和启动服务、配置主配置文件、设置DNS解析以及验证DNS服务的正向和反向解析功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看当前系统版本

[root@iZj6cehstgjoj3qav88fidZ ~]# cat /etc/redhat-release

CentOS Linux release 7.6.1810 (Core)

[root@iZj6cehstgjoj3qav88fidZ ~]#

查看bind软件包信息

[root@iZj6cehstgjoj3qav88fidZ ~]# yum info bind

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Available Packages

Name : bind

Arch : x86_64

Epoch : 32

Version : 9.9.4

Release : 73.el7_6

Size : 1.8 M

Repo : updates/7/x86_64

Summary : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server

URL : http://www.isc.org/products/BIND/

License : ISC

Description : BIND (Berkeley Internet Name Domain) is an implementation of the DNS

: (Domain Name System) protocols. BIND includes a DNS server (named),

: which resolves host names to IP addresses; a resolver library

: (routines for applications to use when interfacing with DNS); and

: tools for verifying that the DNS server is operating properly.

[root@iZj6cehstgjoj3qav88fidZ ~]#

使用yum安装bind及依赖包

[root@iZj6cehstgjoj3qav88fidZ ~]# yum install bind

安装清单

Installed:

bind.x86_64 32:9.9.4-73.el7_6

Dependency Installed:

audit-libs-python.x86_64 0:2.8.4-4.el7 bind-libs.x86_64 32:9.9.4-73.el7_6 checkpolicy.x86_64 0:2.5-8.el7 libcgroup.x86_64 0:0.41-20.el7 libsemanage-python.x86_64 0:2.5-14.el7

policycoreutils-python.x86_64 0:2.5-29.el7_6.1 python-IPy.noarch 0:0.75-6.el7 python-ply.noarch 0:3.4-11.el7 setools-libs.x86_64 0:3.3.8-4.el7

注册服务及启动服务

[root@iZj6cehstgjoj3qav88fidZ ~]# systemctl enable named

Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.

[root@iZj6cehstgjoj3qav88fidZ ~]# systemctl start named

[root@iZj6cehstgjoj3qav88fidZ ~]#

查看端口监听

06605b7de94722a72306bf8f559bca57.png

查看主配置文件

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /etc/named.conf

//

// named.conf

//

// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

// server as a caching only nameserver (as a localhost DNS resolver only).

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

// See the BIND Administrator's Reference Manual (ARM) for details about the

// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

options {

listen-on port 53 { 127.0.0.1; };

listen-on-v6 port 53 { ::1; };

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

memstatistics-file "/var/named/data/named_mem_stats.txt";

recursing-file "/var/named/data/named.recursing";

secroots-file "/var/named/data/named.secroots";

allow-query { localhost; };

/*

- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.

- If you are building a RECURSIVE (caching) DNS server, you need to enable

recursion.

- If your recursive DNS server has a public IP address, you MUST enable access

control to limit queries to your legitimate users. Failing to do so will

cause your server to become part of large scale DNS amplification

attacks. Implementing BCP38 within your network would greatly

reduce such attack surface

*/

recursion yes;

dnssec-enable yes;

dnssec-validation yes;

/* Path to ISC DLV key */

bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";

pid-file "/run/named/named.pid";

session-keyfile "/run/named/session.key";

};

logging {

channel default_debug {

file "data/named.run";

severity dynamic;

};

};

zone "." IN {

type hint;

file "named.ca";

};

include "/etc/named.rfc1912.zones";

include "/etc/named.root.key";

查看当前主机DNS配置

[root@iZj6cehstgjoj3qav88fidZ ~]# cat /etc/resolv.conf

options timeout:2 attempts:3 rotate single-request-reopen

; generated by /usr/sbin/dhclient-script

nameserver 100.100.2.136

nameserver 100.100.2.138

search localdomain

[root@iZj6cehstgjoj3qav88fidZ ~]#

安装域名解析提示工具包

[root@iZj6cehstgjoj3qav88fidZ ~]# yum install bind-utils

查看软件版路径及文件

[root@iZj6cehstgjoj3qav88fidZ ~]# rpm -lq bind-utils

/etc/trusted-key.key

/usr/bin/dig

/usr/bin/host

/usr/bin/nslookup

/usr/bin/nsupdate

/usr/share/man/man1/dig.1.gz

/usr/share/man/man1/host.1.gz

/usr/share/man/man1/nslookup.1.gz

/usr/share/man/man1/nsupdate.1.gz

[root@iZj6cehstgjoj3qav88fidZ ~]#

修改本机DNS为当前DNS服务器并尝试域名解析操作

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /etc/resolv.conf

options timeout:2 attempts:3 rotate single-request-reopen

; generated by /usr/sbin/dhclient-script

#nameserver 100.100.2.136

#nameserver 100.100.2.138

nameserver 127.0.0.1

search localdomain

使用nslookup命令及ping命令检查域名递归(缓存)DNS配置生效情况

533dad41c45d7622a1acb7804b06de3f.png

为内网主机配置正向解析和反向解析

查看默认的区域配置文件

// named.rfc1912.zones:

//

// Provided by Red Hat caching-nameserver package

//

// ISC BIND named zone configuration for zones recommended by

// RFC 1912 section 4.1 : localhost TLDs and address zones

// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt

// (c)2007 R W Franks

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

zone "localhost.localdomain" IN {

type master;

file "named.localhost";

allow-update { none; };

};

zone "localhost" IN {

type master;

file "named.localhost";

allow-update { none; };

};

zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {

type master;

file "named.loopback";

allow-update { none; };

};

zone "1.0.0.127.in-addr.arpa" IN {

type master;

file "named.loopback";

allow-update { none; };

};

zone "0.in-addr.arpa" IN {

type master;

file "named.empty";

allow-update { none; };

};

添加自定义区域配置

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /etc/named.rfc1912.zones

zone "ns-zone.com" IN {

type master;

file "ns-zone.com.zone";

allow-update { none; };

};

创建自定义区域配置文件

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /var/named/ns-zone.com.zone

$TTL 600 ; 10 minutes

@ IN SOA ns1.ns-zone.com. hostmaster.ns-zone.com. (

20190001 ; serial number

10800 ; refresh time (3 hours)

900 ; retry time (15 minutes)

604800 ; expire time (1 week)

86400 ; minimum (1 day)

)

NS ns1.ns-zone.com.

$ORIGIN ns-zone.com.

$TTL 60 ; 1 minute

ns1 A 10.22.105.60

www A 10.22.105.60

修改区域配置文件属性

02c61a0f33b3c58117db1f979fd792b9.png

3e0dc24f37b9afe236444540493a94cf.png

检查主配置文件和自定义区域配置文件

[root@iZj6cehstgjoj3qav88fidZ ~]# named-checkconf

[root@iZj6cehstgjoj3qav88fidZ ~]#

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /var/named/ns-zone.com.zone

[root@iZj6cehstgjoj3qav88fidZ ~]# named-checkzone ns-zone.com. /var/named/ns-zone.com.zone

zone ns-zone.com/IN: loaded serial 20190001

OK

[root@iZj6cehstgjoj3qav88fidZ ~]#

重启bind服务并验证新增加的正向解析

[root@iZj6cehstgjoj3qav88fidZ ~]# systemctl restart named

[root@iZj6cehstgjoj3qav88fidZ ~]# nslookup ns1.ns-zone.com

Server: 127.0.0.1

Address: 127.0.0.1#53

Name: ns1.ns-zone.com

Address: 10.22.105.60

[root@iZj6cehstgjoj3qav88fidZ ~]# nslookup www.ns-zone.com

Server: 127.0.0.1

Address: 127.0.0.1#53

Name: www.ns-zone.com

Address: 10.22.105.60

[root@iZj6cehstgjoj3qav88fidZ ~]#

使用dig命令查看NS记录

f140c5caabc8f9341270eea1a6bcc869.png

反向解析

增加区域配置

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /etc/named.rfc1912.zones

zone "105.22.10.in-addr.arpa" IN {

type master;

file "105.22.10.in-addr.arpa.zone";

allow-update { none; };

};

增加自定义区域配置文件

[root@iZj6cehstgjoj3qav88fidZ ~]# vi /var/named/105.22.10.in-addr.arpa.zone

$TTL 600 ; 10 minutes

@ IN SOA ns1.ns-zone.com. hostmaster.ns-zone.com. (

20190001 ; serial number

10800 ; refresh time (3 hours)

900 ; retry time (15 minutes)

604800 ; expire time (1 week)

86400 ; minimum (1 day)

)

NS ns1.ns-zone.com.

$ORIGIN 105.22.10.in-addr.arpa.

$TTL 60 ; 1 minute

60 PTR ns1.ns-zone.com.

检查主配置文件和自定义区域配置文件

[root@iZj6cehstgjoj3qav88fidZ ~]# named-checkconf

[root@iZj6cehstgjoj3qav88fidZ ~]#

[root@iZj6cehstgjoj3qav88fidZ ~]# named-checkzone 105.22.10.in-addr.arpa. /var/named/105.22.10.in-addr.arpa.zone

zone 105.22.10.in-addr.arpa/IN: loaded serial 20190001

OK

[root@iZj6cehstgjoj3qav88fidZ ~]#

验证反向解析

6f8254860cf1b3173682e7704763c28a.png

e38ab2aab6c893e892f79a939ebbdae8.png

<think>好的,我现在要在CentOS 7.6安装Redis 5.0.14版本。首先,我需要按照用户提供的引用中的步骤来操作。根据引用[1],下载并解压Redis源码包,然后编译安装。用户提到使用tar命令解压,然后进入目录执行make和make install。这应该没问题,但需要确认系统是否安装了gcc等编译工具,否则make会失败。 接下来,引用[4]提到配置主服务器redis.conf文件,需要设置bind、port、protected-mode等参数。这里可能需要先复制一个默认的配置文件,或者安装后的配置文件位置在哪里呢?通常源码安装的话,配置文件可能在解压后的目录里,比如/opt/redis-5.0.14/redis.conf,但用户需要手动处理。 然后是系统服务的配置。根据引用[2]和引用[3],需要创建systemd服务文件,这样可以使用systemctl管理Redis服务。用户提供的步骤中有systemctl daemon-reload,enable,start等命令。需要检查服务文件是否正确,比如路径是否正确,ExecStart指向正确的redis-server和配置文件路径。 另外,引用[3]还提到防火墙设置,开放6379端口。CentOS 7默认使用firewalld,所以需要执行相应的firewall-cmd命令。不过如果是在云服务器上,可能还需要在安全组中放行端口。 用户的问题是关于安装Redis 5.0.14的具体步骤,可能需要将上述引用中的步骤整合起来。例如,下载源码、编译安装配置redis.conf、设置systemd服务、配置开机启动和防火墙。 需要注意的地方可能有:编译前的依赖安装,比如gcc是否已安装,否则make会出错。此外,安装后的目录结构,是否需要将redis.conf复制到/etc/redis目录下,或者保持原位置。还有权限问题,比如日志文件的目录是否有写入权限。 还有,引用[4]中的配置参数如requirepass和masterauth,说明用户可能是在配置主从复制或者集群,但如果是单机安装,这部分是否需要?用户的问题只是安装,可能这些配置是可选的,但根据引用[4],用户可能需要设置密码,所以可能需要包含在步骤中。 总结步骤应该是: 1. 安装编译依赖 2. 下载Redis源码并解压 3. 编译安装 4. 配置redis.conf(绑定地址、端口、保护模式、守护进程、日志、密码等) 5. 创建systemd服务文件并启用 6. 配置防火墙 7. 启动服务并测试 需要检查每个步骤的正确性,比如解压后的目录名是否正确,服务文件中的路径是否正确指向安装后的redis-server和配置文件。另外,在配置文件中设置daemonize为yes,但systemd服务可能需要设置为no,或者由systemd管理守护进程,这个可能需要确认,避免冲突。 还有,用户提供的引用中有多个地方提到不同的配置,比如引用[4]中的配置可能适用于集群设置,但用户的问题只是安装,是否需要全部包含?可能需要分步骤,先完成基本安装,再配置必要参数,如bind和protected-mode,以及密码等。 可能的问题点:编译错误,服务无法启动,防火墙阻止访问,配置文件路径错误,权限问题等。需要确保每个步骤都正确,并给出相应的解决建议,比如安装gcc,处理服务启动失败时的日志查看方法。</think>以下是在CentOS 7.6系统中安装Redis 5.0.14的详细步骤: --- ### **1. 安装编译依赖** 首先安装必要的编译工具: ```bash yum install -y gcc make wget ``` --- ### **2. 下载并解压Redis源码** ```bash wget https://download.redis.io/releases/redis-5.0.14.tar.gz tar -zxvf redis-5.0.14.tar.gz cd redis-5.0.14 ``` --- ### **3. 编译安装** ```bash make && make install ``` 安装完成后,默认二进制文件位于`/usr/local/bin`目录下[^1]。 --- ### **4. 配置Redis** #### 4.1 创建配置文件目录 ```bash mkdir -p /etc/redis cp redis.conf /etc/redis/ ``` #### 4.2 修改配置文件 编辑`/etc/redis/redis.conf`,关键配置如下: ```conf bind 0.0.0.0 # 允许所有IP访问 port 6379 # 默认端口 protected-mode no # 关闭保护模式 daemonize no # 由systemd管理进程 logfile "/var/log/redis.log" # 日志路径 requirepass abc123 # 设置密码(可选) dir /var/lib/redis # 数据存储目录 ``` 创建相关目录并授权: ```bash mkdir -p /var/lib/redis touch /var/log/redis.log chmod 777 /var/log/redis.log ``` --- ### **5. 配置systemd服务** #### 5.1 创建服务文件 ```bash vim /etc/systemd/system/redis.service ``` 输入以下内容: ```ini [Unit] Description=Redis Server After=network.target [Service] ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/local/bin/redis-cli shutdown Restart=always User=root [Install] WantedBy=multi-user.target ``` #### 5.2 启动服务 ```bash systemctl daemon-reload # 刷新配置[^2] systemctl enable redis # 开机自启[^3] systemctl start redis # 启动服务 systemctl status redis # 检查状态 ``` --- ### **6. 配置防火墙** ```bash firewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload ``` --- ### **7. 验证安装** ```bash redis-cli -a abc123 ping # 若设置了密码需添加`-a`参数 ``` 返回`PONG`即表示安装成功。 --- ### **安装问题排查** - **编译错误**:若`make`失败,尝试清理后重新编译: ```bash make distclean && make ``` - **服务启动失败**:检查日志`/var/log/redis.log`定位问题。 - **端口冲突**:通过`netstat -tunlp | grep 6379`检查端口占用。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值