Installation Environment: CentOS7 64 bit mounting MySQL5.7
First, install MySQL
1, a source configured YUM
In MySQL download the source rpm YUM installation package official website: http://dev.mysql.com/downloads/repo/yum/
# Download source installation package mysql the shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch. RPM # mysql installation source the shell > yum localinstall mysql57-Community-Release-el7- 8.noarch.rpm
Check whether the installation was successful mysql source
shell> yum repolist enabled | grep "mysql.*-community.*"
2, Installing MySQL
shell> systemctl start mysqld
3, start the MySQL service
shell> systemctl start mysqld
View start-up state of MySQL
shell> systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled) Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago Main PID: 2888 (mysqld) CGroup: /system.slice/mysqld.service └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server... 6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
4, boot
shell> systemctl enable mysqld shell> systemctl daemon-reload
5, modify the default root password
Mysql After installation is complete, /var/log/mysqld.log file to generate a default root password. Find the root password by default in the following manner, and then log mysql modify:
shell> grep 'temporary password' /var/log/mysqld.log
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
or
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
Note: mysql5.7 default installation password security check-ins (validate_password), check the default password policy requires password must contain: uppercase and lowercase letters, numbers and special symbols, and the length can not be less than eight. Otherwise it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown below:
You can view information about password policies through msyql environment variables:
mysql> show variables like '%password%';
validate_password_policy: password policy, the default is MEDIUM strategy validate_password_dictionary_file: password policy file, the policy is only required STRONG validate_password_length: Minimum password length validate_password_mixed_case_count: uppercase and lowercase characters length, at least one validate_password_number_count: Digital least one validate_password_special_char_count: at least one special character above parameters is the default strategy MEDIUM password checking rules.
There are several password policy:
Tactics | Check the rules |
---|---|
0 or LOW | Length |
1 or MEDIUM | Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG | Length; numeric, lowercase/uppercase, and special characters; dictionary file |
MySQL network password policy official details: http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy
Modify password policy
Add validate_password_policy /etc/my.cnf configuration file, specify a password policy
Select # 0 (the LOW),. 1 (MEDIUM,), 2 (STRONG) one, a password is required to select two dictionary file
validate_password_policy = 0
If no password policy, add the my.cnf file, add the following configuration can be disabled:
validate_password = off
Restart the mysql service to validate the configuration:
systemctl restart mysqld
6, add a remote user login
By default only allow the root account to log on locally, if you want to connect mysql on another machine, you must modify the root allow remote connections, or add an account to allow remote connections, for security reasons, I add a new account:
MySQL> GRANT ALL PRIVILEGES ON . * * the TO 'your username' @ '%' IDENTIFIED BY 'user password' WITH GRANT OPTION;
7, configured default encoding is utf8
/Etc/my.cnf modify the configuration file, add code disposed [mysqld] next, as follows:
[mysqld] character_set_server = utf8 init_connect = 'SET NAMES utf8'
Restart the mysql service, view the database default encoding is as follows:
The default configuration file path:
Profile: /etc/my.cnf
Log Files: /var/log//var/log/mysqld.log
Service startup script: /usr/lib/systemd/system/mysqld.service
socket file: /var/run/mysqld/mysqld.pid
Second, install Zabbix
zabbix directly open the official website, in the Download page to choose their own platform, and then execute the following command to complete the entire installation process.
https://www.zabbix.com/download?zabbix=4.2&os_distribution=centos&os_version=7&db=mysql
Start Service
# systemctl restart zabbix-server zabbix-agent httpd
# systemctl enable zabbix-server zabbix-agent httpd
Login zabbix
Third, the deal with common problems
1. After the installation how to access the browser?
http://server_ip_or_name/zabbix
CentOS view the local IP method:
shell -> ip addr
2. mysql allow remote root login
Log in mysql
> mysql -u root -p
Switching mysql database
mysql> use mysql
Execute queries , view the database currently has access to information
mysql> SELECT User, Password, Host FROM user;
Set access permissions
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
The "*. *" Represents all the resources of all authority, " 'root' @%" which represents the root account name,% represents all access address, you can also use a unique address to be replaced, only one address can be accessed. If the address may use a combination of a segment%, such as 10.0.42.%. IDENTIFIED BY 'root', this refers to the root access password. WITH GRANT OPTION allows for cascading authorization.
Access to refresh the table (do not forget)
mysql> FLUSH PRIVILEGES;
Verify Remote Access
> mysql -u root -p -h 10.0.42.180
3. Check mysql version
mysql> select version();
4. Check the port number mysql
After logging enter the command
mysql> show global variables like 'port';
5. centos7 open and view ports
centos7 firewall Firewall changed, using iptables no effect, open port method is as follows:
> firewall-cmd --zone=public --add-port=80/tcp --permanent
Return success to success
Command Meaning:
--zone # Scope
--add-port = 80 / tcp # Add port, the format is: port / protocol
--permanent # permanent
Restart the firewall:
> systemctl restart firewalld.service
Turn off the firewall:
> systemctl stop firewalld.service
Check listening (Listen) port
> netstat -lntp
Check the port is occupied by what process
netstat -lnp|grep 8080
6. Zabbix 报错: The frontend does not match Zabbix database
When this error occurs zabbix to import data into the database, the corresponding mysql version number does not match with the current, relevant code is: zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p -h 192.168.0.254 zabbix
solutions enter cd / usr / share / doc / enter in SSH, then enter ls enter doc folder will show all of the following file name information, then you can see zabbix-server-mysql-4.0.7) , so to change it into a 4.0.7 version 4.0.0 database to import this line of code.
# zcat /usr/share/doc/zabbix-server-mysql-4.2.5/create.sql.gz | mysql -uzabbix -p zabbix
The "zabbix-server-mysql-4.2.5" replaced with the actual name of the directory.
7. Zabbix initiate a message can not set resource limit: [13] Permission denied problem solving
Basically determine selinux problem, the solution is as follows:
1. Turn off selinux (not recommended)
setenforce 0
2. Update selinux policy to
yum update selinux-policy.noarch selinux-policy-targeted.noarch
After the update is complete restart can zabbix
The processing method update Centos 7:
1. Install selinux tools
yum install policycoreutils-python
2. If server_agent side, the following operation is performed
cat /var/log/audit/audit.log | grep zabbix_agentd | grep denied | audit2allow -M zabbix_agent_setrlimit
After executing the above command will generate a directory named zabbix_agent_setrlimit.pp current file, then execute the following command
semodule -i zabbix_agent_setrlimit.pp
If the server side, it can be performed in the following manner
cat /var/log/audit/audit.log | grep zabbix_server | grep denied | audit2allow -M zabbix_server_setrlimit
semodule -i zabbix_server_setrlimit.pp
If not, do the following
sudo cat /var/log/audit/audit.log | grep zabbix_server | grep denied | audit2allow -M zabbix-server_setrlimit # generated Module1 the sudo the semodule ZABBIX -i-server_setrlimit .pp # Import Module1 the sudo the semodule -l # Import verification
Reproduced in: https: //www.cnblogs.com/yangyxd/p/11050637.html