ວິທີການຕິດຕັ້ງແລະຕັ້ງຄ່າ PowerDNS (ກັບ MariaDB) ແລະ PowerAdmin ໃນ RHEL/CentOS 7


PowerDNS ແມ່ນເຊີຟເວີ DNS ທີ່ໃຊ້ໃນຫລາຍເອກະສານ Linux/Unix. ມັນສາມາດໄດ້ຮັບການຕັ້ງຄ່າດ້ວຍ backends ທີ່ແຕກຕ່າງກັນລວມທັງໄຟລ໌ເຂດແບບ BIND, ຖານຂໍ້ມູນທີ່ກ່ຽວຂ້ອງຫຼືການໂຫຼດທີ່ສົມດຸນ/ສູດການຄິດໄລ່. ມັນຍັງສາມາດຕັ້ງຄ່າໄດ້ຄືກັບການເອີ້ນຄືນ DNS ທີ່ເຮັດວຽກເປັນຂະບວນການແຍກຕ່າງຫາກໃນເຊີຟເວີ.

ໂປແກຼມ PowerDNS ທີ່ໄດ້ຮັບອະນຸຍາດ ໃໝ່ ລ້າສຸດແມ່ນ 3.4.4, ແຕ່ເຄື່ອງທີ່ມີຢູ່ໃນ EPEL repository ດຽວນີ້ແມ່ນ 3.4.3. ຂ້ອຍຂໍແນະ ນຳ ໃຫ້ຕິດຕັ້ງບ່ອນ ໜຶ່ງ ສຳ ລັບຫໍສະ ໝຸດ EPEL ເນື່ອງຈາກຄວາມຈິງທີ່ວ່າລຸ້ນນີ້ຖືກທົດສອບຢູ່ໃນ CentOS ແລະ Fedora. ວິທີນັ້ນທ່ານຍັງຈະສາມາດອັບເດດ PowerDNS ໄດ້ງ່າຍໃນອະນາຄົດ.

ບົດຂຽນນີ້ມີຈຸດປະສົງເພື່ອສະແດງວິທີການຕິດຕັ້ງແລະຕິດຕັ້ງ server server PowerDNS ທີ່ມີລະບົບ backend MariaDB ແລະ PowerAdmin - ເປັນເຄື່ອງມືຄຸ້ມຄອງອິນເຕີເນັດທີ່ເປັນມິດກັບ PowerDNS.

ສຳ ລັບຈຸດປະສົງຂອງບົດຄວາມນີ້ຂ້ອຍຈະ ນຳ ໃຊ້ server ກັບ:

Hostname: centos7.localhost 
IP Address 192.168.0.102

ຂັ້ນຕອນທີ 1: ການຕິດຕັ້ງ PowerDNS ກັບ MariaDB Backend

1. ທຳ ອິດທ່ານ ຈຳ ເປັນຕ້ອງເປີດ ນຳ ໃຊ້ EPEL repository ສຳ ລັບ server ຂອງທ່ານໂດຍໃຊ້ງ່າຍໆ:

# yum install epel-release.noarch 

2. ຂັ້ນຕອນຕໍ່ໄປແມ່ນການຕິດຕັ້ງ serverDD. ສິ່ງນີ້ສາມາດເຮັດໄດ້ງ່າຍໂດຍການ ດຳ ເນີນການ ຄຳ ສັ່ງດັ່ງຕໍ່ໄປນີ້:

# yum -y install mariadb-server mariadb

3. ຕໍ່ໄປພວກເຮົາຈະ ກຳ ນົດຄ່າ MySQL ເພື່ອເປີດໃຊ້ງານແລະເລີ່ມຕົ້ນເມື່ອ boot system:

# systemctl enable mariadb.service
# systemctl start mariadb.service

4. ດຽວນີ້ການບໍລິການ MySQL ກຳ ລັງແລ່ນຢູ່, ພວກເຮົາຈະຮັບປະກັນແລະຕັ້ງລະຫັດລັບໃຫ້ MariaDB ໂດຍການເຮັດວຽກ:

# mysql_secure_installation
/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  Press ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y     
New password:  ← Set New Password
Re-enter new password:  ← Repeat Above Password
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y ← Choose “y” to disable that user
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n ← Choose “n” for no
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y ← Choose “y” for yes
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y ← Choose “y” for yes
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

5. ເມື່ອການຕັ້ງຄ່າຂອງ MariaDB ສຳ ເລັດແລ້ວ, ພວກເຮົາສາມາດ ດຳ ເນີນການຕໍ່ໄປໄດ້ອີກດ້ວຍການຕິດຕັ້ງ PowerDNS. ສິ່ງນີ້ຈະ ສຳ ເລັດໄດ້ງ່າຍໂດຍການເຮັດວຽກ:

# yum -y install pdns pdns-backend-mysql

6. ເອກະສານການຕັ້ງຄ່າ ສຳ ລັບ PowerDNS ແມ່ນຕັ້ງຢູ່ໃນ /etc/pdns/pdns , ແຕ່ກ່ອນຈະແກ້ໄຂມັນ, ພວກເຮົາຈະຕັ້ງຖານຂໍ້ມູນ MySQL ສຳ ລັບການບໍລິການ PowerDNS. ທຳ ອິດພວກເຮົາຈະເຊື່ອມຕໍ່ກັບ MySQL server ແລະຈະສ້າງຖານຂໍ້ມູນທີ່ມີຊື່ powerdns:

# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE powerdns;

7. ຕໍ່ໄປ, ພວກເຮົາຈະສ້າງຜູ້ໃຊ້ຖານຂໍ້ມູນທີ່ມີຊື່ວ່າ powerdns:

MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'centos7.localdomain' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> FLUSH PRIVILEGES;

ໝາຍ ເຫດ: ປ່ຽນ“ tecmint123” ດ້ວຍລະຫັດຜ່ານທີ່ທ່ານຕ້ອງການໃຊ້ ສຳ ລັບການຕັ້ງຄ່າຂອງທ່ານ.

8. ພວກເຮົາ ດຳ ເນີນການໂດຍການສ້າງຕາຕະລາງຖານຂໍ້ມູນທີ່ໃຊ້ໂດຍ PowerDNS. ປະຕິບັດຕັນເຫຼົ່ານັ້ນໂດຍ block:

MariaDB [(none)]> USE powerdns;
MariaDB [(none)]> CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
MariaDB [(none)]> CREATE UNIQUE INDEX name_index ON domains(name);
MariaDB [(none)]> CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
MariaDB [(none)]> CREATE INDEX rec_name_index ON records(name);
MariaDB [(none)]> CREATE INDEX nametype_index ON records(name,type);
MariaDB [(none)]> CREATE INDEX domain_id ON records(domain_id);
MariaDB [(none)]> CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

ດຽວນີ້ທ່ານສາມາດອອກຈາກ console MySQL ໂດຍການພິມ:

MariaDB [(none)]> quit;

9. ສຸດທ້າຍພວກເຮົາສາມາດ ດຳ ເນີນການຕັ້ງຄ່າ PowerDNS ຂອງພວກເຮົາໃນແບບທີ່, ມັນຈະໃຊ້ MySQL ເປັນ backend. ສຳ ລັບຈຸດປະສົງນັ້ນ, ເປີດເອກະສານການຕັ້ງຄ່າ PowerDNS ທີ່ຕັ້ງຢູ່:

# vim /etc/pdns/pdns.conf 

ໃນເອກະສານນັ້ນຊອກຫາບັນດາສາຍທີ່ມີລັກສະນະດັ່ງນີ້:

#################################
# launch        Which backends to launch and order to query them in
#
# launch=

ຫລັງຈາກນັ້ນໃສ່ລະຫັດຕໍ່ໄປນີ້:

launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=user-pass
gmysql-dbname=powerdns

ປ່ຽນ“ user-pass” ດ້ວຍລະຫັດຜ່ານທີ່ທ່ານຕັ້ງໄວ້ກ່ອນ ໜ້າ ນີ້. ນີ້ແມ່ນວິທີການຕັ້ງຄ່າຂອງຂ້ອຍຄ້າຍຄື:

ບັນທຶກການປ່ຽນແປງຂອງທ່ານແລະອອກຈາກ.

10. ຕອນນີ້ພວກເຮົາຈະເລີ່ມຕົ້ນແລະເພີ່ມ PowerDNS ເຂົ້າໃນບັນຊີຂອງການບໍລິການເລີ່ມຕົ້ນທີ່ boot system:

# systemctl enable pdns.service 
# systemctl start pdns.service 

ໃນຈຸດນີ້ເຄື່ອງແມ່ຂ່າຍຂອງ PowerDNS ຂອງທ່ານ ກຳ ລັງຢູ່ແລະເຮັດວຽກຢູ່. ສຳ ລັບຂໍ້ມູນເພີ່ມເຕີມກ່ຽວກັບ PowerDNS ທ່ານສາມາດອ້າງອີງໃສ່ປື້ມຄູ່ມືທີ່ມີຢູ່ http://downloads.powerdns.com/documentation/html/index.html