2018-08-20 21:07:38
一、關閉SELinux
查詢是否開啟了SELinux
getenforce
SELinux一共有3種狀态,分别是**Enforcing,Permissive**和**Disabled**狀态。第一種是預設狀态,表示強制啟用,第二種是寬容的意思,即大部分規則都放行。第三種是禁用,即不設定任何規則
setenforce 0 #把SELinux關閉,此操作為臨時關閉,重新開機後失效
vim /etc/selnux/conf #修改為disabled,此操作為永久關閉,重新開機後生效。
#This file controls the state of SELinux on the system.#SELINUX= can take one of these three values:#enforcing - SELinux security policy is enforced.#permissive - SELinux prints warnings instead of enforcing.#disabled - No SELinux policy is loaded.SELINUX=disabled #disabled為關閉#SELINUXTYPE= can take one of three two values:#targeted - Targeted processes are protected,#minimum - Modification of targeted policy. Only selected processes are protected. #mls - Multi Level Security protection.SELINUXTYPE=targeted
二、關閉或防火牆或開放必需端口
#關閉防火牆,并且禁用開機自啟。
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
或者 開放防火牆相應端口
firewall-cmd --zone=public --add-port=80/tcp --permanent #–permanent #永久生效,沒有此參數重新開機後失效
firewall-cmd --list-ports #檢視已經開啟的端口
firewall-cmd --reload #重新載入
firewall-cmd --zone= public --query-port=80/tcp #檢視
firewall-cmd --zone= public --remove-port=80/tcp --permanent #删除
三、安裝Zabbix的Yum源,以及MySQL的源。
http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/ #在這個頁面下,找到release的rpm包,并且安裝到系統上
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
四、安裝Zabbix和MySQL
yum install -y zabbix-server-mysql zabbix-web-mysql mysql-community-server zabbix-agent
systemctl start mysqld #啟動MySQL資料庫
mysql_secure_installation #初始化資料庫資訊
五、建立zabbix資料庫,建立zabbix賬号
mysql -uroot -p
...
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
六、導入預設的Zabbix資料庫資訊
zcat /usr/share/doc/zabbix-server-mysql-3.0.18/create.sql.gz | mysql zabbix -uzabbix -pzabbix
七、修改Zabbix_server.conf的配置檔案,将以下行内容修改正确,DBPassword是剛才建立資料庫的密碼。
[root@linux-node2 ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
八、修改配置檔案/etc/httpd/conf.d/zabbix.conf,時區改成Asia/Shanghai
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
九、啟動各項服務并設定為開機啟動
systemctl start zabbix-server.service
systemctl start mysqld.service
systemctl start httpd.service
systemctl start zabbix-agent.service
systemctl enable zabbix-server
systemctl enable mysqld
systemctl enable httpd
systemctl enable zabbix-agent
Zabbix-server的預設賬号Admin,密碼zabbix
移除或改名web目錄下面的setup.php檔案
mv setup.php setup.php.bak
登陸成功後馬上更改Admin的密碼