在centos6.5中安装 GitLab 全过程和问题记录


 在centos6.5中安装 GitLab 全过程和问题记录


如果你想省事,使用最新版本的gitlab,请下载一键安装包,一键安装

脚本:https://bitnami.com/stack/gitlab/installer

   

下载后安装时候请查看README

readme:https://bitnami.com/stack/gitlab/README.txt



以下是编译安装,真TM麻烦

先秀下安装完成后的成果。

 wKiom1Z1AEHAEPlEAACY1rjUI8I432.png

centos安装gitlab成果

开始之前

在开始之前请先查看官方的刚需文档: https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/requirements.md ,该文档说明了系统,软件和硬件等各方面的需求。详细的了解这些,可以避免碰到很多怪异的问题。

安装步骤总览

  • 基础操作系统(CentOS 6.4 Minimal,升级后为6.5)

  • Ruby (版本: 2.0.0p353)

  • 创建项目运行用户(创建git账号,方便权限管理)

  • GitLab Shell(版本:1.8.0)

  • 数据库(可以支持mysql和PostgreSQL,这里使用mysql,版本:5.1.17)

  • GitLab(版本:6.3.1)

  • Web服务器(可支持nginx和apache,这里使用tengine-1.5.2)

  • 防火墙(iptables)

1、安装操作系统

这个比较简单,安装完成之后记的配置下网络,使其可以在启动时自动连接。而后需要升级系统和安装一些相应的软件和依赖包,以下逐一说明。

Tips:如果不能连接国外的网络,经常出现网络错误或者couldn’t not resolve host这样的错误,建议修改dns服务器为8.8.8.8和8.8.4.4。

a、升级操作系统和安装wget

$ sudo yum -y update
$ sudo yum -y install wget

升级完成后,系统版本是6.5。

笔者注:和英文文档不同,笔者这里是先升级系统和安装wget,不然后面的操作会提示wget命令找到。

b、增加EPEL安装源

EPEL,即Extra Packages for Enterprise Linux,这个软件仓库里有很多非常常用的软件,而且是专门针对RHEL设计的,对RHEL标准yum源是一个很好的补充,完全免费使用,由Fedora项目维护,所以如果你使用的是RHEL,或者CentOS,Scientific等RHEL系的linux,可以非常放心的使用EPEL的yum源。

下载并安装GPG key

$ sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt
$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

检验下是否安装成功

$ sudo rpm -qa gpg*

安装epel-release-6-8.noarch包

$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

提示:不要在意x86_64,在i686的机器上一样能使用。

c、增加PUIAS安装源

PUIAS Linux是面向桌面和服务器的完整的操作系统,它靠编译Red Hat Enterprise Linux的源代码包来创建。除了这些上游的软件包外,该项目还提供一些其他的软件仓库:“Addons”包含了通常的Red Hat发行中未收入的额外软件包,“Computational”提供专门针对科学计算的软件,“Unsupported”则收入各种各样的测试性软件 包。该发行由美国普林斯顿 大学的高等研究所维护。

创建/etc/yum.repos.d/PUIAS_6_computational.repo,并添加如下内容:

[PUIAS_6_computational]
name=PUIAS computational Base
 $releasever -
 $basearchmirrorlist=
 $releasever/$basearch/mirrorlist
 #baseurl=
 $basearchgpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias

下载并安装GPG key

$ sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias

检验下是否安装成功

$ sudo rpm -qa gpg*

Tips:安装完EPEL和PUIAS两个源后,可以检测下:

$ sudo yum repolist

d、安装GitLab的所需依赖包和工具

$ su -$ yum -y groupinstall 'Development Tools'
$ yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel  redi  sudo wget crontabs logwatch logrotate perl-Time-HiRes git

RHEL提示 
如果部分包不能安装,例如: eg. gdbm-devel, libffi-devel and libicu-devel,那么增加rhel6的安装源。

$ yum-config-manager --enable rhel-6-server-optional-rpms

e、配置redis

配置redis使其在开机时启动:

$此处redis是yum安装,为了省事、
$ sudo chkconfig redis on
$ sudo service redis start

f、配置邮件服务器

笔者注:这个过程笔者没有配置,请参考英文文档。

2、安装Ruby

下载并编译:

$ su -
$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
$ cd ruby-2.0.0-p353$ ./configure --prefix=/usr/local/
$ make && make install

安装完成后,重新登录终端确保$PATH生效,检测ruby的安装成功与否:

$ which ruby
/usr/local/bin/ruby$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

安装bundle:

$ sudo gem install bundler --no-ri --no-rdoc

如果提示sudo: gem: command not found,使用root账号登录执行该命令即可。

3、系统用户

创建用户git

$ su -
$ adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git

因为git用户不需要登录,所以这里不需要设置git的密码。

转发所有邮件

笔者注:因为上面没有配置发送邮件,这里也省略。

4、配置GitLab shell

GitLab shell是专门为GitLab开发的提供ssh访问和版本管理的软件。

先使用root登录,而后切换成git

$ su -
$ su - git

克隆gitlab shell

$  git clone https://github.com/gitlabhq/gitlab-shell.git  
 $ cd gitlab-shell

切换成1.8.0版本,并编辑配置

$ git checkout v1.8.0
$ cp config.yml.example config.yml

这里最重要的是将gitlab_url修改成gitlab的访问域名。形如:http://test.gitlab.com/

笔者注:如果gitlab是使用https访问,则需将http替换成https,配置文件中的self_signed_cert要修改成true,否则gitlab shell在通过api和gitlab进行通信的时候就会出现错误,导致项目push出错。因为后面配置web服务器的时候是使用ssl,所以这里要按照ssl的方式配置。

Tips: 另外如果使用的域名是测试域名,不要忘记在系统的/etc/hosts做域名映射。如果自己有DNS服务器,则不需要绑定hosts

安装一些需要的目录和文件

$ ./bin/install

5、安装数据库

笔者这里使用的是msyql,关于PostgreSQL的安装请参考原文档。

安装mysql并设置开机启动:

 此处我选择安装MySQL的二进制包:安装参考文档:http://douya.blog.51cto.com/6173221/1579986

设置mysql root账号的密码:

$ mysqladmin  -uroot password 'your password'

创建新用户和数据库给gitlab使用

# 登录数据库
$ mysql -u root -p
# 输入root密码
# 为gitlab创建使用用户
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab账号的密码';
# 创建gitlaba使用的数据库
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# 给予gitlab用户权限
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
# 登出数据库
\q

6、安装GitLab

将GitLab安装在git的家目录下:

$ su -
$ su - git

a、克隆GitLab并切换分支到6-3-stable

# 克隆GitLab
$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
# 进入gitlab目录
$ cd /home/git/gitlab
# 切换到6-3-stable分支  ,需要的可以切换到5.0稳定版 
$ git checkout 6-3-stable

b、配置项目

# 复制配置文件
$ cp config/gitlab.yml.example config/gitlab.yml
# 修改配置文件中的访问域名(your_domain_name为项目的访问域名)
$ sed -i 's|localhost|your_domain_name|g' config/gitlab.yml\
 设定log和tmp目录所有者和权限
 $ chown -R git log/
 $ chown -R git tmp/
 $ chmod -R u+rwX log/
 $ chmod -R u+rwX tmp/
 # 创建gitlab-satellites目录
 $ mkdir /home/git/gitlab-satellites
 # 创建tmp/pids/和tmp/sockets/目录,确保gitlab有相应的权限
 $ mkdir tmp/pids/
 $ mkdir tmp/sockets/
 $ chmod -R u+rwX tmp/pids/
 $ chmod -R u+rwX tmp/sockets/
 # 创建public/uploads目录
 $ mkdir public/uploads
 $ chmod -R u+rwX public/uploads
 # 复制unicorn配置
 $ cp config/unicorn.rb.example config/unicorn.rb
 # 编辑unicorn配置(笔者这里采用默认配置)
 $ vim config/unicorn.rb
 # 配置git的用户和邮件
 $ git config --global user.name "GitLab"
 $ git config --global user.email "gitlab@your_domain_name"
 $ git config --global core.autocrlf input

这边的配置比较复杂,细心些就行了。

c、配置数据库访问文件

$ cp config/database.yml.mysql config/database.yml

编辑config/database.yml,设置其中连接数据库的账号密码,笔者的配置部分如下:

## PRODUCTION#production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: gitlab
  password: "gitlab"
  # host: localhost
  # socket: /tmp/mysql.sock

修改其中username和password就可以了,其中密码就是上面数据库步骤中创建gitlab用户的密码。

确保该文件只有git账号有权限读取。

$ chmod o-rwx config/database.yml

d、安装Gems

$ sudo  gem install charlock_holmes --version '0.6.9.4'  此时会遇到一个错误,由于在国内无法访问国外网站原因
[root@gitlab gitlab]# gem install charlock_holmes --version '0.6.9.4'
 
ERROR:  Could not find a valid gem 'charlock_holmes' (= 0.6.9.4), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/specs.4.8.gz)
解决办法:
1,
cd  /home/git/gitlab
vim Gemfile
更改
source https://rubygems.org/ 
为:  
source " https://ruby.taobao.org/ "
2,
gem sources -r  https://rubygems.org/ 
gem sources -a https://ruby.taobao.org/ 
[root@gitlab gitlab]# gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org/
$再次运行,便成功安装
[root@gitlab gitlab]# gem install charlock_holmes --version '0.6.9.4'
$ exit 退出root用户

安装mysql包

$ cd /home/git/gitlab/
[git@Git gitlab]$  bundle install --deployment --without development test postgres puma aws
此时还会出现一个问题
[git@Git gitlab]$ bundle install --deployment --without development test postgres puma aws
-bash: bundle: command not found
解决方案:
[git@Git gitlab]$ sudo   gem install bundler   此不需要用root来安装

此时出现第二个错误:
[git@Git gitlab]$  bundle install --deployment --without development test postgres puma aws
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://ruby.taobao.org/........
Fetching version metadata from https://ruby.taobao.org/..
Could not find modernizr-2.6.2 in any of the sources
解决方法:
1,
[git@gitlab gitlab]$ vim Gemfile
gem "modernizr",        "2.6.2"
更改改为:
gem "modernizr-rails",  "2.7.1"
2,
[git@gitlab gitlab]$ vim Gemfile.lock
将
   modernizr (2.6.2)
更改改为:
    modernizr-rails (2.7.1)
 将
  modernizr (= 2.6.2)
更改改为:
  modernizr-rails (= 2.7.1)
#重新执行:
[git@gitlab gitlab]$ bundle install --deployment --without development test postgres puma aws
此时遇到新的错误:

An error occurred while installing rake (10.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '10.1.0'` succeeds before bundling.
解决办法:
su - 
[root@gitlab gitlab]# gem install rake -v '10.1.0'
此时用root执行 
[root@gitlab gitlab]#     bundle install --deployment --without development test postgres puma aws

e、初始化数据和激活高级功能

$ cd /home/git/gitlab
$ bundle exec rake gitlab:setup RAILS_ENV=production

这步完成后,会生一个默认的管理员账号:

Administrator account created:

login.........root
password......5iveL!fe

f、安装启动脚本

$ su -
$wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn
 $ chmod +x /etc/init.d/gitlab
 $ chkconfig --add gitlab

开机时启动

$ chkconfig gitlab on

g、检测应用程序状态

$ su - git
$ cd gitlab/
 bundle exec rake gitlab:check RAILS_ENV=production   先检查安装环境是否成功、
 
$ bundle exec rake gitlab:env:info RAILS_ENV=production
$ exit
debug模式启动gitlab
bundle exec rails s -e production

可以查看到系统、Ruby、GitLab和GitLab Shell的版本和其他信息。

启动GitLab实例

$ service gitlab start
出现问题 
[root@git ~]# /etc/init.d/gitlab start
Stopping unicorn:                                          [FAILED]
Stopping sidekiq:                                          [FAILED]
Starting unicorn: bash: bin/web: No such file or directory
                                                           [FAILED]
Starting sidekiq: bash: bin/background_jobs: No such file or directory
                                                           [FAILED]

解决方案
[root@git gitlab]#  cd /home/git/gitlab

 cp -r  script/ bin
[root@git gitlab]#/etc/init.d/gitlab start
Starting unicorn:                                          [  OK  ]
Starting sidekiq:                                          [  OK  ]

h、查看应用更加详细的信息

$ su - git
$ cd gitlab/
$ bundle exec rake gitlab:check RAILS_ENV=production
[git@gitlab gitlab]$ bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...

Git configured for git user? ... yes
Has python2? ... yes
python2 is supported version? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version >= 1.7.9 ? ... OK (1.8.0)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ... can't check, you have no projects
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files: 
	/home/git/repositories: OK
	/home/git/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.4.10
Send ping to redis server: PONG
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... no
  Try fixing it:
  Redownload the init script
  For more information see:
  doc/install/installation.md in section "Install Init Script"
  Please fix the error above and rerun the checks.
projects have namespace: ... can't check, you have no projects
Projects have satellites? ... can't check, you have no projects
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... no
  Try fixing it:
  Update your git to a version >= 1.7.10 from 1.7.1
  Please fix the error above and rerun the checks.

Checking GitLab ... Finished

这里会提示一个Init script up-to-date的错误,如下:

Init script up-to-date? ... no
Try fixing it:
Redownload the init scriptFor more information see:
doc/install/installation.md in section "Install Init Script"Please fix the error above and rerun the checks.

原文说明不用介意这个问题,以及git的版本,hooks 咱都不影响使用

7、安装web服务器

笔者选择的是nginx,关于apache方面的请参考原文档

此处我选择的是tengine 编译安装
1,安装省略,因为很简单
2,tengine的配置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
user              root git;
 
worker_processes  2;
 
error_log  logs /error .log;
pid        logs /nginx .pid;
 
 
events {
     worker_connections  1024;
}
 
http {
     include      mime.types;
     default_type  application /octet-stream ;
 
     log_format  main   '$remote_addr - $remote_user [$time_local] "$request" '
                       '$status $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for"' ;
      access_log  logs /access .log  main;
upstream gitlab {
   server unix: /home/git/gitlab/tmp/sockets/gitlab .socket;
}
 
server {
   listen *:80 default_server;         
   server_name your-domain
   server_tokens off;    
   root  /home/git/gitlab/public ;
   client_max_body_size 5m;
 
 
   location / {
     # serve static files from defined root folder;.
     # @gitlab is a named location for the upstream fallback, see below
     try_files $uri $uri /index .html $uri.html @gitlab;
   }
 
   # if a file, which is not found in the root folder is requested,
   # then the proxy pass the request to the upsteam (gitlab unicorn)
   location @gitlab {
     proxy_read_timeout 300;  # https://github.com/gitlabhq/gitlabhq/issues/694
     proxy_connect_timeout 300;  # https://github.com/gitlabhq/gitlabhq/issues/694
     proxy_redirect     off;
 
     proxy_set_header   X-Forwarded-Proto $scheme;
     proxy_set_header   Host              $http_host;
     proxy_set_header   X-Real-IP         $remote_addr;
     proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
 
     proxy_pass http: //gitlab ;
   }
}
}

启动nginx:

1
2
3
4
root@gitlab tengine] # /usr/local/tengine/sbin/nginx -t 
the configuration  file  /usr/local/tengine/conf/nginx .conf syntax is ok
configuration  file  /usr/local/tengine/conf/nginx .conf  test  is successful
[root@gitlab tengine] # /usr/local/tengine/sbin/nginx

 访问成果:


wKioL1Z0_8TiLVDLAACY1rjUI8I681.png

去开始哈皮吧~~~ 


参考资料:http://www.centoscn.com/image-text/install/2015/0320/4929.html

############### 邮件通知########################

 你Linux系统使用的是postfix邮箱,而且配置文件能是默认,并且使用mail可以发邮件,所以执行以下,确保可以发邮件

1. 首先是拷贝Gitlab自带的example

cd  /home/git/gitlab
sudo  -u git -H  cp  config /initializers/smtp_settings .rb.sample config /initializers/smtp_settings .rb


2. 然后用我们自己的邮箱替换example中的邮箱

sudo -u git -H vim config/initializers/smtp_settings.rb

一键安装路径:

cd  /opt/gitlab-8.5.7-0

vim apps/gitlab/htdocs/config/environments/production.rb 


这里提供163和腾讯企业邮箱两种配置方式,注意将下面的123456替换成自己的密码

163邮箱:

if  Rails. env .production?
   Gitlab::Application.config.action_mailer.delivery_method = :smtp
   ActionMailer::Base.smtp_settings = {
     address:  "smtp.163.com" ,
     port: 25,
     user_name:  "wpgitlab" ,
     password:  "123456" ,
     domain:  "163.com" ,
     authentication: :plain,
     enable_starttls_auto:  true
   }
end


QQ邮箱:

if  Rails. env .production?
   Gitlab::Application.config.action_mailer.delivery_method = :smtp
   ActionMailer::Base.smtp_settings = {
     address:  "smtp.exmail.qq.com" ,
     port: 25,
     user_name:  "wangpeng@scnee.com" ,
     password:  "123456" ,
     domain:  "smtp.qq.com" ,
     authentication: :plain,
     enable_starttls_auto:  true ,
   }
end


3. 修改gitlab.yml

cd  /home/git/gitlab

sudo -u git -H vim config/gitlab.yml


一键安装路径:

cd  /opt/gitlab-8.5.7-0

vim apps/gitlab/htdocs/config/gitlab.yml


将默认邮箱修改为自己的邮箱

163:

## Email settings
     # Email address used in the "From" field in mails sent by GitLab
     email_from: wpgit@163.com


腾讯企业邮箱:

## Email settings
     # Email address used in the "From" field in mails sent by GitLab
     email_from: wangpeng@scnee.com


4. 修改后。重启gitlab


本文出自 “crazy_sir” 博客,请务必保留此出处http://douya.blog.51cto.com/6173221/1726333


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!
在 CentOS 6.5 上安装并配置 DNS 服务器的步骤如下: 1. 安装 BIND 软件: ``` yum install bind bind-utils ``` 2. 配置 BIND 在 /etc/named.conf 文件配置 BIND,可以参考下面的示例配置: ``` 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"; allow-query { localhost; }; 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"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "example.com" IN { type master; file "zone/example.com.zone"; allow-update { none; }; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; ``` 上面的配置,listen-on 指定 BIND 监听的 IP 地址和端口,directory 指定 BIND 的工作目录,allow-query 指定允许查询 DNS 的 IP 地址,zone 部分指定了 DNS 解析的域名和对应的配置文件路径。 3. 创建 DNS 配置文件 在 /var/named/ 目录下创建一个名为 example.com.zone 的文件,可以参考下面的示例配置: ``` $TTL 1D @ IN SOA ns.example.com. root.example.com. ( 1 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum IN NS ns.example.com. ns IN A 192.168.0.1 www IN A 192.168.0.2 ``` 上面的配置,@ 表示当前域名,IN 表示 Internet 类型,SOA 表示 Start of Authority,NS 表示 Name Server,A 表示 Address。可以根据自己的需求配置相应的解析记录。 4. 启动 BIND 执行以下命令启动 BIND: ``` service named start ``` 5. 配置 DNS 客户端 在需要使用 DNS 服务的客户端上,可以将 DNS 服务器地址设置为 BIND 服务器的 IP 地址,即 192.168.0.1。 参考上述步骤,可以在 CentOS 6.5 上安装并配置 DNS 服务器。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值