因项目的需求,低版本的MySQL在性能上不能满足我们的需求,现在需要更换为高版本的MySQL 5.5.44.新版本的MySQL 5.5.44在性能上,比起CentOS 5.11自带的低版本的MySQL 5.0.95,至少要高一倍以上。
MySQL 5.5.44的安装,我们这边就不采用源码安装而是直接使用编译好的版本。
yum -y install gcc gcc-devel gcc-c++ gcc-c++-devel libaio-devel boost boost-devel autoconf* automake* zlib* libxml* ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel unzip groupadd -g 10001 mysql useradd -u 10001 -s /sbin/nologin -d /dev/null -g mysql mysql mkdir /data wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.44-linux2.6-x86_64.tar.gz tar zxf mysql-5.5.44-linux2.6-x86_64.tar.gz mv mysql-5.5.44-linux2.6-x86_64 /data/mysql5.5.44 echo "127.0.0.1 $HOSTNAME">>/etc/hosts chown -R mysql.mysql /data/mysql5.5.44/data /data/mysql5.5.44/scripts/mysql_install_db --user=mysql --group=mysql --basedir=/data/mysql5.5.44 --datadir=/data/mysql5.5.44/data cp /data/mysql5.5.44/support-files/my-medium.cnf /etc/my.cnf cp /data/mysql5.5.44/support-files/mysql.server /etc/init.d/mysqld sed -i ‘s#^basedir=$#basedir=/data/mysql5.5.44#g‘ /etc/init.d/mysqld sed -i ‘s#^datadir=$#datadir=/data/mysql5.5.44/data#g‘ /etc/init.d/mysqld chmod 750 /etc/init.d/mysqld service mysqld start ln -s /data/mysql5.5.44/bin/* /usr/bin/ mysqladmin -uroot password 123456 mysql -uroot -p123456 -e ‘delete from mysql.user where password=""‘ mysql -uroot -p123456 -e ‘drop database test‘
以上MySQL就已经正常安装及使用。
源码安装请参阅:http://fengwan.blog.51cto.com/508652/1363566
现在编译安装OpenSIPS,你会发现无法编译
这个时候是因为OpenSIPS找不到MySQL的库,如果yum安装的话至少要安装mysql及mysql-devel.
我们这里就不yum安装了,因为已经安装了mysql。
ln -s /data/mysql5.5.44/bin/* /usr/bin/ ln -s /data/mysql5.5.44/include/ /usr/include/mysql ln -s /data/mysql5.5.44/lib/ /usr/lib64/mysql ln -s /data/mysql5.5.44/lib/* /usr/lib64/
将以上库及包含文件软链接即可正常。
yum -y install gcc make zlib-devel wget yum -y install flex bison ncurses-devel openssl-devel yum -y install lynx svn libxslt wget http://opensips.org/pub/opensips/1.11.5/src/opensips-1.11.5-latest_src.tar.gz tar zxf opensips-1.11.5-latest_src.tar.gz cd opensips-1.11.5-tls/ make prefix=/data/opensips1.11.5 all include_modules="db_mysql" make prefix=/data/opensips1.11.5 install include_modules="db_mysql" cd sed -i ‘s/\# DBENGINE=MYSQL/DBENGINE=MYSQL/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc sed -i ‘s/\# DBHOST=localhost/DBHOST=localhost/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc sed -i ‘s/\# DBNAME=opensips/DBNAME=opensips/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc sed -i ‘s/\# DBRWUSER=opensips/DBRWUSER=opensips/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc sed -i ‘s/\# DBRWPW="opensipsrw"/DBRWPW="opensipsrw"/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc sed -i ‘s/\# DBROOTUSER="root"/DBROOTUSER="root"/g‘ /data/opensips1.11.5/etc/opensips/opensipsctlrc ln -s /data/opensips1.11.5/etc/opensips/ /etc/ echo ‘export PATH=$PATH:/data/opensips1.11.5/sbin/‘ >>/etc/profile source /etc/profile /data/opensips1.11.5/sbin/opensipsdbctl create /data/opensips1.11.5/sbin/osipsconfig rm -f /data/opensips1.11.5/etc/opensips/opensips.cfg mv /data/opensips1.11.5/etc/opensips/opensips_residential_*.cfg /data/opensips1.11.5/etc/opensips/opensips.cfg sed -i ‘s/disable_tcp=no/disable_tcp=yes/g‘ /data/opensips1.11.5/etc/opensips/opensips.cfg sed -i ‘s/listen=udp:127.0.0.1:5060/listen=udp:eth0:5060/g‘ /data/opensips1.11.5/etc/opensips/opensips.cfg sed -i ‘s#mpath="/usr/local/lib/opensips/modules/"#mpath="/data/opensips1.11.5/lib64/opensips/modules/"#g‘ /data/opensips1.11.5/etc/opensips/opensips.cfg sed -i -e ‘/modparam("uri", "use_uri_table", 0)/a\modparam("uri", "db_url","mysql://opensips:opensipsrw@localhost/opensips")‘ /data/opensips1.11.5/etc/opensips/opensips.cfg echo "local0.* /var/log/opensips.log" >> /etc/syslog.conf service syslog restart mysql -uroot -p123456 -e "insert into opensips.domain(domain) values(‘192.168.1.245‘)" #192.168.1.245为你的sip域,可以为ip cp /root/opensips-1.11.5-tls/packaging/fedora/opensips.init /etc/init.d/opensips sed -i ‘s#cfgdir="/etc/$prog"#cfgdir="/data/opensips1.11.5/etc/$prog"#g‘ /etc/init.d/opensips sed -i ‘s#opensips=/usr/sbin/$prog#opensips=/data/opensips1.11.5/sbin/$prog#g‘ /etc/init.d/opensips chmod +x /etc/init.d/opensips groupadd opensips useradd -g opensips -s /sbin/nologin -d /dev/null opensips service opensips start
若有不懂的,参阅http://fengwan.blog.51cto.com/508652/1655265
若启动OpenSIPS的时候出现
ERROR:core:sr_load_module: could not open modu le </data/opensips1.11.5/lib64/opensips/modules/db_mysql.so>: libmysqlclient.so. 18: cannot open shared object file: No such file or directory
运行
ln -s /data/mysql5.5.44/lib/* /usr/lib64/
将库链接上即可
本文出自 “枫林晚” 博客,请务必保留此出处http://fengwan.blog.51cto.com/508652/1669752
原文地址:http://fengwan.blog.51cto.com/508652/1669752