In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to install redis and MySQL in CentOS. It is very detailed and has certain reference value. Friends who are interested must finish it!
1 | 0MySQL (MariaDB)
| 1 | 1: description |
MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and licensed by GPL.
One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting down MySQL, so the community uses a branching approach to avoid this risk.
In other words, MySQL is going to charge a fee.
MariaDB is fully compatible with MySQL, including API and the command line, making it an easy replacement for MySQL.
The Red Hat Enterprise Linux/CentOS 7.0 release has switched the default database from MySQL to MariaDB.
| 1 | 22. Add MariaDB yum repository |
Current environment: yum source of Ali Cloud
Direct yum install mariadb found that the version is very low, or version 5.5, the official version has been launched 10.1
According to the programmer's urine nature, of course, it is to download the latest official version.
# first add the YUM configuration file MariaDB.repo file of MariaDB to the RHEL/CentOS and Fedora operating systems. Mkdir mariadb.repo# then edit the create mariadb.repo warehouse file vi / etc/yum.repos.d/MariaDB.repo# and enter I to enter edit mode, and add the repo warehouse configuration [mariadb] name = MariaDBbaseurl = http://yum.mariadb.org/10.1/centos7-amd64gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1
There are a lot of complaints here that the official server is abroad, the download is too slow!
| 1 | 3. Install MariaDB |
# when the MariaDB warehouse address is added, you can easily install MariaDB with the following command. Yum install MariaDB-server MariaDB-client-y
Start MariaDB related commands
Systemctl start mariadb # start MariaDBsystemctl stop mariadb # stop MariaDBsystemctl restart mariadb # restart MariaDBsystemctl enable mariadb # set boot
| 1 | 4. Initialize MariaDB. |
Do not use it immediately after confirming that the MariaDB database software program has been installed and started successfully. In order to ensure the security and normal operation of the database, it is necessary to initialize the database program. This initialization involves the following five steps.
➢ sets the password value of the root administrator in the database (note that the password is not the password of the root administrator in the system, where the password value should be empty by default, you can press enter directly).
➢ sets the proprietary password of the root administrator in the database.
➢ then deletes the anonymous account and uses the root administrator to remotely log in to the database to ensure that the industry is running on the database
The security of business.
➢ deletes the default test database and removes a series of access rights to the test database.
➢ refreshes the authorization list so that the initialization settings take effect immediately.
Note: make sure that after the mariadb server starts, execute the command initialization
Mysql_secure_installation
And then it's all the way to the end. You can also configure it according to your own needs, such as:
Disallow root login remotely? Root users are prohibited from logging in remotely. You can choose it.
| 1 | 5: 5. Set MariaDB to support Chinese characters |
MariaDB is the same as MySQL. The database format is Latin and Chinese is not supported by default.
We have to change its data format to utf-8.
# Open the configuration file vim / etc/my.cnf# and dG to clear the folder first. Press g to return to the first line without emptying. Then dG clear # and press I to enter edit mode to copy the following code [mysqld] character-set-server=utf8collation-server=utf8_general_cilog-error=/var/log/mysqld.logdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group # customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid## include all files from the config directorycomplete responsibility dedir / etc/my.cnf.d# finally press Esc Enter command mode,: wq! Save forced exit
Just in case you forget how to operate vim, so the steps are all in it! Be considerate ~
| 1 | six, log in |
Note: restart the database before logging in
Systemctl restart mariadb mysql-uroot-p # you read it correctly, this is the login command # MariaDB [(none)] >\ s # View the encoding settings after login
All other commands are exactly the same as MySQl.
If you don't understand, read my MySQL blog.
2 | 0redis installation
| 2 | 1: yum installation |
# premise is to configure Aliyun yum source, Epel source # to check whether there is a redis package yum list redis# installation redisyum install redis-y # installation, start redissystemctl start redis
If there is no source configuration, there are also two solutions:
Plan 1: go to my last blog and configure domestic sources
Plan 2: continue to look at ⬇
Check if redis is working
Redis-cli # redis client tool
# after entering the interactive environment, execute ping and return pong to indicate that the installation is successful
127.0.0.1 purl 6379 > ping
PONG
| 2 | 2. Compile and install redis for source code |
# 1. Download redis source code, you can download cd / opt to this directory wget http://download.redis.io/releases/redis-4.0.10.tar.gz# 2. Extract tar-zxf redis-4.0.10.tar.gz# 3. Switch to the redis source directory cd redis-4.0.10# 4. Compile the source file make & & make install # 5. Start the redis server. / redis-server
Description of the redis executable file
. / redis-benchmark # tool for redis performance testing. / redis-check-dump # for repairing faulty dump.rdb files. / redis-cli # redis client. / redis-server # redis server. / redis-check-aof # for repairing faulty AOF files. / redis-sentinel # for cluster management
By default, redis-server runs in a non-daemon manner, and the default service port is 6379.
At this point, redis can run normally.
The following is about security.
| 2 | 3III. Switch redis port |
Purpose: since the redis port is 6379 by default, hackers can take advantage of this to hack into your server, so they have to change to an unexpected port to run redis
Another is that after redis is configured, the redis-server server will not be mounted by default when it is started. It will run the server in the background, so you do not need to switch windows to run the client.
# 1. First change to the target directory cd / opt/redis-4.0.10/# 2. Create the file touch redis-6380.conf# 3. Create a folder mkdir 638 4. Open the file vi / opt/redis-4.0.10/redis-6380.conf # 5. Press I to enter the editing default Copy the following code port 6380 # redis database instance daemonize yes # running in 6380 redis pidfile / opt/redis-4.0.10/6380/redis.pid # File loglevel notice # Log level logfile "/ opt/redis-4.0.10/6380/redis.log" # specify the generation directory of the redis log file dir / opt/redis-4.0.10/6380 # specify the redis data file Folder directory protected-mode yesrequirepass 123 # set the password of redis Change the password by yourself # and then press the Esc key to enter command mode, enter: wq! Save and force exit # for compatibility, delete the comment when copying!
You can also configure the file path according to your own requirements.
At this point, starting the redis server command becomes like this.
Redis-server redis-6380.conf
The command to start the client has also changed
Redis-cli-p 6380-a 123 #-p sets the port of the redis link #-a displays the filled password # or redis-cli-p 6380auth 123 is all the contents of the article "how to install redis and MySQL in CentOS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.