首页
自习室
互通有无
搞钱日记
养生记
包罗万象
Search
1
解决 docker run 报错 oci runtime error
49,311 阅读
2
WebStorm2023最新激活码
27,531 阅读
3
互点群、互助群、微信互助群
22,706 阅读
4
常用正则表达式
21,525 阅读
5
罗技鼠标logic g102驱动程序lghub_installer百度云下载windows LIGHTSYNC
19,253 阅读
自习室
CODER
课程
SEO
学习视频
手册资料
呆萌
工具软件
运维
DBA
互通有无
微信群
兑换码
资源
搞钱日记
养生记
包罗万象
Search
标签搜索
DeepSeek
学习指北
Loong
累计撰写
173
篇文章
累计收到
0
条评论
首页
栏目
自习室
CODER
课程
SEO
学习视频
手册资料
呆萌
工具软件
运维
DBA
互通有无
微信群
兑换码
资源
搞钱日记
养生记
包罗万象
页面
搜索到
20
篇与
的结果
2020-08-11
CentOS安装新版RabbitMQ解决Erlang 版本依赖 Requires: erlang >= 21.3
RabbitMQ官网提供了新版的rpm包,但是安装的时候会提示需要erlang版本>=21.3,然而默认yum仓库中的版本较低。其实RabbitMQ在github上有提供新的erlang包,也可以直接加到yum源中vim /etc/yum.repos.d/rabbitmq-erlang.repo添加的内容:[rabbitmq-erlang]name=rabbitmq-erlang baseurl=https://dl.bintray.com/rabbitmq/rpm/erlang/20/el/7gpgcheck=1gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc repo_gpgcheck=0enabled=1yum clean all yum makecache然后去官网下载RabbitMQ的RPM包安装,这样yum会自动去源里安装依赖包。wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.6/rabbitmq-server-3.8.6-1.el7.noarch.rpm yum install rabbitmq-server-3.7.4-1.el7.noarch.rpm安装到这里就完成了,下面进行简单的配置。启动RabbitMQ服务 #service rabbitmq-server start 状态查看 #rabbitmqctl status 启用插件 #rabbitmq-plugins enable rabbitmq_management 重启服务 #service rabbitmq-server restart 添加帐号:name 密码:passwd #rabbitmqctl add_user name passwd 赋予其administrator角色 #rabbitmqctl set_user_tags name administrator 设置权限 #rabbitmqctl set_permissions -p / name ".*" ".*" ".*"
2020年08月11日
17,498 阅读
0 评论
65 点赞
2020-07-29
Centos安装部署filebeat做轻量化日志采集入库
最近在做日志采集相关的内容的需求,记录一下通过filebeat实现轻量化日志采集入库。日志采集的实现方案有很多种,比如logstash、fluentd、flume、betas等。为什么选择filebeat呢?因为logstash是jvm跑的,资源消耗比较大,启动一个logstash就需要消耗500M左右的内存,而filebeat是基于golang开发的,依赖极少,运行时只需要10多M内存资源消耗。工作原理 Filebeat可以保持每个文件的状态,并且频繁地把文件状态从注册表里更新到磁盘。这里所说的文件状态是用来记录上一次Harvster读取文件时读取到的位置,以保证能把全部的日志数据都读取出来,然后发送给output。如果在某一时刻,作为output的ElasticSearch或者Logstash变成了不可用,Filebeat将会把最后的文件读取位置保存下来,直到output重新可用的时候,快速地恢复文件数据的读取。在Filebaet运行过程中,每个Prospector的状态信息都会保存在内存里。如果Filebeat出行了重启,完成重启之后,会从注册表文件里恢复重启之前的状态信息,让FIlebeat继续从之前已知的位置开始进行数据读取。安装filebeat服务1.下载和安装key文件rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch2.创建yum源文件vim /etc/yum.repos.d/elk-elasticsearch.repo在新建的源文件中添加如下配置[elastic-5.x] name=Elastic repository for 5.x packages baseurl=https://artifacts.elastic.co/packages/5.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md3.yum安装filebeatyum install filebeat4.启动filebeatsystemctl start filebeat5.查看filebeat运行状态systemctl status filebeat或ps -ef | grep filebeat6.配置filebeat采集源文件和输出vim /etc/filebeat/filebeat.yml配置采集日志文件源:filebeat.prospectors: - input_type: log paths: - /var/lib/docker/containers/*/*.log配置输出:1).输出到elasticsearch:output.elasticsearch: hosts: ["127.0.0.1:9200"]2).输出到redis:output.redis: hosts: ["127.0.0.1:6379"] password: "M123456" data_type: "list" key: "filebeat" db: "0" timeout: 307.重启filebeat服务systemctl restart filebeat至此,filebeat安装及配置完成!
2020年07月29日
12,762 阅读
0 评论
8 点赞
2020-05-18
CentOS 7安装Elasticsearch 7.2
一、安装前准备(1)安装JDK环境首先到Oracle官网下载jdk。下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html。Elasticsearch 7.2支持JDK版本:1.8、11、12。这里使用了JDK12。具体支持情况:https://www.elastic.co/cn/support/matrix#matrix_jvm。下载JDK压缩包,通过SFTP客户端(WinSCP)上传到CentOS7相应的目录下。然后解压JDK,解压命令为:#tar -zxvf jdk-12.0.2_linux-x64_bin.tar.gz。为了使后续使用方便将将压后的目录重命名为jdk,重命名的命令为#mv jdk-12.0.2/ jdk(2)配置环境变量输入命令:#vi /etc/profile在文件尾部加入如下内容:export JAVA_HOME=/opt/jdkexport JRE_HOME=/$JAVA_HOME/jreexport CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin修改完成后,保存文件,退出。通过source命令重新加载/etc/profile文件,使得修改后的内容生效,命令如下。# source /etc/profile输入java –version查看jdk版本,输出成功,这代表安装成功。二、Elasticsearch安装配置(1)Elasticsearch安装Elasticsearch的下载地址为https://www.elastic.co/cn/downloads/elasticsearch,选择Linux版本,然后上传至CentOS服务器,进入压缩文件所在的目录,这里选择放在了/opt目录下,进入/opt目录,安装解压命令如下。# tar -zxvf elasticsearch-7.2.0-linux-86_64.tar.gz同样为了后续使用方面将解压后的目录文件重命名为elasticsearch,重命名命令如下。# mv elasticsearch-7.2.0 elasticsearch(2)修改系统参数修改系统参数的目的是确保系统有足够的资源启动Elasticsearch。a)设置内核参数# vi /etc/sysctl.conf 增加以下参数vm.max_map_count=655360b)执行以下命令确保配置生效。# sysctl -pc)设置资源参数# vi /etc/security/limits.conf# 修改如下* soft nofile 65536* hard nofile 131072* soft nproc 65536* hard nproc 131072d)设置用户资源参数# vi /etc/security/limits.d/20-nproc.conf# 设置elk用户参数elk soft nproc 65536(3)添加启动用户,设置权限因为启动Elasticsearch5.0版本及以上需要使用非root用户,需要新建一个用户来启动Elasticsearch,命令如下所示。useradd elk #创建用户elkgroupadd elk #创建组elkuseradd elk -g elk #将用户添加到组mkdir -pv /opt/elk/{data,logs} # 创建数据和日志目录# 修改文件所有者chown -R elk:elk /opt/elk/chown -R elk:elk /opt/elasticsearch/ (4)Elasticsearch配置修改Elasticsearch的配置文件/opt/elasticsearch/elasticsearch.yml。以下配置仅供参考。注意,设置参数的时候:后面要有空格!(5)使用elk用户启动Elasticsearch服务,命令如下所示。# /opt/elasticsearch/bin/elasticsearch如果要让Elasticsearch服务一直运行需要在上面命令后加&符号如下所示。# /opt/elasticsearch/bin/elasticsearch &关闭Elasticsearch服务需要查看一下这个服务所占用的进程号,然后使用kill命令杀死这个进程。然后可以通过浏览器访问到Elasticsearch,如下图所示,通过浏览器访问时需要将CentOS防火墙关闭或者在防火墙开启9200端口。(6)集群配置只需配置的cluster.name保持一致,elasticsearch节点即可自动形成集群。另外添加集群内节点的所有IP,便于发现集群内的节点,如下:discovery.seed_hosts:[“10.10.2.221”,“10.10.2.222“]cluster_initial_master_nodes:[“10.10.2.221”,“10.10.2.222“]如果该节点可以作为主节点:node.master:true否则 node.master:false如果该节点作为数据采集节点,配置node.data:false否则node.data:true(7)常用操作查看索引 curl '10.10.2.221:9200/_cat/indices?v'删除索引 curl -XDELETE 10.10.2.221:9200/apache*
2020年05月18日
9,721 阅读
0 评论
33 点赞
2019-12-20
CentOS7.2 安装MySQL、PHP报错 Killed signal terminated program cc1
CentOS7.2 安装MySQL、PHP报错 Killed signal terminated program cc1,这个原因是由于内存不足导致的,可以通过增加交换分区来解决。 对于make编译,如果是阿里云centos主机内存小于2G的,可能会在make编译到45%、63%时报错;如果是腾讯云centos主机内存为1G时,可能会在make编译到64%时报错。===============阿里云测试结果(引用)================== c++: Internal error: Killed (program cc1plus) Please submit a full bug report. See <http://bugzilla.redhat.com/bugzilla> for instructions. make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 1 make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2 make: *** [all] Error 2 ================腾讯云测试结果(实测)================= g++: fatal error: Killed signal terminated program cc1plus compilation terminated. make[2]: *** [sql/CMakeFiles/sql_gis.dir/gis/crosses.cc.o] Error 1 make[1]: *** [sql/CMakeFiles/sql_gis.dir/all] Error 2 make: *** [all] Error 2以上均为内存不足所致,可通过设置2G交换分区来解决该问题。解决方案:#获取要增加的2G的SWAP文件块 dd if=/dev/zero of=/swapfile bs=1k count=2048000 #创建SWAP文件 mkswap /swapfile #激活SWAP文件 swapon /swapfile #查看SWAP信息是否正确 swapon -s #添加到fstab文件中让系统引导时自动启动 echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstabswapfile文件的路径在/var/下,编译完后, 如果不想要交换分区了, 可以删除。删除交换分区:swapoff /swapfile rm -rf /swapfile至此,问题解决。
2019年12月20日
9,875 阅读
0 评论
66 点赞
2019-10-26
centos7搭建lnmp开发环境
centos7搭建lnmp开发环境一、安装axel1. 在shell中运行 yum install axel进行安装用yum安装如果没有的话需要安装EPEL源(Extra Packages for Enterprise Linux),为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS等,里面有1万多个软件安装 epel-releasewget https://mirrors.ustc.edu.cn/epel//7/x86\_64/Packages/e/epel-release-7-11.noarch.rpm rpm -ivh epel-release-7-11.noarch.rpm##更新yum源yum clean all yum update2. 安装后可以用axel --version查看版本。检测是否安装成功。二、安装nginx1. 安装依赖包nginx依赖ssl,rewrite,gzip 3个包,如果没有c++编译环境需要用下面命令安装。yum install gcc-c++2. 建立目录先在home目录下建一个nginx文件夹。然后进入文件。(nginx、openssl、zlib、pcre直接下载到这个文件夹,解压也是解压到这个文件夹,都安装好后直接删除即可。)cd home mkdir nginx cd nginx3. openssl库安装ssl功能需要安装openssl库 ,官网:https://www.openssl.org。建立文件夹/alidata/library/做为这3个库的安装目录。统一放一个文件夹,日后如果想卸载,直接删除就可以。在library下面再建立openssl、zlib、pcre三个文件夹。做为那3个库的安装目录。参考:https://blacksaildivision.com/how-to-install-openssl-on-centoswget https://www.openssl.org/source/openssl-1.1.1a.tar.gz yum install libtool perl-core zlib-devel -y #安装响应的组件 tar -zxvf openssl-1.1.1a.tar.gz cd openssl-1.1.1a ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib make && make install vi /etc/profile.d/openssl.sh # /etc/profile.d/openssl.sh pathmunge /usr/local/openssl/bin vi /etc/ld.so.conf.d/openssl-1.1.0g.conf # /etc/ld.so/conf.d/openssl-1.1.0g.conf /usr/local/openssl/lib #执行命令使openssl新版本lib路径生效 ldconfig -v #重开shell4. 安装zlib库gzip模块需要安装zlib库,官网:http://www.zlib.net。(axel -n 后面的10是一次性建立10个连接下载)axel -n 10 http://www.zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure --prefix=/alidata/library/zlib && make && make install5. 安装pcre库rewrite模块需要pcre库,官网:http://www.pcre.org。axel -n 10 https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz tar -zxvf pcre-8.41.tar.gz cd pcre-8.41 ./configure --prefix=/alidata/library/pcre && make && make install6. nginx的编译安装下载nginx,nginx的官网是http://nginx.org/。我们直接下载最新版本的nginx-1.14.2。在/alidata下建立server,然后在server下面分别建立nginx、mysql、php。后面会分别把对应的软件安装到这几个文件夹里。(--prefix:nginx的安装目录 ,--with-pcre:pcre的源码目录,--with-zlib和--with-openssl同理)axel -n 10 http://nginx.org/download/nginx-1.14.2.tar.gz tar -zxvf nginx-1.14.2.tar.gz cd nginx-1.14.2 ./configure \ --prefix=/alidata/server/nginx \ --with-http_realip_module \ --with-http_sub_module \ --with-http_flv_module \ --with-http_dav_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_addition_module \ --with-pcre=/home/nginx/pcre-8.41 \ --with-openssl=/home/nginx/openssl-1.1.1a \ --with-openssl-opt='enable-tls1_3 enable-weak-ssl-ciphers' \ --with-http_ssl_module \ --with-http_v2_module \ --with-zlib=/home/nginx/zlib-1.2.11 && make && make install7. 检查nginx是否安装成功检查nginx是否安装成功,如果出现下图信息,表示安装成功。cd /alidata/server/nginx/sbin ./nginx -t8. 常用命令nginx的几个常用命令:查看Nginx的版本号:./nginx -v启动Nginx:./nginx快速停止或关闭Nginx:./nginx -s stop正常停止或关闭Nginx:./nginx -s quit配置文件修改重装载命令:./nginx -s reload9. 将nginx加入系统命令vi /etc/init.d/nginx加入下面代码#!/bin/bash #nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/alidata/server/nginx/sbin/nginx nginx_config=/alidata/server/nginx/conf/nginx.conf nginx_pid=/alidata/server/nginx/run/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ [${NETWORKING} = "no"] ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /alidata/server/nginx/run/nginx.pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL保存上面的代码。然后添加到系统服务中。chmod 755 /etc/init.d/nginx chkconfig --add nginx10. 在系统服务目录中创建nginx.service文件vi /lib/systemd/system/nginx.service加入下面的代码[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/alidata/server/nginx/sbin/nginx ExecReload=/alidata/server/nginx/sbin/nginx -s reload ExecStop=/alidata/server/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target保存。再执行重加载systemctl daemon-reload设置开机启动systemctl enable nginx.service10. nginx服务命令配置好之后nginx就可以用系统服务的方式操作了。service nginx start 启动nginxservice nginx stop 关闭nginxservice nginx restart 重启nginxservice nginx reload 重新加载nginx三、安装php1. 下载php安装包新建一个文件夹/home/php文件夹存放php的安装文件。php的官网:http://www.php.net/下载php的最新版本php-7.3.1axel -n 10 http://cn2.php.net/distributions/php-7.3.1.tar.gz2. 解压压缩包tar -zxvf php-7.3.1.tar.gz cd php-7.3.13. 安装依赖库先安装php需要的依赖库(直接复制进去一次性安装好)yum -y install libxml2 yum -y install libxml2-devel yum -y install openssl yum -y install openssl-devel yum -y install curl-devel yum -y install libjpeg-devel yum -y install libpng-devel yum -y install freetype-devel yum -y install bzip2-devel yum -y install libmcrypt libmcrypt-devel yum -y install postgresql-devel yum -y install aspell-devel yum -y install readline-devel yum -y install libxslt-devel yum -y install net-snmp-devel yum -y install unixODBC-devel yum -y install libicu-devel yum -y install libc-client-devel yum -y install libXpm-devel yum -y install libvpx-devel yum -y install enchant-devel yum -y install openldap yum -y install openldap-devel yum -y install db4-devel yum -y install gmp-devel yum -y install sqlite-devel yum -y install mysql-devel如果cmake版本低于3.0.2需要升级wget https://cmake.org/files/v3.13/cmake-3.13.0.tar.gz tar -zxvf cmake-3.13.0.tar.gz cd cmake-3.13.0 ./bootstrap --prefix=/usr/ make && make install cmake --versionlibzip安装wget https://libzip.org/download/libzip-1.5.1.tar.gz tar -zxvf libzip-1.5.1.tar.gz cd libzip-1.5.1 mkdir build && cd build && cmake .. && make && make install echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf&&ldconfig -v4. 添加用户和组groupadd -r www && adduser -r -g www -s /bin/false -d /alidata/www -M www查看用户cat /etc/passwd查看组cat /etc/group5. 对php7进行配置下面代码按需求修改后全部复制进去一次性执行(php7.3去掉 --with-mcrypt, --enable-gd-native-ttf, --with-libmbfl)./configure \ --prefix=/alidata/server/php \ --with-config-file-path=/alidata/server/php/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-xmlrpc \ --with-openssl \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache \ --enable-pcntl \ --enable-posix6. 编译安装php7make && make install看到下图信息说明安装成功 (如果重新编译需要先make clean清理之前的已经编译的可执行文件)7. 查看php版本/alidata/server/php/bin/php -v8. 创建配置文件创建www.conf配置文件cd /alidata/server/php/etc/php-fpm.d cp www.conf.default www.conf创建php-fpm.conf配置文件cd /alidata/server/php/etc cp php-fpm.conf.default php-fpm.conf创建php.ini配置文件将安装源文件目录里的php.ini-production或者php.ini-development修改后缀拷贝到php安装目录的etc文件夹内cd /home/php/php-7.3.1 cp php.ini-production /alidata/server/php/etc/php.ini9. 将bin和sbin路径加入到path变量中。配置环境变量vim /etc/profile加入下面内容PATH=/user/local/cmake/bin:$PATH PATH=/alidata/server/mysql/bin:$PATH PATH=/alidata/server/php/bin:$PATH export PATH保存后执行source命令使配置立即生效source /etc/profile10. 配置php-fpm到系统服务cp /home/php/php-7.3.1/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod 755 /etc/init.d/php-fpm配置php-fpm.confvim /alidata/server/php/etc/php-fpm.conf将pid(;pid = run/php-fpm.pid)前的;去掉。12. 配置开机自动启动chkconfig --add /etc/init.d/php-fpm chkconfig php-fpm on13. 配置nginx解析php文件cd /alidata/server/nginx/conf vim nginx.conf将php解析前的#都去掉,如下图。然后保存修改。 location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; }nginx重新加载配置文件service nginx reload14. 创建一个php文件如果设置了根目录,在根目录里面新建vi /alidata/server/nginx/html/phpinfo.php输入如下代码<?php phpinfo(); ?>保存配置没问题就会看到下面的页面四、安装mysq1. 下载mysql下载mysql,官网地址:https://www.mysql.com/axel -n 10 https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.13.tar.gzyum localinstall https://repo.mysql.com//mysql80-community-release-el7-2.noarch.rpmyum -c /etc/yum.conf --installroot=/alidata/server/mysql -y install mysql-community-server2. 解压压缩包tar -zxvf mysql-8.0.13.tar.gz3. 安装编译需要的软件包yum -y install make bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools4. 编译配置重新cmake需要删除CMakeCache.txt文件cd mysql-8.0.13 cmake . \ -DCMAKE_INSTALL_PREFIX=/alidata/server/mysql \ -DMYSQL_DATADIR=/alidata/server/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/alidata/server/boost(注:如果boost已经安装过在配置里面去掉-DDOWNLOAD_BOOST=1,这个配置是用来下载boost。另外配置boost的安装目录 -DWITH_BOOST。其他的按需要配置即可。)5. 编译安装make && make install6. 创建mysql用户和组groupadd -r mysql && adduser -r -g mysql -s /bin/false -M mysql7. 修改mysql的权限chown -R mysql:mysql /alidata/server/mysql8. 数据库初始化cd /alidata/server/mysql/bin ./mysqld --initialize --basedir=/alidata/server/mysql --datadir=/alidata/server/mysql/data --user=mysql9. 加入到系统服务cp /alidata/server/mysql/support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql chkconfig --add mysql10. 配置my.cnfvim /etc/my.cnf修改对应的配置[mysqld] datadir=/alidata/server/mysql/data socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-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 [mysqld_safe] log-error=/alidata/server/mysql/log/mariadb.log pid-file=/alidata/server/mysql/log/run/mariadb.pid # # include all files from the config directory # !includedir /etc/my.cnf.d保存文件后建立mysql.sock的存放目录,并分配给mysql用户和组mkdir /var/lib/mysql chown -R mysql:mysql /var/lib/mysql创建日志文件mariadb.logtouch /alidata/server/mysql/log/mariadb.log cd /alidata/server/mysql/log chown -R mysql:mysql mariadb.log11. 启动mysqlservice mysql start如果启动有问题可以查看mariadb.log日志里面的[ERROR]部分。12. 修改初始密码,mysql登录查看mysql的初始密码???用初始密码登录mysql???cd /alidata/server/mysql/bin ./mysql -uroot -p登录后修改密码alter user user() identified by "你的新密码";修改用户的MySQL的密码认证插件是“mysql_native_password”alter user 'root'@'localhost' identified with mysql_native_password by '密码'; flush privileges;查询用户的密码插件信息use mysql select plugin,authentication_string,host,user from user;允许远程访问my.cnf添加下面参数重启数据库 default_authentication_plugin=mysql_native_password 创建用户 create user 'root'@'%' identified by 'mysql的密码'; grant all on *.* to 'root'@'%'; flush privileges;13. 配置环境变量vim /etc/profile加入下面内容export PATH=$JAVA_HOME/bin:$PATH:/alidata/server/php/bin:/alidata/server/php/sbin:/alidata/server/mysql/bin保存后执行source命令使配置立即生效source /etc/profile到这为止,lnmp的环境就配置完成了。五、安装redis下载redisaxel -n 10 http://download.redis.io/releases/redis-5.0.3.tar.gz tar -zxvf redis-5.0.3.tar.gz cd redis-5.0.3安装redismake PREFIX=/alidata/server/redis/ install配置redis新建数据目录和日志目录mkdir /alidata/server/redis/data mkdir /alidata/server/redis/log cp ./redis.conf /alidata/server/redis/ vim /alidata/server/redis/redis.conf编辑内容# IP绑定 bind 127.0.0.1 192.168.0.111 # 保护模式(开启条件为各redis之间可以互相通信,做集群不可开启) protected-mode yes # 访问端口 port 6379 # 连接超时,单位S,0为不启用超时 timeout 0 # 以守护进程运行 daemonize yes # 数据文件路径 dir /alidata/server/redis/data # 进程ID文件的路径 pidfile /alidata/server/redis/log/redis.pid # 日志文件路径 logfile /alidata/server/redis/log/redis.log # 设置登陆密码 requirepass [redis的密码] # 禁用部分危险命令 rename-command FLUSHALL "" rename-command CONFIG "" rename-command EVAL "" # 开启键过期删除通知 notify-keyspace-events Ex性能优化# 编辑/etc/rc.local vim /etc/rc.local echo never > /sys/kernel/mm/transparent_hugepage/enabled # 添加/etc/rc.local执行权限 chmod +x /etc/rc.d/rc.local # 编辑/etc/sysctl.conf vim /etc/sysctl.conf vm.overcommit_memory = 1 net.core.somaxconn = 1024 # 立即解决 echo never > /sys/kernel/mm/transparent_hugepage/enabled echo 1024 > /proc/sys/net/core/somaxconn sysctl vm.overcommit_memory=1 sysctl -p修改目录归属useradd -s /sbin/nologin -M redis chown -R redis:redis /alidata/server/redis启动redis并设置开机启动# 进入单元文件目录 cd /etc/systemd/system # 创建redis单元文件,格式为: [单元文件名].[单元文件类型] vim redis.service [Unit] Description=Start redis on boot. After=default.target network.target [Service] User=redis Group=redis Type=forking PIDFile=/alidata/server/redis/log/redis.pid ExecStart=/alidata/server/redis/bin/redis-server /alidata/server/redis/redis.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=false #Restart=always [Install] WantedBy=multi-user.target # 修改文件权限为只有root用户可以编辑该文件 chown -R root:root /etc/systemd/system/redis.service chmod -R 644 /etc/systemd/system/redis.service # 更新systemd systemctl daemon-reload systemctl enable redis systemctl start redisredis加入系统服务cp /home/redis/redis-5.0.3/utils/redis_init_script /etc/init.d/redis # 编辑/etc/init.d/redis 直接用systemctl控制开启和关闭redis # start 部分修改 #$EXEC $CONF systemctl start redis # stop 部分修改 #PID=$(cat $PIDFILE) echo "Stopping ..." #$CLIEXEC -p $REDISPORT shutdown #while [ -x /proc/${PID} ] #do # echo "Waiting for Redis to shutdown ..." # sleep 1 #done systemctl stop redis#如果没有设置开机启动 执行chkconfig redis on配置环境变量vim /etc/profile PATH=/alidata/server/redis/bin:$PATH # 使配置生效 source /etc/profile六、php安装redis扩展安装igbinary和phpredis扩展如果phpize动态编译报错Cannot find autoconf yum install m4 yum install autoconf wget http://pecl.php.net/get/igbinary-2.0.7.tgz tar -zxvf igbinary-2.0.7.tgz cd igbinary-2.0.7 phpize ./configure make && make install wget https://github.com/nicolasff/phpredis/archive/4.0.2.tar.gz tar -zxvf 4.0.2.tar.gz cd 4.0.2 #用phpize生成configure配置文件 phpize ./configure --with-php-config=/alidata/server/php/bin/php-config make && make install配置php.ini在php.ini最后一行加上 extension_dir = '/【php安装路径】/lib/php/extensions/no-debug-non-zts-20160303/' extension=igbinary.so extension=redis.so 重启php-fpm和Nginx,完成。七、php扩展trie-filter安装libiconv这个是libdatrie的依赖项wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz tar zxvf libiconv-1.15.tar.gz cd libiconv-1.15 ./configure make make install //查看版本 iconv --version 如果报 iconv: error while loading shared libraries: libiconv.so.2 ldconfig安装libdatrie最新版本下载站点https://github.com/tlwg/libdatrie/releaseswget https://github.com/tlwg/libdatrie/releases/download/v0.2.12/libdatrie-0.2.12.tar.xz tar xvJf libdatrie-0.2.12.tar.xz cd libdatrie-0.2.12 ./configure --prefix=/usr/local/libdatrie LDFLAGS=-L/usr/local/lib LIBS=-liconv make make install安装trie-filter扩展git clone https://github.com/zzjin/php-ext-trie-filter cd php-ext-trie-filter phpize ./configure --with-php-config=/alidata/server/php/bin/php-config --with-trie_filter=/usr/local/libdatrie make make install在php.ini文件最后加上extension=trie_filter.so,保存配置并重启php八、php开启opcache1. 配置php.ini文件在php的安装目录配置php.ini文件添加opcache扩展extension_dir = '/alidata/server/php/lib/php/extensions/no-debug-non-zts-20160303/' zend_extension=opcache.so配置opcache[opcache] 1. 开关打开 opcache.enable=1 2. 开启CLI opcache.enable_cli=1 3. 可用内存, 酌情而定, 单位为:Mb opcache.memory_consumption=528 4. Zend Optimizer + 暂存池中字符串的占内存总量.(单位:MB) opcache.interned_strings_buffer=8 5. 对多缓存文件限制, 命中率不到 100% 的话, 可以试着提高这个值 opcache.max_accelerated_files=10000 6. Opcache 会在一定时间内去检查文件的修改时间, 这里设置检查的时间周期, 默认为 2, 定位为秒 注意:0是一直检查不是关闭,推荐 60 opcache.revalidate_freq=60 7. 打开快速关闭, 打开这个在PHP Request Shutdown的时候回收内存的速度会提高 opcache.fast_shutdown=1
2019年10月26日
5,060 阅读
0 评论
3 点赞
1
2
3
4